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
 

 

Merging records from two files

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
scdinesh
Warnings : 1

New User


Joined: 06 Sep 2006
Posts: 37
Location: United States

PostPosted: Wed Nov 18, 2009 3:33 pm    Post subject: Merging records from two files
Reply with quote

Hi All..

Please find the below question and help me out on this

First file layout is xxxx20091115xxxxx(only one record would be there ..contains date).


second file layout is 768899999999999978908887565
767899000667777777777777778
768899999999999978908887565
767899000667777777777777778


i want to insert date record (20091115) from first file to all records of second file to get third file using sort

Expected Output:

20091115768899999999999978908887565
20091115 767899000667777777777777778
20091115768899999999999978908887565
20091115767899000667777777777777778

if u find some time could you pls send me the Sort syntax

Thanks
Dinesh
Back to top
View user's profile Send private message

Skolusu

Senior Member


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

PostPosted: Wed Nov 18, 2009 11:28 pm    Post subject:
Reply with quote

scdinesh,

The following DFSORT JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD *                                             
XXXX20091115XXXXX                                           
//SORTOUT  DD DSN=&&S1,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE) 
//SYSIN    DD *                                             
  SORT FIELDS=COPY,STOPAFT=1                               
  INREC BUILD=(C'FVALUE,C''',5,8,C'''',80:X)               
//*                                                         
//STEP0200 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SYMNAMES DD DSN=&&S1,DISP=SHR                             
//SORTIN   DD *                                             
768899999999999978908887565                                 
767899000667777777777777778                                 
768899999999999978908887565                                 
767899000667777777777777778                                 
//SORTOUT  DD SYSOUT=*                                     
//SYSIN    DD *                                             
  SORT FIELDS=COPY                                         
  INREC BUILD=(FVALUE,1,80)                                 
//*



With z/OS DFSORT V1R5 PTF UK51706 or z/OS DFSORT V1R10 PTF UK51707, you can use the Joinkeys function like shown below to get the desired results. Since both files don't have a common key we add an extra byte at pos 81 using INREC for each file via JNF1CNTL and JNF2CNTL and use that as a key for matching

Code:

//STEP0100 EXEC PGM=SORT                           
//SYSOUT   DD SYSOUT=*                             
//SORTJNF1 DD *                                   
768899999999999978908887565                       
767899000667777777777777778                       
768899999999999978908887565                       
767899000667777777777777778                       
//SORTJNF2 DD *                                   
XXXX20091115XXXXX                                 
//SORTOUT  DD SYSOUT=*                             
//SYSIN    DD *                                   
  SORT FIELDS=COPY                                 
  JOINKEYS FILE=F1,FIELDS=(81,1,A),SORTED,NOSEQCK 
  JOINKEYS FILE=F2,FIELDS=(81,1,A),SORTED,NOSEQCK 
  REFORMAT FIELDS=(F2:5,8,F1:1,80)                 
//JNF1CNTL DD *                                   
  INREC BUILD=(1,80,X)                             
//JNF2CNTL DD *                                   
  INREC BUILD=(1,80,X)                             
//*
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Thu Nov 19, 2009 12:50 pm    Post subject:
Reply with quote

This is one more solution for it.
Code:

//S1    EXEC  PGM=SORT                               
//SORTIN DD *                                         
XXXX20091115XXXXX                                     
/*                                                   
//     DD *                                           
768899999999999978908887565                           
767899000667777777777777778                           
768899999999999978908887565                           
767899000667777777777777778                           
//SORTOUT DD DSN=outptut dataset,LRECL=88
//SYSOUT    DD  SYSOUT=*                             
//SYSPRINT DD SYSOUT=*                               
//SYSIN    DD  *                                     
  OPTION COPY                                         
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,4,CH,EQ,C'XXXX'),
              PUSH=(81:5,8))                         
  OUTFIL BUILD=(81,8,1,80),OMIT=(1,4,CH,EQ,C'XXXX')   
/*                                                   
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 Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Unable to create multiple files using... mbattu COBOL Programming 3 Fri May 05, 2017 5:35 pm
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts Dynamic split of files under groups sril.krishy DFSORT/ICETOOL 4 Mon Apr 17, 2017 1:09 pm
No new posts Compare two files and subtract values ameetmund DFSORT/ICETOOL 7 Fri Mar 31, 2017 3:35 pm


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