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

Merging records from two files


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

New User


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

PostPosted: Wed Nov 18, 2009 3:33 pm
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
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
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 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 Pulling a fixed number of records fro... DB2 2
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
No new posts Joinkeys - 5 output files DFSORT/ICETOOL 7
Search our Forums:

Back to Top