Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

To remove duplicates from an arry using DELDUPS in REXX

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
HameedAli

Active User


Joined: 16 Apr 2009
Posts: 151
Location: India

PostPosted: Tue Jun 09, 2009 1:26 pm    Post subject: To remove duplicates from an arry using DELDUPS in REXX
Reply with quote

How can I remove duplicates from an array using DELDUPS in REXX?

Code:
/* REXX */                                                         
                                                                   
"EXECIO * DISKR DDIN (STEM LINENUM. FINIS "                       
"FREE FI(DDIN)"                                                   
TRACE ?R                                                           
ADDRESS ISREDIT                                                   
'MACRO (BEGCOL ENDCOL)'                                           
IF BEGCOL = '?' THEN DO                                           
ZEDSMSG = 'DELDUPS BEGCOL,ENDCOL'                                 
ZEDLMSG = 'COMMAND SYNTAX: DELDUP BEGINNING COL, ENDING COL'       
SIGNAL QUITME                                                     
END                                                               
NUMCHECK = DATATYPE(BEGCOL,N) /* DETERMINE IF ANY PARMS HAVE */   
IF NUMCHECK /= 1 THEN BEGCOL = 1 /* BEEN PASSED. */               
NUMCHECK = DATATYPE(ENDCOL,N)                                     
IF NUMCHECK /= 1 THEN 'ISREDIT (ENDCOL) = LRECL'                   
'ISREDIT (CURRLINE) = LINENUM .ZFIRST' /* SAVE STARTING RECORD # */
'ISREDIT (LASTLINE) = LINENUM .ZLAST' /* SAVE ENDING RECORD # */ 
'ISREDIT (CL,CC) = CURSOR' /* SAVE CURSOR POSITION */ 
DUPCNT = 0                                             
DO CURRLINE = 1 TO LASTLINE - 1                       
IF CURRLINE > (LASTLINE - 1) THEN LEAVE               
'ISREDIT (LINE1) = LINE' CURRLINE                     
LINE1 = SUBSTR(LINE1,BEGCOL,(ENDCOL - BEGCOL) + 1)     
NEXTLINE = CURRLINE + 1                               
'ISREDIT (LINE2) = LINE' NEXTLINE /* GET NEXT RECORD */
LINE2 = SUBSTR(LINE2,BEGCOL,(ENDCOL - BEGCOL) + 1)     
IF LINE1 == LINE2 THEN DO                             
DUPCNT = DUPCNT + 1                                   
"ISREDIT LABEL " CURRLINE " = .A"                     
"ISREDIT LABEL " NEXTLINE " = .B"                     
"ISREDIT DELETE " NEXTLINE                             
CURRLINE = CURRLINE - 1 ; LASTLINE = LASTLINE - 1     
END                                                   
END                                                   
ZEDSMSG = DUPCNT 'DUPS DELETED'                       
ZEDLMSG = DUPCNT 'DUPLICATE LINES WERE DELETED'     
QUITME:                                             
ADDRESS ISPEXEC                                     
'SETMSG MSG(ISRZ000)'                               
EXIT 0


The above code is hitting "Bad arithmetic conversion" in
Code:
DO CURRLINE = 1 TO LASTLINE - 1

because LASTLINE contains the value 'LASTLINE'., that because of
Code:
'ISREDIT (LASTLINE) = LINENUM .ZLAST'

How do I overcome this probe?
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Tue Jun 09, 2009 1:36 pm    Post subject:
Reply with quote

What is DELDUPS ???
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Tue Jun 09, 2009 1:46 pm    Post subject:
Reply with quote

DELDUPS seems to be in-house utility, if I got it correct, this edit macro will sort a file and delete the duplicate lines from it. (at least, that's what it does at my shop)
Back to top
View user's profile Send private message
HameedAli

Active User


Joined: 16 Apr 2009
Posts: 151
Location: India

PostPosted: Tue Jun 09, 2009 2:26 pm    Post subject: Reply to: To remove duplicates from an arry using DELDUPS in
Reply with quote

Yes, Anuj you are right.
I don't know how to fix that probe of "Bad arithmetic conversion"
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10231
Location: italy

PostPosted: Tue Jun 09, 2009 2:28 pm    Post subject: Reply to: To remove duplicates from an arry using DELDUPS in
Reply with quote

looks to me that the code posted is a patchwork of things

Code:
"EXECIO * DISKR DDIN (STEM LINENUM. FINIS "                       
"FREE FI(DDIN)"           
       
have nothing to share with the rest of the code
Code:
'ISREDIT (CURRLINE) = LINENUM .ZFIRST' /* SAVE STARTING RECORD # */

but then after three lines You use CURRLINE as a DO iteration count
Code:
"ISREDIT LABEL " CURRLINE " = .A"                     
"ISREDIT LABEL " NEXTLINE " = .B"                     

again... have nothing to share with the rest of the code

furthermore inside the DO loop You change the values of the DO control variables

it' s difficult to interpret and understand somebody' s else code,
it' s even more difficult to do it with sloppy code

clean it up and repost it, You will have more chances of getting help
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Tue Jun 09, 2009 2:44 pm    Post subject:
Reply with quote

Anuj Dhawan wrote:
DELDUPS seems to be in-house utility, if I got it correct, this edit macro will sort a file and delete the duplicate lines from it. (at least, that's what it does at my shop)

If that is the case, why not just invoke the site SORT product and save all the faffing about ?
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Tue Jun 09, 2009 6:01 pm    Post subject:
Reply with quote

Quote:
Yes, Anuj you are right.
I don't know how to fix that probe of "Bad arithmetic conversion"
I'm not the right person to suggest here-- there are better people here in this Forum when it comes to REXX, have patience some one will be around or follow on what Enrico and Expat has suggested...Good Luck.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Tue Jun 09, 2009 6:37 pm    Post subject: Be afraid - be very afraid
Reply with quote

Please tell me that I have misread the code. Very easy from the lack of indentation

You are going line by line, comparing against all following lines to see if duplicates exist.

Is this going to run in foreground or background ? Well either way, if my interpretation is correct, this is a criminal and incompetant waste of resource.

At one site, they used a sort routine written in REXX, and I had to investigate what was wrong when a user complained of his job taking over 6 hours and was still running. Over 63,000 records to be sorted using a one line by one line process.

I replaced the inhouse sort routine with a call to DFSORT and the job was finished in less than 45 seconds.

It would be oh so easy to create sort cards and invoke your sort product and save a whole lot of problems and resource.

Also consider the foreground option. If the file is too large to open in edit mode ....... what happens then.

I only hope that my interpretation of the code is wrong, PLEASE let it be wrong icon_cry.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts REXX cdoe to purge a JOB from spool a... Sulabh Agrawal CLIST & REXX 11 Thu Mar 09, 2017 11:36 am
No new posts Overriding PS data in rexx Shaheen Shaik CLIST & REXX 8 Fri Mar 03, 2017 5:08 pm
No new posts REXX compiled via RXTCOMP sergeyken CLIST & REXX 7 Tue Feb 07, 2017 9:41 pm
No new posts Remove junk values in a file and rite... KP1125 DFSORT/ICETOOL 2 Wed Jan 25, 2017 9:58 pm
No new posts Sort Card to Remove Duplicate records... raj4neo SYNCSORT 2 Wed Jan 25, 2017 4:44 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us