View previous topic :: View next topic
Author
Message
nareshdacha New User Joined: 12 Jan 2010Posts: 66 Location: US
I have an input file(which have reports) like below:
1REPORT ID: EXP-100
REPORTING FOR: XXX
........................
DATA
............................
1REPORT ID: EXP-101
REPORTING FOR: XXX
..........................
DATA
.....................
1REPORT ID: EXP-103
REPORTING FOR: XXX
....................
DATA
..............
1REPORT ID: EXP-104
REPORTING FOR: XXX
I want to split the above input file into different files. File1 should contain the EXP-100 report details, file2 should contain EXP-101 details, file3 should contain EXP-102 report details and file4 should contain EXP-104 report details.
Please suggest......
Back to top
smijoss Active User Joined: 30 Aug 2007Posts: 114 Location: pune
LRECL RECFM ??
are the records per ID constant ??
you have only 4 ids in the file ??
read "Smart DFSORT Tricks" , it has different ways to split a file , check if your requirement can be solved using them .
if not you can alwasys use IFTHEN -WHEN=GROUP
and then use OUTFIL FNAMES to split
Back to top
nareshdacha New User Joined: 12 Jan 2010Posts: 66 Location: US
Thanks for the suggestion....
LRECL = 133
RECFM = FB
Actual input file has 17 reports. I just gave the sample data.
I have searched in "Smart DFSORT Tricks" but those doesn't suite my requirement...
Back to top
nil_mf New User Joined: 06 Jun 2005Posts: 29
Hi,
You can try the below sortcard
INREC IFTHEN=(WHEN=INIT,OVERLAY=(134:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(13,3,CH,EQ,C'EXP'),OVERLAY=(142:SEQNUM,8,ZD)),
IFTHEN=(WHEN=NONE,
OVERLAY=(150:SEQNUM,8,ZD,142:134,8,ZD,SUB,150,8,ZD,M11,LENGTH=8))
SORT FIELDS=COPY
OUTFIL FNAMES=OUT1,INCLUDE=(142,8,ZD,EQ,1),BUILD=(1,133)
OUTFIL FNAMES=OUT2,INCLUDE=(142,8,ZD,EQ,2),BUILD=(1,133)
OUTFIL FNAMES=OUT3,INCLUDE=(142,8,ZD,EQ,3),BUILD=(1,133)
OUTFIL FNAMES=OUT4,SAVE,BUILD=(1,133)
regards
nil
Back to top
prahalad New User Joined: 14 Sep 2010Posts: 18 Location: Pune
Can you try with the following code. I have done for 4 output file you can repeat the OUTFIL condition for the desired number of files. Please let me know if any other details required.
Code:
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,11,CH,EQ,C'1REPORT ID:'),
PUSH=(151:17,3))
OPTION EQUALS
SORT FIELDS=(151,03,CH,A)
OUTFIL FNAMES=OUT1,INCLUDE=(151,3,ZD,EQ,101),BUILD=(1,133)
OUTFIL FNAMES=OUT2,INCLUDE=(151,3,ZD,EQ,102),BUILD=(1,133)
OUTFIL FNAMES=OUT3,INCLUDE=(151,3,ZD,EQ,103),BUILD=(1,133)
OUTFIL FNAMES=OUT4,INCLUDE=(151,3,ZD,EQ,104),BUILD=(1,133)
Back to top
Please enable JavaScript!