IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Merge multiple files with header & trailer into 1 file


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
aneeta

New User


Joined: 08 Dec 2005
Posts: 48
Location: Chennai

PostPosted: Tue Apr 17, 2007 11:38 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Apr 18, 2007 12:26 am
Reply with quote

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
View user's profile Send private message
aneeta

New User


Joined: 08 Dec 2005
Posts: 48
Location: Chennai

PostPosted: Wed Apr 18, 2007 11:02 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Apr 18, 2007 11:51 pm
Reply with quote

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
View user's profile Send private message
aneeta

New User


Joined: 08 Dec 2005
Posts: 48
Location: Chennai

PostPosted: Thu Apr 19, 2007 10:16 pm
Reply with quote

Thanks Frank..
Can u explain this statement SORT FIELDS=(2,10,UFF,D)?
What REMOVECC does?

Thanks
Aneeta
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Apr 19, 2007 10:33 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 7
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Write line by line from two files DFSORT/ICETOOL 7
Search our Forums:

Back to Top