View previous topic :: View next topic
|
Author |
Message |
aneeta
New User
Joined: 08 Dec 2005 Posts: 48 Location: Chennai
|
|
|
|
Hi,
I have multiple files of same length and RECFM with each file having a header and a trailer.I need to merge all the files into 1 file with a single header and trailer.
Note:The header should contain the latest time stamp and the trailer should contain the total no. of records in all the files.The header can be identified by a starting 'H' and a trailer by a starting 'T'.
Eg:
RECFM=FB,LRECL=80
File1:
H2007-01-03-01.01.0000002007-01-03-01.01.000000
A
B
C
T0000003
File2:
H2007-01-02-01.01.0000002007-01-02-01.01.000000
AA
BB
CC
DD
EE
T0000005
File3:
H2007-01-01-01.01.0000002007-01-01-01.01.000000
AAA
BBB
CCCC
DDDD
EEE
FGHJ
UYU
T0000007
Output File:
H2007-01-03-01.01.0000002007-01-03-01.01.000000
A
B
C
AA
BB
CC
DD
EE
AAA
BBB
CCCC
DDDD
EEE
FGHJ
UYU
T0000015
Pls provide a solution thru DFSORT.Pls let me know if more explanation is required.
Thanks
Aneeta |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
It appears that the trailer record is just T and the count, so it can easily be recreated with TRAILER1.
Can the header record be recreated as well with H and the current date and time in some form (what form?), or does the most current header record need to be kept as is? |
|
Back to top |
|
|
aneeta
New User
Joined: 08 Dec 2005 Posts: 48 Location: Chennai
|
|
|
|
Hi Frank,
Pls make the solution generic as we have to merge different types.But the similarity between all the types of files is the Header will start with a 'H' followed by the date (may be once or twice) and the trailer with a 'T' followed by the count.
The most recent header to be populated in the output file wud be the best choice.
Pls let me know if more information is reqd.
Thanks
Aneeta |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Aneeta,
Here's a DFSORT/ICETOOL job that will do what you asked for. It keeps the most recent record as is and rebuilds the trailer record with 'T' and the new count.
Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//CON DD DSN=... input file1
// DD DSN=... input file2
// DD DSN=... input file3
//***> OUT MUST BE A MOD DATA SET
//OUT DD DISP=MOD,DSN=...
//TOOLIN DD *
SORT FROM(CON) USING(CTL1)
COPY FROM(CON) USING(CTL2)
/*
//CTL1CNTL DD *
INCLUDE COND=(1,1,CH,EQ,C'H')
SORT FIELDS=(2,10,UFF,D)
OUTFIL FNAMES=OUT,ENDREC=1
/*
//CTL2CNTL DD *
OMIT COND=(1,1,SS,EQ,C'H,T')
OUTFIL FNAMES=OUT,REMOVECC,
TRAILER1=(C'T',COUNT=(M11,LENGTH=7))
/*
|
|
|
Back to top |
|
|
aneeta
New User
Joined: 08 Dec 2005 Posts: 48 Location: Chennai
|
|
|
|
Thanks Frank..
Can u explain this statement SORT FIELDS=(2,10,UFF,D)?
What REMOVECC does?
Thanks
Aneeta |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
UFF is unsigned free format. I'm using it to treat yyyy-mm-dd as yyyymmdd. You can find details at:
Use [URL] BBCode for External Links
REMOVECC removes the ANSI carriage control character (e.g. '1' for eject), so the 'T' starts in position 1. Without REMOVECC, the 'T' would start in position 2. |
|
Back to top |
|
|
|