Joined: 07 May 2003 Posts: 7 Topics: 2 Location: Seattle
Posted: Mon Sep 21, 2015 11:59 am Post subject: Split file based on finding record with particular value
I've searched on the forum, elsewhere online and in the manuals and can't quite find anything to match what I'm trying to accomplish.
I have a single file (FBA, LRECL=133) that contains two reports, one followed by the other. I simply want to split the file into two separate files, each containing a separate report.
Each report has a unique report name in the headings, like 'REPT301', 'REPT302', starting in column 2. When that 2nd report name is found, I want the records up to that point (1st report) to be put in one file and the remaining records (2nd report) to be put in another file. No sorting.
It sounds so simple... any suggestions would be appreciated.
Joined: 07 May 2003 Posts: 7 Topics: 2 Location: Seattle
Posted: Mon Sep 21, 2015 1:05 pm Post subject:
Thank you - I did see that but had hoped there was a simpler way (than having to add a sequence number, sorting, then remove it). If this is the best way to go, that's what I'll do.
I appreciate the quick response, and I enjoy browsing the forums - they often provide the answers I need.
Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Mon Sep 21, 2015 2:45 pm Post subject:
zornet57 wrote:
Thank you - I did see that but had hoped there was a simpler way (than having to add a sequence number, sorting, then remove it). If this is the best way to go, that's what I'll do.
I appreciate the quick response, and I enjoy browsing the forums - they often provide the answers I need.
zornet57,
huh? Why do you need to sort it? you just need to copy. It is quite simple. WHEN=GROUP to put the sequence number and validate that sequence on OUTFIL. It can't get any simpler than that.
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
REPT301
RPT LINE 01
RPT LINE 02
RPT LINE 03
RPT LINE 04
RPT LINE 05
REPT302
RPT LINE 01
RPT LINE 02
//REPT301 DD SYSOUT=*
//REPT302 DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(2,7,SS,EQ,C'REPT301.REPT302'),
PUSH=(134:ID=1))
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum