IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

To remove duplicates from an arry using DELDUPS in REXX


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
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
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: 8797
Location: Welsh Wales

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

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

Superior Member


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

PostPosted: Tue Jun 09, 2009 1:46 pm
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Jun 09, 2009 2:28 pm
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: 8797
Location: Welsh Wales

PostPosted: Tue Jun 09, 2009 2:44 pm
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

Superior Member


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

PostPosted: Tue Jun 09, 2009 6:01 pm
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: 8797
Location: Welsh Wales

PostPosted: Tue Jun 09, 2009 6:37 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
Search our Forums:

Back to Top