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

Merging of FIles with Headers and Trailers


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

New User


Joined: 21 Nov 2006
Posts: 50
Location: India

PostPosted: Tue Mar 04, 2008 1:44 pm
Reply with quote

Hi,

I have two files need to be combined which has header and trailer.The merged file should have one header and trailer having the Count of number of Records.

File 1:
hh
12311
245511
TT000000004

File 2:
hh
123114444
245511444
2455113255
TT000000005

o/p File:
hh
12311
245511
123114444
245511444
2455113255
TT000000007

the Trailer count fiels is 9 bytes.can this be done by using IFTHEN.
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: Tue Mar 04, 2008 11:00 pm
Reply with quote

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 the job can be changed appropriately for other attributes.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
hh
12311
245511
TT000000004
/*
// DD *
hh
123114444
245511444
2455113255
TT000000005
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=(1,2,CH,EQ,C'hh'),OVERLAY=(81:SEQNUM,8,ZD))
  OUTFIL REMOVECC,
    OMIT=(81,8,ZD,EQ,2,OR,1,2,CH,EQ,C'TT'),
    BUILD=(1,80),
    TRAILER1=(C'TT',COUNT+1=(TO=ZD,LENGTH=9))
/*
Back to top
View user's profile Send private message
ksathishkumar83

New User


Joined: 21 Nov 2006
Posts: 50
Location: India

PostPosted: Wed Mar 05, 2008 1:08 am
Reply with quote

Hi,

Thanks For Your quick response.
Please explain me how it actually does the sort.
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 Mar 05, 2008 1:44 am
Reply with quote

It doesn't do a sort - it does a copy since your example shows the file1 records followed by the file2 records with no sorting involved.

Are you asking what the control statements do? If not, then please be more clear about what you want to know.

By the way, if you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
ksathishkumar83

New User


Joined: 21 Nov 2006
Posts: 50
Location: India

PostPosted: Thu Mar 06, 2008 12:38 pm
Reply with quote

In the same type of sort i need to add trailer count

file1:
hh
records..
.......
TT 00005 0000013

File 2:

hh
records..
.......
TT 00003 0000010

o/p:

hh
records..
.......
TT 00008 0000023
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 Mar 06, 2008 9:40 pm
Reply with quote

Quote:
i need to add trailer count


Are you talking about the second count in the trailer record?

What is it? I assumed the first count was the number of records in the output file. What is the second count? Is it related to the number of records in the file in some way, or is it just the total of the original second counts in the two input trailer records?
Back to top
View user's profile Send private message
ksathishkumar83

New User


Joined: 21 Nov 2006
Posts: 50
Location: India

PostPosted: Thu Mar 06, 2008 10:02 pm
Reply with quote

It is the total number total of the original second counts in the two input trailer records
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 Mar 06, 2008 11:36 pm
Reply with quote

You can use a DFSORT job like the following to do what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
hh
RECORD 01
RECORD 02
RECORD 03
TT 00005 0000013
/*
// DD *
hh
RECORD 01
TT 00003 0000010
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  INREC IFTHEN=(WHEN=(1,2,CH,EQ,C'hh'),OVERLAY=(81:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=(1,2,CH,EQ,C'TT'),OVERLAY=(81:C'99999999')),
        IFTHEN=(WHEN=NONE,OVERLAY=(81:SEQNUM,8,ZD,START=5))
  SORT FIELDS=(81,8,ZD,A)
  OPTION ZDPRINT
  SUM FIELDS=(4,5,ZD,10,7,ZD)
  OUTFIL OMIT=(81,8,ZD,EQ,+2),BUILD=(1,80)
/*
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 Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Grouping by multiple headers DFSORT/ICETOOL 7
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
Search our Forums:

Back to Top