View previous topic :: View next topic
Author
Message
raj_mainframe08 New User Joined: 11 Sep 2007Posts: 65 Location: Gurgaon
Following are the records in the Input File
Code:
HEADER
11111111
22222222
33333333
11111111
22222222
11111111
99999999
TRAILER
HEADER
99999999
11111111
33333333
22222222
11111111
99999999
33333333
TRAILER
My requirement is to separatly SORT the reocords between First HEADER and TRAILER Group and then separatly sort records between Second HEADER and TRAILER Group. Thus the output file should look like
Code:
HEADER
11111111
11111111
11111111
22222222
22222222
33333333
99999999
TRAILER
HEADER
11111111
11111111
22222222
33333333
33333333
99999999
99999999
TRAILER
Please let me know how to do that.
Here is what i got so far. The file length is 80. If i write the below statement
Code:
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,6,CH,EQ,C'HEADER'),
PUSH=(81:ID=8))
SORT FIELDS=(81,8,ZD,A,1,8,CH,A)
OUTREC BUILD=(1,80)
I am getting below output
Code:
HEADER
TRAILER
11111111
11111111
11111111
22222222
22222222
33333333
99999999
HEADER
TRAILER
11111111
11111111
22222222
33333333
33333333
99999999
99999999
Basically i have achieved the required results but it also sorting TRAILER which i don't want.
Back to top
gcicchet Senior Member Joined: 28 Jul 2006Posts: 1702 Location: Australia
Hi,
try this
Code:
SORT FIELDS=(81,9,BI,A)
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,6,CH,EQ,C'HEADER'),
PUSH=(81:ID=8)),
IFTHEN=(WHEN=(1,6,CH,EQ,C'HEADER'),
OVERLAY=(89:X'00')),
IFTHEN=(WHEN=(1,7,CH,EQ,C'TRAILER'),
OVERLAY=(89:X'FF'))
OUTREC BUILD=(1,80)
Gerry
Back to top
gcicchet Senior Member Joined: 28 Jul 2006Posts: 1702 Location: Australia
Hi,
sorry, sort fields should be
Code:
SORT FIELDS=(81,9,BI,A,1,8,BI,A)
Gerry
Back to top
Please enable JavaScript!