Page 1 of 1

Spitt file based on key field and condition

PostPosted: Thu Sep 26, 2013 2:24 pm
by trilochan_p
Hi,

I need sort code to splitt my input file into 2 files based on the key field (1 to 4) and condition filed(5 to 7), If PDF then goes that records into output file 2 else output file 1. Please see below input and output file records detail.

Input File:
1111PDF
1111
1111
2222PAP
2222
3333FAX
3333
3333
4444PDF
4444

Output File 1 (Non PDF Records):
2222PAP
2222
3333FAX
3333
3333

Output File 2 (PDF Records):
1111PDF
1111
1111
4444PDF
4444

Re: Spitt file based on key field and condition

PostPosted: Thu Sep 26, 2013 3:57 pm
by BillyBoyo
What is the RECFM and LRECL of your file?

Re: Spitt file based on key field and condition

PostPosted: Fri Sep 27, 2013 5:22 pm
by trilochan_p
RECFM = FB and LRECL=7

Re: Spitt file based on key field and condition

PostPosted: Fri Sep 27, 2013 5:59 pm
by BillyBoyo
If you use INREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,4)... you can PUSH the value from the first record of a group onto each record of a group (including that first one). If you locate this, temporarily, at position 8:, where you can put the value from 5,3.

You can then use two OUTFILs, one with an INCLUDE= for the PDF value in the extension, and the other OUTFIL having SAVE.

You can use BUILD on OUTFIL to cut the records back down to seven bytes again.