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

DFSORT Join Keys Controlcard


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

New User


Joined: 12 Feb 2024
Posts: 17
Location: India

PostPosted: Wed Jan 21, 2026 5:34 pm
Reply with quote

Hi All,

I need help on DFSORT join keys controlcard. Below are the details for your reference:

1) I have two input PS files with FB 80 800
2) PS1 has the below values separated with a pipe(|) and contains 3000 records:

Code:
AAAAAAAA|JOHN FENWICK|ZZZZZZZ
BBBBBBBB|DANIEL|YYYYYYY
CCCCCCCC|RAVI SANKAR|XXXXXXX
DDDDDD|BRYAN|ZZZZZZZ
EEEEEEE|ROBERT|WWWWWWW
FFFFF|SHAUN|VVVVVVV
GGGG|GARY|UUUUUUU
HHHHHHHH|AMY|TTTTTTT
IIIII|JERRY|SSSSSSS
KKK|TOM|RRRRRRR


3) PS2 has the below values separated with a space and contains 2000 records. Though the length of first column varies from record to record, the second column starts at 10th position for all the records:

Code:
AAAAAAAA 111111111
BBBBBBBB 222222222
CCCCCCCC 333333333
DDDDDD   444444444
EEEEEEE  555555555
FFFFF    666666666
GGGG     777777777
HHHHHHHH 888888888
IIIII    999999999
JJJJJJJJ 234567812
KKK      000000000
MMMMMMM  123456789


Requirement :

I want to compare the first column of both the files and take the second column of PS2 to make the final output as:

Code:
111111111|AAAAAAAA|JOHN FENWICK|ZZZZZZZ
222222222|BBBBBBBB|DANIEL|YYYYYYY
333333333|CCCCCCCC|RAVI SANKAR|XXXXXXX
444444444|DDDDDD|BRYAN|ZZZZZZZ
555555555|EEEEEEE|ROBERT|WWWWWWW
666666666|FFFFF|SHAUN|VVVVVVV
777777777|GGGG|GARY|UUUUUUU
888888888|HHHHHHHH|AMY|TTTTTTT
999999999|IIIII|JERRY|SSSSSSS
000000000|KKK|TOM|RRRRRRR


After comparing, I only need the matched records to my output. I had tried the below but it is not giving expected output as the length of first column is not consistent for all records. The length of first column of PS1 varies from 3 to 8 characters:

Code:
//P12SORT EXEC PGM=SORT
//SYSOUT   DD  SYSOUT=*
//IN1      DD  DSN=PS1,DISP=SHR
//IN2      DD  DSN=PS2,DISP=SHR
//SORTOUT  DD  DSN=PS3,DISP=SHR
//SYSIN    DD  *
 JOINKEYS F1=IN1,FIELDS=(1,08,A)
 JOINKEYS F2=IN2,FIELDS=(1,08,A)
 REFORMAT FIELDS=(F2:10,09,F1:1,60)
 JOIN UNPAIRED,F1
 SORT FIELDS=(11,08,CH,A)
//*



If the length of characters should be same for join keys concept in both input files then please suggest a way out here.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1441
Location: Bamberg, Germany

PostPosted: Wed Jan 21, 2026 6:37 pm
Reply with quote

Code:
//WHATEVER EXEC PGM=ICEMAN               
//F1       DD *                           
AAAAAAAA|JOHN FENWICK|ZZZZZZZ             
BBBBBBBB|DANIEL|YYYYYYY                   
CCCCCCCC|RAVI SANKAR|XXXXXXX             
DDDDDD|BRYAN|ZZZZZZZ                     
EEEEEEE|ROBERT|WWWWWWW                   
FFFFF|SHAUN|VVVVVVV                       
GGGG|GARY|UUUUUUU                         
HHHHHHHH|AMY|TTTTTTT                     
IIIII|JERRY|SSSSSSS                       
KKK|TOM|RRRRRRR                           
/*                                       
//F2       DD *                           
AAAAAAAA 111111111                       
BBBBBBBB 222222222                       
CCCCCCCC 333333333                       
DDDDDD   444444444                       
EEEEEEE  555555555                       
FFFFF    666666666                       
GGGG     777777777                       
HHHHHHHH 888888888                       
IIIII    999999999                       
JJJJJJJJ 234567812                       
KKK      000000000                       
MMMMMMM  123456789                       
/*                                       
//SYSOUT   DD SYSOUT=*                   
//SORTOUT  DD SYSOUT=*                   
//SYSIN    DD *                           
  OPTION COPY
  JOINKEYS F1=F1,FIELDS=(81,8,A)         
  JOINKEYS F2=F2,FIELDS=(1,8,A)           
  REFORMAT FIELDS=(F2:10,8,F1:89,1,1,80) 
  END                                     
/*                                       
//JNF1CNTL DD *                           
  INREC IFTHEN=(WHEN=INIT,               
    PARSE=(%01=(ENDBEFR=C'|',FIXLEN=8),   
           %02=(SUBPOS=1,FIXLEN=1)),     
  OVERLAY=(81:%01,%02))                   
  END                                     
/*                                       
//JNF2CNTL DD *                           
  END                                     
/*

Output:
Code:
****** ***************************** Top of Data *****
000001 11111111|AAAAAAAA|JOHN FENWICK|ZZZZZZZ         
000002 22222222|BBBBBBBB|DANIEL|YYYYYYY               
000003 33333333|CCCCCCCC|RAVI SANKAR|XXXXXXX         
000004 44444444|DDDDDD|BRYAN|ZZZZZZZ                 
000005 55555555|EEEEEEE|ROBERT|WWWWWWW               
000006 66666666|FFFFF|SHAUN|VVVVVVV                   
000007 77777777|GGGG|GARY|UUUUUUU                     
000008 88888888|HHHHHHHH|AMY|TTTTTTT                 
000009 99999999|IIIII|JERRY|SSSSSSS                   
000010 00000000|KKK|TOM|RRRRRRR                       
****** **************************** Bottom of Data ***


You might need to adjust lengths for the REFORMAT to stay with FB;80
Back to top
View user's profile Send private message
cravisankar

New User


Joined: 12 Feb 2024
Posts: 17
Location: India

PostPosted: Wed Jan 21, 2026 8:12 pm
Reply with quote

Thank you for the quick reply Joerg. I will try this and get back to you.
Back to top
View user's profile Send private message
cravisankar

New User


Joined: 12 Feb 2024
Posts: 17
Location: India

PostPosted: Thu Jan 22, 2026 1:21 pm
Reply with quote

Thank you very much Joerg. The ICEMAN logic that you proposed had worked for me and it's giving the desired output.

Many thanks for your support.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1441
Location: Bamberg, Germany

PostPosted: Thu Jan 22, 2026 3:11 pm
Reply with quote

Thanks for the feedback. The logic just makes the "flexible" field a fixed one at another position, so it's usable for JK. That's it.

You can omit here the the DD:JNF2CNTL also. I just leave them always in for my testings.
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts FINDREP before JOIN DFSORT/ICETOOL 3
No new posts To join 2 tables and to join 3rd tabl... DB2 8
No new posts Date format correction using dfsort DFSORT/ICETOOL 3
No new posts DFSORT GUID DFSORT/ICETOOL 5
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
Search our Forums:


Back to Top