Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to Merge 2 files through SORT with Count in Header

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: How to Merge 2 files through SORT with Count in Header
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    Post subject: Reply to: How to Merge 2 files through SORT with Count in He
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 15 Thu Dec 01, 2016 8:28 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us