View previous topic :: View next topic
|
Author |
Message |
Niki
Active User
Joined: 20 Sep 2008 Posts: 106 Location: Bangalore
|
|
|
|
Hi All,
could someone please help me in solving this issue.
I need to compare two files and generate the report
1) File 1 is a VB file of lrecl 3504. The key is a PD field starts from position 10 to 19.
2) File 2 is a FB fie of LRECL 100. The key is a numeric and starts from position 20 to 35.
There should be 4 output,
1) Records should be pulled from file 1 where the key matches.
2) Records should be pulled from file-1 where the key is not matched.
3) Records should be pulled from file-2, where key matches.
4) Records should be pulled from file 2 where key doesnot match. |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Quote: |
1) File 1 is a VB file of lrecl 3504. The key is a PD field starts from position 10 to 19.
2) File 2 is a FB fie of LRECL 100. The key is a numeric and starts from position 20 to 35. |
Are you sure the provided key is correct? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Pandora, one PD one "numeric" (ZD).
Niki, how many output files is that, one, four, or something else? |
|
Back to top |
|
|
Niki
Active User
Joined: 20 Sep 2008 Posts: 106 Location: Bangalore
|
|
|
|
The first file is of PD type and the position is 10 to 18 bytes. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
And the answer to the next question is....? |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Niki,
Joinkeys comparison keys will be treated as binary, so they must be "normalized". For example, if the keys are actually zoned decimal, they must have all C and D signs, or all F and D signs. You can use an INREC statement in JNF1CNTL and/or JNF2CNTL to normalize the keys for the F1 file and/or F2 file, respectively, if appropriate.
So in your case you need to "normalize" the PD key to ZD key or convert the ZD key to PD using JNF1CNTL or JNF2CNTL.
Look at the smart DFSORT trick "Create files with matching and non-matching records" here
www-01.ibm.com/support/docview.wss?rs=114&uid=isg3T7000094
Give it a shot and get back to us if you have a problem. |
|
Back to top |
|
|
Niki
Active User
Joined: 20 Sep 2008 Posts: 106 Location: Bangalore
|
|
|
|
Thanks Skolusu. I will have a look into the sort trick documents.
Bill,
There should be 4 output files.
1) Records should be pulled from file 1 where the key matches.
2) Records should be pulled from file-1 where the key is not matched.
3) Records should be pulled from file-2, where key matches.
4) Records should be pulled from file 2 where key doesnot match. |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Niki,
Is there something you have tried ? |
|
Back to top |
|
|
Niki
Active User
Joined: 20 Sep 2008 Posts: 106 Location: Bangalore
|
|
|
|
Pandora,
In sort I tried to use the join functionality, by using splice operators but as the keys we are planning to compare are of different format always the job used to fail.
Finally I tried to achieve the same result by using the DYL code instead of Sort.
But the experience I have from this forum. I know one thing is that any file operation can be handled through SORT if there is some logic of operation.
Thanks again for helping me in all these days. |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Niki wrote: |
In sort I tried to use the join functionality, by using splice operators but as the keys we are planning to compare are of different format always the job used to fail. |
Why are you using SPLICE? We have shown enough examples for you about using JOINKEYS. Can't you take them as examples and build your JCL?
Niki wrote: |
But the experience I have from this forum. I know one thing is that any file operation can be handled through SORT if there is some logic of operation. Thanks again for helping me in all these days. |
You need to understand the examples shown here and try to apply the same logic to your other jobs. The request is you have is fairly simple request and can be done very easily. The actual Sort control cards are just 11 lines. Anyway it is a moot point since you already have written a program. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Niki,
You have an FB and a VB. You need to arrange the keys such that they are both the same format. So, easiest/fewest resources is to OVERLAY the "numeric" key at position 101 to a PD of the correct length. This is done in JNFnCNTL, where "n" is the "number of the file".
Do the JOINKEYS with the original PD key and the new PD key.
Specify that you require matched and unmatched records (from both files).
The thing to watch on the REFORMAT statement is to both make the REFORMAT record variable and put the "variable part" of the VB as the last thing on the REFORMAT definition.
Use 4 X OUTFIL with INCLUDE/OMIT for the "matching values" of the ? from the REFORMAT statement. Use BUILD on each to get the correct and appropriate data for that output file.
If we keep just providing code to you, you'll keep coming back, without, it seems, the inclination to learn how to do anything new.
So, have a go. If you get stuck, there'll be someone here. |
|
Back to top |
|
|
|