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

Compare only first records of the files using SYNCSORT


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

New User


Joined: 25 Mar 2007
Posts: 7
Location: Canada

PostPosted: Fri Jan 19, 2024 10:27 pm
Reply with quote

Compare File1 header (position (7,6)) with File2 1st Record only (position (31,6)). If matching Max-RC should be 0, else throw Max-RC 16.
If return code is 0 then File2 will be merged with File1 in the next step.

Sample layout:
LRECL=95 for Both files

File1: With Header
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
XXXXXX2024011620240131
AB387CDE **0001 9999 XY3849 Z 20240116170020240116230020240116170020240116170020
AB387CDE ND0001 9999 XY3849 Z 20240116170020240116230020240116170020240116170020
AB387CDE ZP0001 9999 XY3849 Z 20240116170020240116230020240116170020240116170020

File2 : Without header
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
DE387CDE **0001 9999 WV3849 Z 20240116170020240116230020240116170020240116170020
DE387CDE WG0001 9999 WV3849 Z 20240116170020240116230020240116170020240116170020
DE387CDE DJ0001 9999 WV3849 Z 20240116170020240116230020240116170020240116170020
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2141
Location: USA

PostPosted: Sat Jan 20, 2024 2:00 am
Reply with quote

What did you try so far?
Back to top
View user's profile Send private message
pavanbolla

New User


Joined: 25 Mar 2007
Posts: 7
Location: Canada

PostPosted: Sat Jan 20, 2024 2:15 am
Reply with quote

I tried by keeping single record in each file. No idea with multiple records.

//STEP01 EXEC PGM=SORT
//SORTJNF1 DD DSN=File1,DISP=SHR
//SORTJNF2 DD DSN=FILE2,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY,NULLOUT=RC16
JOINKEYS FILE=F1,FIELDS=(7,6,A)
JOINKEYS FILE=F2,FIELDS=(31,6,A)
REFORMAT FIELDS=(F1:7,6,F2:31,6)
/*
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2141
Location: USA

PostPosted: Sun Jan 21, 2024 2:00 am
Reply with quote

1. Learn to use Code button when presenting your code, and/or data:

pavanbolla wrote:
I tried by keeping single record in each file. No idea with multiple records.

Code:
//STEP01    EXEC PGM=SORT
//SORTJNF1 DD DSN=FILE1,DISP=SHR
//SORTJNF2 DD DSN=FILE2,DISP=SHR
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
   OPTION COPY,NULLOUT=RC16
   JOINKEYS FILE=F1,FIELDS=(7,6,A)
   JOINKEYS FILE=F2,FIELDS=(31,6,A)
   REFORMAT FIELDS=(F1:7,6,F2:31,6)
/*


2. Stop your habits to assign stupid names to ANY OBJECT OF YOUR CODE, like STEP01, etc!!!
Also, instead of obsolete FILE=F1 try to use the format F1=meaningful_DD_name

3. Try to learn about //SYMNAMES option of SORT utility, to assign meaningful names to all used fields, instead of their absolute positions, and offsets.

4. Search and learn about extra processing statements //JFN1CNTL, and //JFN2CNTL, to pre-handle each of F1/F2 DD data before they are joined.

5. Likely, you need to (temporary) renumber each record of both F1/F2, and then use INCLUDE parameter in each of your JOINKEYS statement.

Please, try it yourself, before asking to provide you with the ready-to-use code.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3076
Location: NYC,USA

PostPosted: Sun Jan 21, 2024 4:03 pm
Reply with quote

Please use code tags ..
This has been discussed several times on this forum and simple search would get you to wha you want..
Try
ibmmainframes.com/about58174.html
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Tue Jan 23, 2024 12:37 am
Reply with quote

The provided attempt was not that bad, omitting the JOIN statement. It just missed the STOPAFT part.

Code:
//WHATEVER EXEC PGM=SORT                                 
//F1       DD *                                                         
XXXXXX2024011620240131                                                   
AB387CDE **0001 9999 XY3849 Z 202401161700202401162300202401161700202401
AB387CDE ND0001 9999 XY3849 Z 202401161700202401162300202401161700202401
/*                                                                       
//F2       DD *                                                         
DE387CDE **0001 9999 WV3849 Z 202401161700202401162300202401161700202401
DE387CDE WG0001 9999 WV3849 Z 202401161700202401162300202401161700202401
DE387CDE DJ0001 9999 WV3849 Z 202401161700202401162300202401161700202401
/*                                                                       
//SYSOUT   DD SYSOUT=*                                                   
//SORTOUT  DD DUMMY SYSOUT=*                                             
//SYSIN    DD *                                                         
  OPTION COPY,NULLOUT=RC16                                               
  DEBUG NOABEND                                                         
  JOINKEYS F1=F1,FIELDS=(7,6,A),SORTED,NOSEQCK                           
  JOINKEYS F2=F2,FIELDS=(31,6,A),SORTED,NOSEQCK                         
  REFORMAT FIELDS=(F1:7,6,F2:31,6)                                       
  END                                                                   
/*                                                                       
//JNF1CNTL DD *                                                         
  OPTION STOPAFT=1                                                       
/*                                                                       
//JNF2CNTL DD *                                                         
  OPTION STOPAFT=1                                                       
/*
Back to top
View user's profile Send private message
pavanbolla

New User


Joined: 25 Mar 2007
Posts: 7
Location: Canada

PostPosted: Tue Jan 23, 2024 5:27 am
Reply with quote

Thanks Joerg, the code worked after adding STOPAFT.

Code:
//SYSIN    DD *
   OPTION COPY,NULLOUT=RC4
   JOINKEYS FILE=F1,STOPAFT=1,FIELDS=(7,6,A)
   JOINKEYS FILE=F2,STOPAFT=1,FIELDS=(31,6,A)
   REFORMAT FIELDS=(F1:7,6,F2:31,6)         
/*
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Tue Jan 23, 2024 11:51 am
Reply with quote

I was not aware one can add that keyword to the JOINKEYS statement as well. Thanks for the update.
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 3 files concatenated to 1 DFSORT/ICETOOL 2
No new posts Syncsort help SYNCSORT 3
No new posts JCL sort to compare dates in two file... DFSORT/ICETOOL 2
No new posts combine multiple unique records into ... DFSORT/ICETOOL 2
No new posts SYNCSORT-DB2 interface SYNCSORT 0
Search our Forums:

Back to Top