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

Combining the contents of 2 identically stuctured files


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

New User


Joined: 27 Sep 2007
Posts: 3
Location: Toronto

PostPosted: Fri Nov 09, 2007 6:52 am
Reply with quote

Hi There,

Just wondering how I could combine the contents of 2 identically stuctured files. Both files contain a header, details, and a trailer record. I want to include the details from both but only need one header and one trailer (it doesn't matter which). Also, each trailer contains two different record counts in PD that I would like to sum together and write to the trailer record.

Each file is FB 300 with the following being the layout of the trailer in a COBOL layout:

Code:
05  TRANSIT        PIC S9(5)  COMP-3.
05  ACCOUNT        PIC S9(7)  COMP-3.
05  REC-TYPE       PIC X.
05  NUM-ACCOUNTS   PIC S9(9)  COMP-3.
05  NUM-RECORDS    PIC S9(9)  COMP-3.


The num-accounts field and the num-records field are the two fields I need to sum together from each trailer.

Chris
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Fri Nov 09, 2007 8:26 am
Reply with quote

ChrisK
Hi, and welcome to forums.

Can you show some sample records for i/p and o/p?
How do you identify header and trailer record and detail record?
After combining both the files, should the detail records be sorted?
Back to top
View user's profile Send private message
ChrisK

New User


Joined: 27 Sep 2007
Posts: 3
Location: Toronto

PostPosted: Fri Nov 09, 2007 10:01 am
Reply with quote

Thanks for the greeting.

Actually the header, details and trailer all have the same layout for the first few bytes. So all records begin with transit, account, and then record type (in the format I described above). The record type of the header is '0', the details are '2', and the trailer is '9'. And, yes, the records need to be sorted in ascending order by the first 8 bytes (transit, account, rec type).

Thanks,

Chris
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Fri Nov 09, 2007 12:39 pm
Reply with quote

Chris,

Try this -

Code:
//STEP@  EXEC PGM=ICETOOL                       
//TOOLMSG  DD SYSOUT=*                           
//DFSMSG DD SYSOUT=*                             
//IPFILES DD DSN=FILE1,DISP=....                 
//        DD DSN=FILE2,DISP=....                 
//OPFILE DD  DSN=...,DISP=(MOD,CATLG),.....     
//TOOLIN DD *                                   
  COPY FROM(IPFILES) TO(OPFILE) USING(HEAD)     
  SORT FROM(IPFILES) TO(OPFILE) USING(DETL)     
  SORT FROM(IPFILES) TO(OPFILE) USING(TRIL)     
/*
//HEADCNTL DD *                               
**** COPY HEADER TO OP FILE                   
  SORT FIELDS=COPY,STOPAFT=1                   
/*                                             
//*                                           
//DETLCNTL DD *                               
***** COPY DETAILED RECORDS WITH SORT OPER     
  SORT FIELDS=(1,3,PD,A,                       
               4,4,PD,A,                       
               8,1,CH,A)                       
  INCLUDE COND=(8,1,CH,EQ,C'2')               
/*                                             
//*                                           
//TRILCNTL DD *                       
*** TRAILER RECORD                   
  INCLUDE COND=(8,1,CH,EQ,C'9')       
  SORT FIELDS=(8,1,CH,A)             
  SUM FIELDS=(14,5,PD)               
/*                                   
Back to top
View user's profile Send private message
ChrisK

New User


Joined: 27 Sep 2007
Posts: 3
Location: Toronto

PostPosted: Fri Nov 09, 2007 8:18 pm
Reply with quote

Beautiful!!! Works like a charm.

Thank you very much for the help!
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Sat Nov 10, 2007 7:02 am
Reply with quote

You are welcome Chris!!!!!
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 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 Merge two VSAM KSDS files into third ... JCL & VSAM 6
No new posts Joinkeys - 5 output files DFSORT/ICETOOL 7
No new posts How to append a PS file into multiple... JCL & VSAM 3
Search our Forums:

Back to Top