# remove duplicates from a PE field in adabas without compression

**URL:** <https://techcommunity.softwareag.com/t/remove-duplicates-from-a-pe-field-in-adabas-without-compression/175231>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Mainframes\
**Created:** [March 23, 2014, 5:34pm UTC](https://techcommunity.softwareag.com/t/remove-duplicates-from-a-pe-field-in-adabas-without-compression/175231 "2014-03-23T17:34:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![aseem\_sharma](https://avatars.discourse-cdn.com/v4/letter/a/ecb155/32.png) [@aseem\_sharma](https://techcommunity.softwareag.com/u/aseem_sharma)\
**Post date:** [March 23, 2014, 5:34pm UTC](https://techcommunity.softwareag.com/t/remove-duplicates-from-a-pe-field-in-adabas-without-compression/175231/1 "2014-03-23T17:34:01Z")

</div>

i have a periodic field with duplicate occurences .I need to remove the duplicates and also move the non duplicate values up the occerence such that the c\* field is updated with only single occurence of the field. Is there any way of selecting a range of array index like 3-7 indexes all together and move one place up in index when the duplicate is removed from the them.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [March 23, 2014, 6:22pm UTC](https://techcommunity.softwareag.com/t/remove-duplicates-from-a-pe-field-in-adabas-without-compression/175231/2 "2014-03-23T18:22:36Z")

</div>

Are you really talking about a PE(riodic GROUP) or a MU(ltiple value FIELD)

---

<div class="post-metadata">

**Author:** ![aseem\_sharma](https://avatars.discourse-cdn.com/v4/letter/a/ecb155/32.png) [@aseem\_sharma](https://techcommunity.softwareag.com/u/aseem_sharma)\
**Post date:** [March 23, 2014, 7:40pm UTC](https://techcommunity.softwareag.com/t/remove-duplicates-from-a-pe-field-in-adabas-without-compression/175231/3 "2014-03-23T19:40:52Z")

</div>

hi,  
Periodic group with multivales… did find for the record…and it has dulicate vlaues in the indexes…have to remove them…since their is no compression that index remains balnk and the count (C\*) doesnt change…so have to move the other index values up…and reset the sapces so that the occurences (C\*) get rectified correctly…thanks for your help

---

<div class="post-metadata">

**Author:** ![Jerome\_LeBlanc](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/jerome_leblanc/32/111_2.png) [@Jerome\_LeBlanc](https://techcommunity.softwareag.com/u/Jerome_LeBlanc)\
**Post date:** [March 24, 2014, 3:50pm UTC](https://techcommunity.softwareag.com/t/remove-duplicates-from-a-pe-field-in-adabas-without-compression/175231/4 "2014-03-24T15:50:52Z")

</div>

To answer your original question, yes, you can do:

```auto
MOVE #VAR (3:7) TO #VAR (2:6)
RESET #VAR(7)
```

… and it behaves as you would expect it to. But, you can’t do the opposite (not that you want to in this case, just pointing it out):

```auto
MOVE #VAR (2:6) TO #VAR (3:7)
RESET #VAR(2)
```

If you try that you will end up with the value of #VAR(2) in occurrences 3 through 7.

---

<div class="post-metadata">

**Author:** ![Steve\_Robinson](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/steve_robinson/32/107_2.png) [@Steve\_Robinson](https://techcommunity.softwareag.com/u/Steve_Robinson)\
**Post date:** [March 26, 2014, 1:21pm UTC](https://techcommunity.softwareag.com/t/remove-duplicates-from-a-pe-field-in-adabas-without-compression/175231/5 "2014-03-26T13:21:37Z")

</div>

> [@](#):
>
> Periodic group with multivales… did find for the record…and it has dulicate vlaues in the indexes…have to remove them…since their is no compression that index remains balnk and the count (C\*) doesnt change…so have to move the other index values up…and reset the sapces so that the occurences (C\*) get rectified correctly…thanks for your help

What is not clear is whether you mean a PE that has MU fields in it? Or , as Wolfgang asked, do you have an MU? Or, a PE with just one field in it?

What do you mean by “duplicate values in the indexes”?

Can we see an example of the structure you are talking about?

Are you aware of the “old” way to update an MU, which does change the count?

---

<div class="post-metadata">

**Author:** ![Ralph\_Zbrog](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/ralph_zbrog/32/78_2.png) [@Ralph\_Zbrog](https://techcommunity.softwareag.com/u/Ralph_Zbrog)\
**Post date:** [April 3, 2014, 8:07am UTC](https://techcommunity.softwareag.com/t/remove-duplicates-from-a-pe-field-in-adabas-without-compression/175231/6 "2014-04-03T08:07:15Z")

</div>

Compressing an array in-place requires complicated or obscure logic. I’ll use a temporary array to simplify things.

First, here are the “before” and “after” images of the PE (although they don’t display well in a proportional font). The first column contains the count.

```auto
C* PRIVATE-ADDRESS PRIVATE-ADDRESS PRIVATE-CITY Zip
-- --------------- ------------------------- -------------------- ----------
 
 9 PO Box 7 77 Sunset Strip Los Angeles 90001
 
   Apt 9 45 Indiana Pl Burbank 91501
   20th Floor 100 Universal City Plaza Los Angeles 91608
 
 
 
 
   Suite 16 1313 Disneyland Dr Anaheim 92802
```

```auto
C* PRIVATE-ADDRESS PRIVATE-ADDRESS PRIVATE-CITY Zip
-- --------------- ------------------------- -------------------- ----------
 
 4 PO Box 7 77 Sunset Strip Los Angeles 90001
   Apt 9 45 Indiana Pl Burbank 91501
   20th Floor 100 Universal City Plaza Los Angeles 91608
   Suite 16 1313 Disneyland Dr Anaheim 92802
```

And here is the program, manipulating the demo Employees file. It includes an MU within the PE. Significant entries are copied to a temporary table. Then the temporary table is copied over top of the original.

```auto
DEFINE DATA LOCAL
1 #M (I4) CONST <10>
1 EMP VIEW OF EMPLOYEES-V2009
  2 C*PRIVATE-ADDRESS (HD='C*')
  2 PRIVATE-ADDRESS
    3 PRIVATE-ADDRESS-LINE (#M, 1:2)
    3 PRIVATE-CITY (#M)
    3 PRIVATE-POST-CODE (#M) (HD='Zip')
    3 PRIVATE-COUNTRY (#M)
    3 PRIVATE-AREA-CODE (#M)
    3 PRIVATE-PHONE (#M)
    3 PRIVATE-FAX (#M)
    3 PRIVATE-MOBILE (#M)
    3 PRIVATE-EMAIL (#M, 1:2)

1 #PA (#M)
  2 PRIVATE-ADDRESS-LINE (U30/1:2)
  2 PRIVATE-CITY (U20)
  2 PRIVATE-POST-CODE (A10)
  2 PRIVATE-COUNTRY (A3)
  2 PRIVATE-AREA-CODE (A6)
  2 PRIVATE-PHONE (A15)
  2 PRIVATE-FAX (A15)
  2 PRIVATE-MOBILE (A15)
  2 PRIVATE-EMAIL (A80/1:2)
1 #OLD (I4)
1 #NEW (I4)
END-DEFINE
G. GET EMP 1
DISPLAY EMP.C*PRIVATE-ADDRESS (EM=Z9) /* before
        EMP.PRIVATE-ADDRESS-LINE (*, 1) (AL=10)
        EMP.PRIVATE-ADDRESS-LINE (*, 2) (AL=25)
        EMP.PRIVATE-CITY (*)
        EMP.PRIVATE-POST-CODE (*)
*
FOR #OLD = 1 #M
  IF NOT EMP.PRIVATE-ADDRESS-LINE (#OLD, *) <> U' '
   AND EMP.PRIVATE-CITY (#OLD) = U' '
   AND EMP.PRIVATE-POST-CODE (#OLD) = ' '
   AND EMP.PRIVATE-COUNTRY (#OLD) = ' '
   AND EMP.PRIVATE-AREA-CODE (#OLD) = ' '
   AND EMP.PRIVATE-PHONE (#OLD) = ' '
   AND EMP.PRIVATE-FAX (#OLD) = ' '
   AND EMP.PRIVATE-MOBILE (#OLD) = ' '
   AND NOT EMP.PRIVATE-EMAIL (#OLD, *) <> ' '
    THEN
      ESCAPE TOP /* Ignore empty entries
  END-IF
  ADD 1 TO #NEW
  MOVE BY NAME EMP.PRIVATE-ADDRESS (#OLD) TO #PA (#NEW)
END-FOR
MOVE BY NAME #PA (*) TO EMP.PRIVATE-ADDRESS (*)
UPDATE (G.)
GET EMP 1
NEWPAGE
DISPLAY EMP.C*PRIVATE-ADDRESS (EM=Z9) /* after
        EMP.PRIVATE-ADDRESS-LINE (*, 1) (AL=10)
        EMP.PRIVATE-ADDRESS-LINE (*, 2) (AL=25)
        EMP.PRIVATE-CITY (*)
        EMP.PRIVATE-POST-CODE (*)
*
BACKOUT TRANSACTION
END
```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 3:30pm UTC](https://techcommunity.softwareag.com/t/remove-duplicates-from-a-pe-field-in-adabas-without-compression/175231/7 "2021-04-02T15:30:38Z")

</div>


