View previous topic :: View next topic
|
Author |
Message |
nynali
New User
Joined: 08 May 2007 Posts: 13 Location: Hyderabad
|
|
|
|
Hi,
I have two files FILE1(key 1 to 6 bytes 9(6) field, LRECL=150) and FILE2 (key 1 to 4 bytes S9(6) Comp-3, LRECL=230).
Now I want write out all the records from FILE2 only if the key field gets a match from FILE1. Please let me know how I can achieve this.
Thanks in Advance !!! |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
nynali,
You can do this using any of the sort products(DFSORT or SYNCSORT) if you have any of them installed and the solution differs based on which one you have.
Can you post the sort product info?. Also do you expect duplicate keys in FILE1(or FILE2)? |
|
Back to top |
|
|
nynali
New User
Joined: 08 May 2007 Posts: 13 Location: Hyderabad
|
|
|
|
Arun,
We use SYNCSORT.
FILE2 might have duplicates. FILE1 doesn't have any duplicates |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Hello,
If you have Syncsort for z/OS 1.2 or later you can use Syncsort's JOIN functionality to do this. But before doing that you should make sure that the keys are in the same format. The below Syncsort job does what you asked for.
Code: |
//STEP1 EXEC PGM=SORT
//SORTIN DD DSN= Input file1 ------> FB, LRECL=150
//SYSOUT DD SYSOUT=*
//SORTOUT DD DSN=&&TEMP,DISP=(,PASS)
//SYSIN DD *
INREC BUILD=(1,6,ZD,TO=PD,LENGTH=4)
SORT FIELDS=COPY
//*
//STEP2 EXEC PGM=SORT
//SORTJNF1 DD DSN=&&TEMP1,DISP=(OLD,PASS)
//SORTJNF2 DD DSN= Input file2 ------> FB, LRECL=230
//SORTOUT DD DSN= Output file ------> FB, LRECL=230
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(1,4,A)
JOINKEYS FILE=F2,FIELDS=(1,4,A)
REFORMAT FIELDS=(F2:1,230)
SORT FIELDS=COPY
//* |
|
|
Back to top |
|
|
|