Page 1 of 1

Merge 2 files with header detail and trailer

PostPosted: Thu Mar 07, 2019 2:27 am
by sethukutty
Need to combine 2 input files into one output files after keeping just one header and footer. Footer is just copy of header with record count. All files are 600 length.

I/P File1
ZZZZZZZZZ02272019ZZZZZZ      
AAAAAAA                      
BBBBBBB                      
CCCCCCC                      
DDDDDDD                      
EEEEEEE                      
ZZZZZZZZZ02272019ZZZZZZ000005


I/P File2
ZZZZZZZZZ02272019ZZZZZZ      
FFFFFFF                      
GGGGGGG                      
ZZZZZZZZZ02272019ZZZZZZ000002
 

Output File
ZZZZZZZZZ02272019ZZZZZZ      
AAAAAAA                      
BBBBBBB                      
CCCCCCC                      
DDDDDDD                      
EEEEEEE  
FFFFFFF                      
GGGGGGG                    
ZZZZZZZZZ02272019ZZZZZZ000007  ---COPY OF THE HEADER PLUS RECORD COUNT


I used the following SORT card and achieved what I want but I physically inserted the footer and then calculated the record count as you see. But I do want to copy the header into footer and then add the record count so that I get the updated date. Appreciate any help.

INREC BUILD=(1,600,SEQNUM,10,ZD)                            
SORT FIELDS=COPY                                            
OUTFIL REMOVECC,BUILD=(1,600),OMIT=(601,10,ZD,GT,+1,AND,    
    1,9,CH,EQ,C'ZZZZZZZZZ'),                                    
TRAILER1=(C'ZZZZZZZZZ02272019ZZZZZZ',COUNT-1=(M11,LENGTH=6))
 

Thanks


CODE' D

Re: Merge 2 files with header detail and trailer

PostPosted: Thu Mar 07, 2019 12:31 pm
by expat
Have you downloaded and read the DFSORT smart tricks pdf that was written by Frank Yaeger ?

If not, do so, because it is detailed in that document.
You can probably find it from the DFSORT reference material section at the top of this forum section.
If not, you can always google it :mrgreen:

Re: Merge 2 files with header detail and trailer

PostPosted: Thu Mar 07, 2019 3:54 pm
by NicC
Please use the code tags when posting data, code, etc. You were asked to do this in a previous post. Failure to do so in future could lead to your post being deleted.