Avoid duplication in array



IBM's Command List programming language & Restructured Extended Executor

Avoid duplication in array

Postby senthil » Thu Jul 02, 2009 5:47 pm

hi all,
i have an array
arr.1 = 'peter'
arr.2 = 'parker'
arr.3 = 'osborn'
arr.4 = 'peter'
arr.5 = 'connor'
arr.6 = 'parker'
arr.7 = 'osborn'
arr.8 = 'peter'
arr.9 = 'parker'
arr.10 = 'kevin'

now i have to copy this to another array without duplications in a rexx exec.
can any one suggest a solution...............
Thanks
Senthil Kumar
senthil
 
Posts: 12
Joined: Mon Jun 01, 2009 3:23 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Avoid duplication in array

Postby dick scherrer » Thu Jul 02, 2009 11:15 pm

Hello,

As you create the new array, scan it to make sure the entry you are about enter is not already present. If it exists, increment to the next "input" entry. If it does not, move the value to the array and then increment to the next.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Avoid duplication in array

Postby expat » Fri Jul 03, 2009 3:55 pm

Dick, Creating an internal sort or cross reference duplicates routine in REXX is easy enough, but when the number of records gets higher the time taken is much increased. At one site the internal REXX sort ran for 14 hours, but an invoked SORT for the same data took 23 seconds.

The code below will read the contents of the stem FILE99 into the SORTIN DD, perform the external sort, and then read the sorted output back into the stem FILE99.

Obviously you will need to change your SYSOUT parameter to fit with your site standards, also to set the SORT parameters to your requirement, and of course to use the stem name that you have chosen.

X = MSG('OFF')
"FREE  FI(SYSIN,SYSOUT,SORTIN,SORTOUT)"
"ALLOC FI(SYSOUT)   SYSOUT(X)"
"ALLOC FI(SYSIN)    NEW TRACKS SPACE(3 3)     RECFM(F B) LRECL(80)"
"ALLOC FI(SORTIN)   NEW TRACKS SPACE(300 300) RECFM(V B) LRECL(80)"
"ALLOC FI(SORTOUT)  NEW TRACKS SPACE(300 300) RECFM(V B) LRECL(80)"
QUEUE " OPTION VLSHRT VLSCMP"
QUEUE " SORT FIELDS=(5,44,CH,A)"
QUEUE "  SUM FIELDS=NONE"
"EXECIO "QUEUED() "DISKW SYSIN   ( FINIS"
"EXECIO * DISKW SORTIN  ( STEM FILE99. FINIS"
FILE99.0 = 0
DROP FILE99.
"CALL *(SORT)"
"EXECIO * DISKR SORTOUT ( STEM FILE99. FINIS"
"FREE  FI(SYSIN,SYSOUT,SORTIN,SORTOUT)"
expat
 
Posts: 459
Joined: Sat Jun 09, 2007 3:21 pm
Has thanked: 0 time
Been thanked: 8 times

Re: Avoid duplication in array

Postby dick scherrer » Sat Jul 04, 2009 7:15 am

Hi Expat,

Foolish me. . . Believed there were only 10 entries. . .

I've never been a proponent of "whole file" processing in rexx (clist) anyway ;)

d
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Avoid duplication in array

Postby parthiban » Tue Jul 14, 2009 10:21 pm

Hi Expat,

You're right. Same happend to me. So i just used external sort.






Thanks,
Parthiban j
Parthiban jayaraman
mainframe rexxer,
Banglore
parthiban
 
Posts: 66
Joined: Mon Oct 20, 2008 7:54 pm
Location: Bangalore-India
Has thanked: 0 time
Been thanked: 0 time


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post