View previous topic :: View next topic
|
Author |
Message |
varma096
New User
Joined: 20 Apr 2024 Posts: 6 Location: Hyderabad
|
|
|
|
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 |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2139 Location: USA
|
|
|
|
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 |
|
|
varma096
New User
Joined: 20 Apr 2024 Posts: 6 Location: Hyderabad
|
|
|
|
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 |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1333 Location: Bamberg, Germany
|
|
|
|
What have you tried yourself?
Please provide sample outputs, and usable sample inputs for F1 and F2. |
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1333 Location: Bamberg, Germany
|
|
|
|
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 |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2139 Location: USA
|
|
|
|
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.
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 |
|
|
varma096
New User
Joined: 20 Apr 2024 Posts: 6 Location: Hyderabad
|
|
|
|
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 |
|
|
varma096
New User
Joined: 20 Apr 2024 Posts: 6 Location: Hyderabad
|
|
|
|
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 |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1333 Location: Bamberg, Germany
|
|
|
|
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 |
|
Back to top |
|
|
|