These were created by someone else in 1992. Yeah, I know there should be ONE 
macro that accepts more parms, but it has never been worth the time to do the 
enhancement.

Fun fact: just last week I found a bug! The macros considered lines with these 
two keys to be duplicate lines:

7475269191210720
7475269191211080

REXX mavens will know why. I've fixed that bug.

Anyway, here's the first one, which excludes all but the first line:

/* rexx - exclude all but first line of any set of duplicate lines,
          (checks portion of the line within the current bounds)    */

ADDRESS ISREDIT
         "MACRO"
         ADDRESS ISPEXEC "CONTROL ERRORS RETURN"

         progress_interval = 1.0
         x = time('E')      /* start elapsed time clock */

         "NUMBER OFF"
         "(NUMLINES) = LINENUM .ZLAST"

         linenbr = 0
         "(LEFTBND,RIGHTBND) = BOUNDS"
         previous_key = nextline()
         current_key  = nextline()
         do while rc  = 0
            if time('E') > progress_interval then do
               call progress_message linenbr,numlines
               x = time('R')
               end
            if previous_key == current_key then do
               "LABEL" linenbr "= .A"
               "EXCLUDE P'=' .A .A FIRST"
               end
            previous_key = current_key
            current_key = nextline()
            end
         exit

nextline: procedure,
         expose linenbr leftbnd rightbnd rc
         linenbr = linenbr + 1
         "(THISLINE) = LINE" linenbr
         return substr(thisline,leftbnd,rightbnd - leftbnd + 1)

progress_message: procedure
address ISPEXEC
          arg line_number,max_lines
          complete = (line_number * 100) % max_lines
          zerrsm   = ''
          zerrlm   = 'Processing...' complete'% complete'
          zerralrm = 'NO'
          zerrhm   = '*'
          zerrtp   = 'NOTIFY'
          zerrwn   = 'NORESP'
          "CONTROL DISPLAY LOCK"
          "DISPLAY MSG(ISRZ003)"
          return

And here's the second, that excludes the entire set. This one doesn't have the 
progress message logic, but that's OK; the system is fast enough that you have 
to be working on a huge file before you ever see a progress message.

/* REXX - exclude all duplicate lines, (checks portion of the line
          within the current bounds)    */

ADDRESS ISREDIT
         "MACRO"
         ADDRESS ISPEXEC "CONTROL ERRORS RETURN"
         lineprv = 0
         linenbr = 1
         "(LEFTBND,RIGHTBND) = BOUNDS"
         previous_key = nextlprv()
         current_key  = nextlnbr()
         do while rc  = 0
            if previous_key == current_key then do
               "LABEL" linenbr "= .A"
               "EXCLUDE P'=' .A .A FIRST"
               "LABEL" lineprv "= .C"
               "EXCLUDE P'=' .C .C FIRST"
               end
            previous_key = current_key
            current_key = nextlnbr()
            lineprv = lineprv + 1
            end
         exit

nextlnbr: procedure,
         expose linenbr leftbnd rightbnd rc
         linenbr = linenbr + 1
         "(THISLINE) = LINE" linenbr
         return substr(thisline,leftbnd,rightbnd - leftbnd + 1)

nextlprv: procedure,
         expose lineprv leftbnd rightbnd
         lineprv = lineprv + 1
         "(THISLINE) = LINE" lineprv
         return substr(thisline,leftbnd,rightbnd - leftbnd + 1)

-----Original Message-----
From: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> On Behalf Of 
Schmitt, Michael
Sent: Tuesday, January 14, 2025 12:08 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: ISPF edit macro to sort and delete duplicate records

I have macros that exclude duplicate records, comparing a key within the 
current bounds. Then you can delete all X.

One macro excludes all but the first of each duplicate set, the other excludes 
all of the set. Which one do you want?

-----Original Message-----
From: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> On Behalf Of 
Peter Ten Eyck
Sent: Tuesday, January 14, 2025 12:05 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: ISPF edit macro to sort and delete duplicate records

Greetings,

Anyone know of an ISPF edit macro to sort and delete duplicate records within 
PDS member or dataset?

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN



----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN



----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to