|
View previous topic :: View next topic
|
| Author |
Message |
Krishnadeva Reddy
New User

Joined: 14 Nov 2007 Posts: 40 Location: Chennai
|
|
|
|
Hi,
Could anyone please help me out on sorting records with in a group as per the example shown below:
The below file contains diff types of records with more than one batch: A-Batch, Z-Trailer, and group of H,D,I is one record.I type record is not mandatory in each group.
Input RECL = 80
Input RECFM = FB
Input file:
| Code: |
A03162011BATCH00103152011
HN000294968250012XYZ
DN0002949682500100010307201103072011
HN000294968240012ABC
DN0002949682400100010205201102052011
DN0002949682400100020205201102052011
IN0002949682400100030205201102052011
HN000294968230012TMC
DN0002949682300100010217201102172011
DN0002949682300100020217201102172011
HN000294968210012ABC
DN0002949682100100010304201103042011
HN000294968200012XYZ
DN0002949682000100010308201103082011
IN0002949682000100010308201103082011
Z000000500000070000002000000000000077595
A03162011BATCH00203152011
HN000294968250012WIC
DN0002949682500100010307201103072011
HN000294968240012MDR
DN0002949682400100010205201102052011
DN0002949682400100030205201102052011
HN000294968230012MDR
DN0002949682300100010217201102172011
IN0002949682300100020217201102172011
Z000000300000040000001000000000000004590
|
I'm trying to sort records based on the code present in H type record.The position of the code is 18 with 3 bytes length.Could you please help me out to get the output as shown below: The group containing code ABC in type H record is shown on TOP in batch1 and group containing code MDR in type H record is shown on TOP in batch2.
Output file:
| Code: |
A03162011BATCH00103152011
HN000294968240012ABC
DN0002949682400100010205201102052011
DN0002949682400100020205201102052011
IN0002949682400100030205201102052011
HN000294968210012ABC
DN0002949682100100010304201103042011
HN000294968230012TMC
DN0002949682300100010217201102172011
DN0002949682300100020217201102172011
HN000294968250012XYZ
DN0002949682500100010307201103072011
HN000294968200012XYZ
DN0002949682000100010308201103082011
IN0002949682000100010308201103082011
Z000000500000070000002000000000000077595
A03162011BATCH00203152011
HN000294968240012MDR
DN0002949682400100010205201102052011
DN0002949682400100030205201102052011
HN000294968230012MDR
DN0002949682300100010217201102172011
IN0002949682300100020217201102172011
HN000294968250012WIC
DN0002949682500100010307201103072011
Z000000300000040000001000000000000004590
|
|
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Here's a DFSORT job that will do what you asked for:
| Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/80)
//SORTOUT DD DSN=... output file (FB/80)
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'A'),
PUSH=(81:ID=8)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'H'),
PUSH=(89:1,1,90:18,3)),
IFTHEN=(WHEN=(1,1,SS,EQ,C'AZ'),OVERLAY=(89:1,1))
OPTION EQUALS
SORT FIELDS=(81,8,CH,A,89,1,CH,A,90,3,CH,A)
OUTREC BUILD=(1,80)
/*
|
|
|
| Back to top |
|
 |
Krishnadeva Reddy
New User

Joined: 14 Nov 2007 Posts: 40 Location: Chennai
|
|
|
|
Thanks Frank for providing the solution.
While I'm looking at output dataset, there is ZERO '0' written in the last byte of the output file.Any idea please why the last byte is written with '0'.
Other than this everything looks good as expected. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
| I don't see 0 in the last byte when I run the job using your input example as shown. Something must be different on your end. If your input had '0' in the last byte, so would the output. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|