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

Need assistance formatting when joining/matching two files.


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
chillmo

New User


Joined: 31 Aug 2017
Posts: 30
Location: USA

PostPosted: Wed Oct 21, 2020 10:56 am
Reply with quote

I need to join 2 files and write matching records to output. Below are the details of file.

Code:


//SORTJNF1 DD *                                                 
999 C 0000000000AAAAAAAAAA 1                                   
999 C 0000000000DDDDDDDDDD 1                                   
999 C 0000000000GGGGGGGGGG 1                                   
999 C 0000000000HHHHHHHHHH 1                                   
999 C 0000000000IIIIIIIIII 1                                   
999 C 0000000000JJJJJJJJJJ 1                                   
999 C 0000000000KKKKKKKKKK 1                                   
999 C 0000000000LLLLLLLLLL 1                                   
999 C 0000000000MMMMMMMMMM 1                                   
999 C 0000000000NNNNNNNNNN 1                                   
999 C 0000000000OOOOOOOOOO 1                                   
//SORTJNF2 DD *                                                 
999 C 0000000000AAAAAAAAAA 999 D 88888888888888888888           
999 C 0000000000AAAAAAAAAA 999 D 99999999999999999999           
999 C 0000000000AAAAAAAAAA 999 D 77777777777777777777           
999 C 0000000000AAAAAAAAAA 999 D 66666666666666666666           
999 C 0000000000BBBBBBBBBB 999 D 11111111111111111111           
999 C 0000000000BBBBBBBBBB 999 D 00000000000000000000           
999 C 0000000000CCCCCCCCCC 999 D 22222222222222222222           
999 C 0000000000CCCCCCCCCC 999 D 33333333333333333333           
999 C 0000000000CCCCCCCCCC 999 D 44444444444444444444           
999 C 0000000000CCCCCCCCCC 999 D 55555555555555555555           
999 C 0000000000DDDDDDDDDD 999 D 11111111111111111115           
999 C 0000000000DDDDDDDDDD 999 D 22222222222222222225           
999 C 0000000000DDDDDDDDDD 999 D 33333333333333333335           
999 C 0000000000DDDDDDDDDD 999 D 44444444444444444445           
999 C 0000000000EEEEEEEEEE 999 D 99999999999999999998           
999 C 0000000000EEEEEEEEEE 999 D 99999999999999999997           
999 C 0000000000EEEEEEEEEE 999 D 99999999999999999996           
999 C 0000000000FFFFFFFFFF 999 D 88888888888888888887           
999 C 0000000000FFFFFFFFFF 999 D 88888888888888888886           
999 C 0000000000GGGGGGGGGG 999 D 77777777777777777771           
//F1ONLY DD SYSOUT=*                                             
//F2ONLY DD SYSOUT=*                                             
//BOTH DD SYSOUT=*                                               
//SYSIN    DD    *                                               
  SORT FIELDS=(1,28,CH,A)                                       
* CONTROL STATEMENTS FOR JOINKEYS APPLICATION                   
  JOINKEYS FILE=F1,FIELDS=(1,26,A),SORTED,NOSEQCK               
  JOINKEYS FILE=F2,FIELDS=(1,26,A),SORTED,NOSEQCK               
  JOIN UNPAIRED,F1                                               
  REFORMAT FIELDS=(F1:1,28,F2:28,26,?)                           
* CONTROL STATEMENTS FOR MAIN TASK (JOINED RECORDS)             
  OPTION COPY                                                   
  OUTFIL FNAMES=F1ONLY,INCLUDE=(55,1,CH,EQ,C'1'),               
    BUILD=(1,28)       
  OUTFIL FNAMES=F2ONLY,INCLUDE=(55,1,CH,EQ,C'2'),               
    BUILD=(29,26)                                               
  OUTFIL FNAMES=BOTH,INCLUDE=(55,1,CH,EQ,C'B'),                 
    BUILD=(1,28,C' ',29,26)                             



It works fine but I need assistance in getting the output in the format below:

Code:


999 C 0000000000AAAAAAAAAA 1 999 D 88888888888888888888
                             999 D 99999999999999999999
                             999 D 77777777777777777777
                             999 D 66666666666666666666
                                                       
999 C 0000000000DDDDDDDDDD 1 999 D 11111111111111111115
                             999 D 22222222222222222225
                             999 D 33333333333333333335
                             999 D 44444444444444444445
                                                       
999 C 0000000000GGGGGGGGGG 1 999 D 77777777777777777771

999 C 0000000000HHHHHHHHHH 1                           
                                                       
999 C 0000000000IIIIIIIIII 1                           
                                                       
999 C 0000000000JJJJJJJJJJ 1                           
                                                       
999 C 0000000000KKKKKKKKKK 1                           
                                                       
999 C 0000000000LLLLLLLLLL 1                           
                                                       
999 C 0000000000MMMMMMMMMM 1                           
                                                       
999 C 0000000000NNNNNNNNNN 1                           
                                                       
999 C 0000000000OOOOOOOOOO 1 


Any help would be greatly appreciated.

Thanks for your time! icon_smile.gif
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Wed Oct 21, 2020 11:54 am
Reply with quote

Code:
//SYSIN    DD *                                                   
  JOINKEYS FILE=F1,FIELDS=(1,26,A),SORTED,NOSEQCK                   
  JOINKEYS FILE=F2,FIELDS=(1,26,A),SORTED,NOSEQCK                   
  JOIN UNPAIRED,F1                                               
  REFORMAT FIELDS=(F1:1,28,F2:28,26,?)                           
  SORT FIELDS=(1,28,CH,A)                                         
  OUTFIL FNAMES=F1ONLY,INCLUDE=(55,1,CH,EQ,C'1'),                 
    BUILD=(1,28)                                                 
  OUTFIL FNAMES=BOTH,INCLUDE=(55,1,CH,EQ,C'B'),                   
    IFTHEN=(WHEN=INIT,OVERLAY=(56:SEQNUM,8,ZD,RESTART=(1,28))), 
    IFTHEN=(WHEN=(56,8,ZD,EQ,+1),BUILD=(1,28,C' ',29,26)),       
    IFTHEN=(WHEN=NONE,BUILD=(29X,29,26))                         
  END                                                             
/*

Output DD:BOTH:
Code:
********************************* TOP OF DATA **************
999 C 0000000000AAAAAAAAAA 1 999 D 88888888888888888888     
                             999 D 99999999999999999999     
                             999 D 77777777777777777777     
                             999 D 66666666666666666666     
999 C 0000000000DDDDDDDDDD 1 999 D 11111111111111111115     
                             999 D 22222222222222222225     
                             999 D 33333333333333333335     
                             999 D 44444444444444444445     
999 C 0000000000GGGGGGGGGG 1 999 D 77777777777777777771     
******************************** BOTTOM OF DATA ************

Output DD:F1ONLY:
Code:
********************************* TOP OF DATA ********
999 C 0000000000HHHHHHHHHH 1                         
999 C 0000000000IIIIIIIIII 1                         
999 C 0000000000JJJJJJJJJJ 1                         
999 C 0000000000KKKKKKKKKK 1                         
999 C 0000000000LLLLLLLLLL 1                         
999 C 0000000000MMMMMMMMMM 1                         
999 C 0000000000NNNNNNNNNN 1                         
999 C 0000000000OOOOOOOOOO 1                         
******************************** BOTTOM OF DATA ******
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2010
Location: USA

PostPosted: Wed Oct 21, 2020 8:18 pm
Reply with quote

Remains unclear:
1) do you need the unpaired records from F2 to be also indicated in any manner?
2) do you need the combined report in a single DD, or 2-3 separate reports for matching/non-matching records?
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Wed Oct 21, 2020 8:43 pm
Reply with quote

From JOIN UNPAIRED,F1 statement, there is no indication that a separate DD:F2 is wanted. Also I don't see a DD:SORTOUT coded. Could have been more precisely specified by the TS, indeed.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2010
Location: USA

PostPosted: Wed Oct 21, 2020 8:58 pm
Reply with quote

The original sample code includes both:
JOIN UNPAIRED,F1
and
FNAMES=F2ONLY
They are mutually exclusive.

The original sample code defines three separate OUTFIL FNAMES=, but sample output data presented only a single report.

It is unclear: which of samples are correct?
Back to top
View user's profile Send private message
chillmo

New User


Joined: 31 Aug 2017
Posts: 30
Location: USA

PostPosted: Thu Oct 22, 2020 12:32 am
Reply with quote

Sergeyken/Joerg.Findeisen,

Yes, I originally wanted 3 separate files, which is why I had F1, F2, and Both (sort card was JOIN UNPAIRED,F1,F2).
But, business changed the requirement to keep all records from F1 and if there's a match with F2, display those records (in the format I showed above). In addition, they want a blank line inserted after each match/unmatched row. I coded this but, it doesn't appear to be working.

Code:


OUTFIL REMOVECC,         
  SECTIONS=(1,28,SKIP=1L)
Back to top
View user's profile Send private message
chillmo

New User


Joined: 31 Aug 2017
Posts: 30
Location: USA

PostPosted: Thu Oct 22, 2020 4:36 am
Reply with quote

Sergeyken,

To be clear, yes I would like the records from F1 and Both in one report, sorted, and with spaces between the rows. This makes it easier to read for the business.

I really appreciate the assistance.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Thu Oct 22, 2020 10:39 am
Reply with quote

Code:
//SYSOUT   DD SYSOUT=*                                             
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                     
  JOINKEYS FILE=F1,FIELDS=(1,26,A),SORTED,NOSEQCK                   
  JOINKEYS FILE=F2,FIELDS=(1,26,A),SORTED,NOSEQCK                   
  JOIN UNPAIRED,F1                                                 
  REFORMAT FIELDS=(F1:1,28,F2:28,26,?)                             
  SORT FIELDS=(1,28,CH,A)                                           
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(56:SEQNUM,8,ZD,RESTART=(1,28)))
  OUTFIL REMOVECC,                                                 
    IFTHEN=(WHEN=(55,1,CH,EQ,C'1'),                                 
      BUILD=(/,1,28)),                                             
    IFTHEN=(WHEN=(55,1,CH,EQ,C'B',AND,56,8,ZD,EQ,+1),               
      BUILD=(/,1,28,X,29,26)),                                     
    IFTHEN=(WHEN=NONE,BUILD=(29X,29,26))                           
  END                                                               
/*


Output:
Code:
********************************* TOP OF DATA **********************
                                                                   
999 C 0000000000AAAAAAAAAA 1 999 D 88888888888888888888             
                             999 D 99999999999999999999             
                             999 D 77777777777777777777             
                             999 D 66666666666666666666             
                                                                   
999 C 0000000000DDDDDDDDDD 1 999 D 11111111111111111115             
                             999 D 22222222222222222225             
                             999 D 33333333333333333335             
                             999 D 44444444444444444445             
                                                                   
999 C 0000000000GGGGGGGGGG 1 999 D 77777777777777777771             
                                                                   
999 C 0000000000HHHHHHHHHH 1                                       
                                                                   
999 C 0000000000IIIIIIIIII 1                                       
                                                                   
999 C 0000000000JJJJJJJJJJ 1                                       
                                                                   
999 C 0000000000KKKKKKKKKK 1                                       
                                                                   
999 C 0000000000LLLLLLLLLL 1                                       
                                                                   
999 C 0000000000MMMMMMMMMM 1                                       
                                                                   
999 C 0000000000NNNNNNNNNN 1                                       
                                                                   
999 C 0000000000OOOOOOOOOO 1                                       
******************************** BOTTOM OF DATA ********************
Back to top
View user's profile Send private message
chillmo

New User


Joined: 31 Aug 2017
Posts: 30
Location: USA

PostPosted: Thu Oct 22, 2020 8:36 pm
Reply with quote

Joerg.Findeisen,

It works perfectly, thanks!

icon_biggrin.gif icon_biggrin.gif icon_biggrin.gif icon_biggrin.gif
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 -> SYNCSORT

 


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 Merge two VSAM KSDS files into third ... JCL & VSAM 6
No new posts Joinkeys - 5 output files DFSORT/ICETOOL 7
No new posts How to append a PS file into multiple... JCL & VSAM 3
Search our Forums:

Back to Top