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

How to Merge 2 files through SORT with Count in Header


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

New User


Joined: 01 Mar 2010
Posts: 21
Location: India

PostPosted: Wed Jun 08, 2011 4:27 pm
Reply with quote

I have two files, each with same record length as 512.
I have to merge this two file with group by same Header & there would be only one Header for that with a total of record count as well.


File1:
-------

DIVHDR003B11009 000000041110607180558...................
Record1
Record2
Record3
Record4
DIVHDR004B11009 000000021110607180558...................
Record1
Record2
DIVHDR008B11009 000000021110607180558...................
Rec1
rec2




File2:
-------

DIVHDR004B11009 000000041110607144720...................
Rec1
Rec2
Rec3
Rec4


So my Output file should be,

DIVHDR003B11009 000000041110607180558...................
Record1
Record2
Record3
Record4
DIVHDR004B11009 000000061110607180558...................
Record1
Record2
Rec1
Rec2
Rec3
Rec4
DIVHDR008B11009 000000021110607180558...................
Rec1
rec2


The header

DIVHDR004B11009 000000021110607180558
&
DIVHDR004B11009 000000041110607144720

may be different but any one Header could be taken in output. First 9 byte "DIVHDR004" is the group by keyword & 18:8 is the position for Record count (Under each Header) which should be updated to 6 (Total of 2 of 1st file + 4 from second file = 6 in the output file ).

Please help!!
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Jun 08, 2011 10:07 pm
Reply with quote

D Rishi,

The following DFSORT JCL will give you the desired results. Since both files are of the same LRECL , simply concatenate them to sortin.

Code:

//STEP0100 EXEC PGM=SORT       
//SYSOUT   DD SYSOUT=*         
//SORTIN   DD DSN=your input file1,DISP=SHR
//         DD DSN=your input file2,DISP=SHR
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                     
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(538:8C'0')),                     
  IFTHEN=(WHEN=GROUP,BEGIN=(1,6,CH,EQ,C'DIVHDR'),                   
         PUSH=(513:1,9,ID=8,SEQ=8)),                               
  IFTHEN=(WHEN=(1,6,CH,EQ,C'DIVHDR'),OVERLAY=(522:16C'0',538:18,8))
  SORT FIELDS=(513,25,CH,A),EQUALS                                 
  SUM FIELDS=(538,8,ZD)                                             
                                                                   
  OUTREC IFOUTLEN=512,                                             
  IFTHEN=(WHEN=(1,6,CH,EQ,C'DIVHDR'),OVERLAY=(18:538,8))           
//*
Back to top
View user's profile Send private message
D Rishi

New User


Joined: 01 Mar 2010
Posts: 21
Location: India

PostPosted: Thu Jun 09, 2011 1:29 pm
Reply with quote

Kolusu, Thanx a lot. Its been working as expected.
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 Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Write line by line from two files DFSORT/ICETOOL 7
Search our Forums:

Back to Top