I have a requirement to match a value from F1 with F2 and if that value is found in F2 then write the complete record into F3 and if not found it in F2 then write into F4.
- The match value can be repeated in the file F2; So all the matched records should written into F3.
- match value start from POS 06 in F2
- match value start from POS 01 till 15 in F1
F1 file: FB with Record length . . . : 15
the record 1 - 4 is always have values
5 - is a separator '/'
6 - 15 may have values
1. Read any manual on SORT utility regarding JOIN feature
2. Try to test something using examples from the manual
3. Post your results at this forum.
4. In case of a problem people would help you, but not do your job instead of yourself
Welcome!!
You also need to Parse the keys into fixed format using INREC in //JNF2CNTL DD * and then refer that in the join task.
Example 5 - Paired and unpaired F1/F2 records
You can also search this forum and you will find many similar topics and solution posted which will help you. Try it and let us know what's not working.
As the above solution will be bit complex. I have changed the question in this way.
---------------------------------------------------------
I am using below SORT step to join records from 2 files. But it is not giving me the expected results. Can you please help with the correct SYSIN statement?
- Input file1 has RECFM=VB and LRECL=32000. It contains the following records:
Code:
----+----1----+----2----+----3----+----4----+----5
***************************** Top of Data ********
1000/1234567 @(#)@1000/1234567 566 :16R:GENL
1100/12345678 @(#)@1100/12345678 566 :16R:GENL
1100/12345678 @(#)@1100/12345678 566 :16R:GENL
0110/12345 @(#)@0110/12345 566 :16R:GENL
0000/12345678 @(#)@0000/12345678 566 :16R:GENL
1010/1234567890@(#)@1010/1234567890 566 :16R:GENL
- Input file2 has RECFM=FB and LRECL=15. It contains the following records:
- Expected output in first file (RECFM=VB and LRECL=32000):
Code:
----+----1----+----2----+----3----+----4----+----5
***************************** Top of Data ********
@(#)@1000/1234567 566 :16R:GENL
@(#)@1100/12345678 566 :16R:GENL
@(#)@1100/12345678 566 :16R:GENL
- Expected output in second file (RECFM=VB and LRECL=32000):
Code:
----+----1----+----2----+----3----+----4----+----5
***************************** Top of Data ********
@(#)@0110/12345 566 :16R:GENL
@(#)@0000/12345678 566 :16R:GENL
@(#)@1010/1234567890 566 :16R:GENL
You only want missing entries from F1, F2 is not needed here.
Code:
JOIN UNPAIRED,F1,F2
Read when the other things are fixed what messages you will get. F1:19 will likely not going to work. Also when wanting to separate the data you need an Id to do so. Read about the '?' operator.
Code:
REFORMAT FIELDS=(F1:19)
Consider a SORT statement to keep the original sequence of F1 after the Join.
Code:
OPTION COPY
For both OUTFIL the ident is missing (look up the '?' operator). Also start positions seem to be off. That will not be the last hurdle I guess.
As Rohit has said when your F1 (in the first sample provided) has some floating keys, you must parse F1 before the JOINKEYS and provide them as fixed length at the same position.