Alexis Sebastian
New User
Joined: 04 Mar 2010 Posts: 38 Location: DC
|
|
|
|
There is an input file in the below format,
Code: |
H21122010HEADER RECORD
D00000000019122010
D00000000020122010
D00000000021122010
T0000003
|
Input file Description:-
1. First Byte shows H - Header D- Detail T-Trailer records
2. In Header record, from position 2 to pos 9 -> header date
3. in Detail Record, from Pos 11 to pos 18 -> date field
4. In Trailer record, from pos 2 to pos 8 is the trailer count.
5. Date format is 'DDMMYYYY'
Output requirements:-
1. Need to copy the header record as it is
2. records with the latest date need to be taken out for detail records.
3. Also latest date in the detail record should match with the header date
4. Correspondingly trailer count needs to be written based on the no of detail records.
Sample Output file is given below.
Code: |
H21122010HEADER RECORD
D00000000021122010
T0000001 |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
You can use a DFSORT job like the following to do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but you can change the job appropriately for other attributes.
Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/80)
//SORTOUT DD DSN=... output file (FB/80)
//SYSIN DD *
OPTION COPY
OMIT COND=(1,1,CH,EQ,C'T')
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'H'),
PUSH=(81:2,8))
OUTFIL REMOVECC,
INCLUDE=(1,1,CH,EQ,C'H',OR,
(1,1,CH,EQ,C'D',AND,81,8,CH,EQ,11,8,CH)),
BUILD=(1,80),
TRAILER1=(C'T',COUNT-1=(M11,LENGTH=7))
/*
|
|
|