Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
You use IFTHEN=(WHEN=GROUP with your sequence not being blank and RECORDS=2, PUSH your sequence to an extension of the record.
Then use IFTHEN=(WHEN=(logicalexpression) to identify spaces in the seqnum, and use OVERLAY to put the extended sequence number in place of the spaces.
Return the record to it's original size. If you get that working, post the code please.
I am achieving this output using three sort steps.
On first step, I am generating Seqnum based on Key values and used RESTART to start the Sequencing, if key value changes.
On second step, I am re-sequencing and moving spaces.
On final step, I am appending the previous record sequence num.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Just quickly, the entire thing can be done in one step using IFTHEN=(WHEN=GROUP and PUSH an ID= for the length of your field. ID is a sequence number across groups, SEQ is a sequence number within a group.
You have to decide what your key is. You are SORTing on one key, but only using the low-order part of the key. This gives you a potential for "false hits" were two different high-order keys are different but consecutive, and the low-order keys are equal.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
The IFOUTLEN will have already set the record-length to 80, so when INREC is complete only the original 80 bytes are present, and you don't need the OUTFIL with BUILD.