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 Append data from two files into a sin... Praveen04 DFSORT/ICETOOL 5 Thu Mar 16, 2017 7:29 pm
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am
No new posts Extract set of records matching on ac... bhaskar_kanteti DFSORT/ICETOOL 3 Mon Mar 06, 2017 7:19 am
No new posts Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm


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