Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Sort Join with Duplicates in Lookup File

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

New User


Joined: 17 Mar 2009
Posts: 9
Location: India

PostPosted: Sat Sep 14, 2013 12:44 am    Post subject: Sort Join with Duplicates in Lookup File
Reply with quote

Hi,


I have 2 files which i have to join, however the lookup file, file2 is having duplicates and i want to join in the first available match and ignore the subsequent ones.
Is there anyway i can avoid the duplicates in the second file to be in the output other than sorting the second file on the key.


File 1

Code:
0001 UK
0002 JAPAN
0003 NORWAY
0004 DUBAI


File 2

Code:
0001 APPLE
0001 ORANGE
0002 MANGO
0003 GUAVA
0004 GRAPES
0004 PEACH



Fileout

Code:
0001 UK       APPLE
0002 JAPAN    MANGO
0003 NORWAY   GUAVA
0004 DUBAI    GRAPES
Back to top
View user's profile Send private message

Skolusu

Senior Member


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

PostPosted: Mon Sep 16, 2013 9:50 pm    Post subject:
Reply with quote

aviswam,

If your input is already sorted then you can use the following

Code:

//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//INA      DD *                                           
----+----1----+----2----+----3----+----4----+----5----+----
0001 UK                                                   
0002 JAPAN                                                 
0003 NORWAY                                               
0004 DUBAI                                                 
//INB      DD *                                           
0001 APPLE                                                 
0001 ORANGE                                               
0002 MANGO                                                 
0003 GUAVA                                                 
0004 GRAPES                                               
0004 PEACH                                                 
//SORTOUT  DD SYSOUT=*                                     
//SYSIN    DD *                                           
  OPTION COPY                                             
  JOINKEYS F1=INA,FIELDS=(1,4,A,81,4,A),SORTED,NOSEQCK     
  JOINKEYS F2=INB,FIELDS=(1,4,A,81,4,A),SORTED,NOSEQCK     
  REFORMAT FIELDS=(F1:1,12,F2:6,10)                       
//*                                                       
//JNF1CNTL DD *                                           
  INREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,4),PUSH=(81:SEQ=4))
//*                                                       
//JNF2CNTL DD *                                           
  INREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,4),PUSH=(81:SEQ=4))
//*


The output from this is
Code:

0001 UK     APPLE 
0002 JAPAN  MANGO 
0003 NORWAY GUAVA 
0004 DUBAI  GRAPES
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 sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Execute JCL step based on the content... sprikitik JCL & VSAM 2 Tue Oct 03, 2017 10:03 am
This topic is locked: you cannot edit posts or make replies. PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am
No new posts JOINKEYS Paired and Unpaired Sort MFwhiz DFSORT/ICETOOL 4 Fri Sep 29, 2017 1:48 am
No new posts Garbage on output file Hervey Martinez SYNCSORT 4 Wed Sep 27, 2017 12:50 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us