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: 23
Location: chennai

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 Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
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 Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm


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