View previous topic :: View next topic
Author
Message
sivaraj.ramaraj Currently Banned New User Joined: 04 May 2007Posts: 3 Location: softwarew
Hi ,
I have some problem in sorting a file using DFSORT.Scenario is like,
I have to sort a file based on some reference number. But actual file is variable length format and the file format is like
T10 - Header - 238 bytes
T30 - Trailer - 143 bytes
T20 - Detail - 166 bytes - 0000000000000005
T20 - Detail - 166 bytes - 0000000000000001
T20 - Detail - 166 bytes - 0000000000000003
T20 - Detail - 166 bytes - 0000000000000001
T20 - Detail - 166 bytes - 0000000000000008
T20 - Detail - 166 bytes - 0000000000000009
T20 - Detail - 166 bytes - 0000000000000003
T20 - Detail - 166 bytes - 0000000000000001
T30 - Trailer - 143 bytes
T20 - Detail - 166 bytes - 0000000000000010
T20 - Detail - 166 bytes - 0000000000000018
T20 - Detail - 166 bytes - 0000000000000013
T20 - Detail - 166 bytes - 0000000000000015
T20 - Detail - 166 bytes - 0000000000000001
T20 - Detail - 166 bytes - 0000000000000004
T20 - Detail - 166 bytes - 0000000000000002
T20 - Detail - 166 bytes - 0000000000000001
T10 - Header - 238 bytes
T30 - Trailer - 143 bytes
T20 - Detail - 166 bytes - 0000000000002345
T20 - Detail - 166 bytes - 0000000000001234
The output should be
T10 - Header - 238 bytes
T30 - Trailer - 143 bytes
T20 - Detail - 166 bytes - 0000000000000001
T20 - Detail - 166 bytes - 0000000000000001
T20 - Detail - 166 bytes - 0000000000000001
T20 - Detail - 166 bytes - 0000000000000003
T20 - Detail - 166 bytes - 0000000000000003
T20 - Detail - 166 bytes - 0000000000000005
T20 - Detail - 166 bytes - 0000000000000008
T20 - Detail - 166 bytes - 0000000000000009
T30 - Trailer - 143 bytes
T20 - Detail - 166 bytes - 0000000000000001
T20 - Detail - 166 bytes - 0000000000000001
T20 - Detail - 166 bytes - 0000000000000002
T20 - Detail - 166 bytes - 0000000000000004
T20 - Detail - 166 bytes - 0000000000000010
T20 - Detail - 166 bytes - 0000000000000013
T20 - Detail - 166 bytes - 0000000000000015
T20 - Detail - 166 bytes - 0000000000000018
T10 - Header - 238 bytes
T30 - Trailer - 143 bytes
T20 - Detail - 166 bytes - 0000000000001234
T20 - Detail - 166 bytes - 0000000000002345
We want to sort ONLY the DETAIL records based on some reference number with an offset of (154 : 9) in DETAIL record.
Here we want to keep both HEADER and TRAILER records as it is without sorting.
Can we handle this total process in a one DFSORT step?
Could anybody please suggest the solution.
Thanks in advance,
Siva
Back to top
expat Global Moderator Joined: 14 Mar 2007Posts: 8797 Location: Welsh Wales
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
sivar,
The indicated trick only works for one header and one trailer. You have multiple headers and trailers, so you need a different trick.
I need more information to give you a solution:
It appears that groups 1 and 3 have a header and trailer, but group 2 only has a trailer. Is that the way the data really looks? Can a group start with just a header, just a trailer, or a header and a trailer? Or is it more restrictive than that (each group starts with a header and trailer but you forgot the header for group2)?
What is the LRECL of the input file?
I assume 154 does not include the RDW in positions 1-4 so the starting position is really 158 - right?
Back to top
sivaraj.ramaraj Currently Banned New User Joined: 04 May 2007Posts: 3 Location: softwarew
Hi Frank,
Yes, the indicated trick only works for one header and one trailer. But I am having multiple headers and trailers.
Each group having header,trailer and detail. sorry Frank I forgot to add header for group2.
Input file RECFM=VB,LRECL=255
Yes, Starting position is 158 of length 9 bytes packed Decimal
(i.e PIC 9(16) COMP-3) only in DETAIL.
Thanks
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Here's a DFSORT job that will do what you asked for:
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (VB/255)
//SORTOUT DD DSN=... output file (VB/255)
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,
BUILD=(1,4,5:C'2',6:SEQNUM,8,ZD,22:5)),
IFTHEN=(WHEN=(22,3,CH,EQ,C'T10'),
OVERLAY=(5:C'0',6:SEQNUM,8,ZD),HIT=NEXT),
IFTHEN=(WHEN=(22,3,CH,EQ,C'T30'),
OVERLAY=(5:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(22,3,CH,NE,C'T10'),
OVERLAY=(14:SEQNUM,8,ZD,
6:6,8,ZD,SUB,14,8,ZD,M11,LENGTH=8))
SORT FIELDS=(6,8,ZD,A,5,1,CH,A,175,9,PD,A)
OUTREC BUILD=(1,4,5:22)
/*
Back to top
Please enable JavaScript!