D Rishi
New User
Joined: 01 Mar 2010 Posts: 21 Location: India
|
|
|
|
I have two files, each with same record length as 512.
I have to merge this two file with group by same Header & there would be only one Header for that with a total of record count as well.
File1:
-------
DIVHDR003B11009 000000041110607180558...................
Record1
Record2
Record3
Record4
DIVHDR004B11009 000000021110607180558...................
Record1
Record2
DIVHDR008B11009 000000021110607180558...................
Rec1
rec2
File2:
-------
DIVHDR004B11009 000000041110607144720...................
Rec1
Rec2
Rec3
Rec4
So my Output file should be,
DIVHDR003B11009 000000041110607180558...................
Record1
Record2
Record3
Record4
DIVHDR004B11009 000000061110607180558...................
Record1
Record2
Rec1
Rec2
Rec3
Rec4
DIVHDR008B11009 000000021110607180558...................
Rec1
rec2
The header
DIVHDR004B11009 000000021110607180558
&
DIVHDR004B11009 000000041110607144720
may be different but any one Header could be taken in output. First 9 byte "DIVHDR004" is the group by keyword & 18:8 is the position for Record count (Under each Header) which should be updated to 6 (Total of 2 of 1st file + 4 from second file = 6 in the output file ).
Please help!! |
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
D Rishi,
The following DFSORT JCL will give you the desired results. Since both files are of the same LRECL , simply concatenate them to sortin.
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=your input file1,DISP=SHR
// DD DSN=your input file2,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(538:8C'0')),
IFTHEN=(WHEN=GROUP,BEGIN=(1,6,CH,EQ,C'DIVHDR'),
PUSH=(513:1,9,ID=8,SEQ=8)),
IFTHEN=(WHEN=(1,6,CH,EQ,C'DIVHDR'),OVERLAY=(522:16C'0',538:18,8))
SORT FIELDS=(513,25,CH,A),EQUALS
SUM FIELDS=(538,8,ZD)
OUTREC IFOUTLEN=512,
IFTHEN=(WHEN=(1,6,CH,EQ,C'DIVHDR'),OVERLAY=(18:538,8))
//* |
|
|