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

Compare 2 files and write Matched/Unmatched records


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
varma096

New User


Joined: 20 Apr 2024
Posts: 6
Location: Hyderabad

PostPosted: Mon Apr 22, 2024 10:39 pm
Reply with quote

Hello Team,

I have 2 files of LRECL 133. File 1 has key from position 1 to position 8 and File 2 has key from position 22 to position 29. I need a JCL Sort condition when the key from file 1 matches key on file 2, write the complete record of the key match from file 2 to Matched record data set(Output 1) and when the key from File 1 doesn't have a match a key on file 2, write those records into output 2.

NOTE: File 1 has unique key records and File 2 has multiple records and Multiple keys.

Example:
File 1 Record Layout: Please find attachment for clear File 1 layout
----+----1----+----2----+----3----+----4----+--
12345678XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
23456789XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
34567891XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

File 2 Record Layout: Please find attachment for clear File 2 layout
----+----1----+----2----+----3----+----4----+----
XXXX-XXXX-XXXXXXXX 12345678 XXXXX XXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXX
XXXXXXXXXXXXX
XXXXXXXXXXXXX
XXXXXXXXXXXXX
XXXXXXXXX XXXXXXXXXXXXX
XXXXXX XXXXXXXX XXXXXXXXXXXXX

XXXX-XXXX-XXXXXXXX 12345678 XXXXXXXX

XXXXXXXXXXXXX
XXXX-XXXX-XXXXXXXX 23456789 XXXXXXXX

XXXX-XXXX-XXXXXXXX 23456789 XXXXXXXX XXXXXXXX XXXXXXXXXXXXX
XXXXXXXXXXXXX
XXXXXXXXXXXXX
XXXXXXXXXXXXX
XXXXXXXXXXXXX

When Key from File 1 matches key on File 2(even in multiple cases) write the complete record of file 2 into output 1
Example from above layout:
Key 12345678 from file 1 matches 2 times in file 2 with different record count like first occurrence in file 2 with key 12345678 has 8 records(including the Key record), I want all the 8 records into output 1(Matched records). Second occurrence with same key: 12345678 has 3 records which i want to put them in output 1(matched records) as well.

Similarly keys which don't match should be moved to output 2(Unmatched records) need all the records under that key.

Can someone help me with this logic. Thank you in advance!
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2051
Location: USA

PostPosted: Tue Apr 23, 2024 12:07 am
Reply with quote

1. Do not use attachments in your posting.

2. Use Code button to emphasize your code and data samples.

3. Use Search option to find hundreds of ready-to-use answers and examples. Use search both on this forum, and/or in Goggle search.
Back to top
View user's profile Send private message
varma096

New User


Joined: 20 Apr 2024
Posts: 6
Location: Hyderabad

PostPosted: Tue Apr 23, 2024 12:12 am
Reply with quote

Hi Sergeyken, Yeah Sure on the attachments information. Logical part, I tried but was unable to incorporate the logic exactly as needed. Please help me if you can.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Tue Apr 23, 2024 12:39 am
Reply with quote

What have you tried yourself?

Please provide sample outputs, and usable sample inputs for F1 and F2.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Tue Apr 23, 2024 1:19 pm
Reply with quote

Basically you need to identify the GROUPs before the JOIN. Once done, JOIN by the key, and REFORMAT the record as needed (including the join indicator).
Process further with INCLUDE/OMIT using the indicator. The required code is less than twenty lines.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2051
Location: USA

PostPosted: Tue Apr 23, 2024 5:20 pm
Reply with quote

varma096 wrote:
Hi Sergeyken, Yeah Sure on the attachments information. Logical part, I tried but was unable to incorporate the logic exactly as needed. Please help me if you can.


Yes, I can. icon_rolleyes.gif
But I don't want to do the full job for lazy newbies.

WHAT EXACTLY did you try?

Where is ANY EXAMPLE of your own efforts?
Back to top
View user's profile Send private message
varma096

New User


Joined: 20 Apr 2024
Posts: 6
Location: Hyderabad

PostPosted: Tue Apr 23, 2024 9:05 pm
Reply with quote

Hi Sergeyken,

Here is the code which i tried.
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(134:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(22,2,CH,EQ,C'23'),
OVERLAY=(134:+1,ADD,134,8,ZD,M11,LENGTH=8))

OUTFIL FNAMES=OUTFIL1,BUILD=(1,133)

I was not able to copy all the records for particular key. I am able to copy only 2 rows of each key.
Back to top
View user's profile Send private message
varma096

New User


Joined: 20 Apr 2024
Posts: 6
Location: Hyderabad

PostPosted: Tue Apr 23, 2024 9:15 pm
Reply with quote

Hi Findeisen,

Yeah got what you said, but unable to understand how to create the instruction logic for the same.

Need you guidance if you can explain it to me in details if you have sometime.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Tue Apr 23, 2024 9:55 pm
Reply with quote

Seems you are using ICETOOL, right? To "tag" a group you need to identify it first. Use IFTHEN=(WHEN=GROUP,BEGIN=(<where_does_it_start>),PUSH=(134:<items_needed_(this_is_the_identifier)>))
Next, look up JOINKEYS/JOIN in the manual how to use the prepared Groups with your Keys.

Also you were told to use code tags when presenting code or data to the forum icon_exclaim.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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts To fetch records that has Ttamp value... DFSORT/ICETOOL 4
No new posts ICETOOL returns no records JCL & VSAM 1
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
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
Search our Forums:

Back to Top