|
View previous topic :: View next topic
|
| Author |
Message |
Sebin89
New User
Joined: 14 Dec 2020 Posts: 10 Location: Germany
|
|
|
|
Hi All,
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
eg:
| Code: |
=COLS> ----+----1----+
****** ***************
000001 0000/123
000002 0001/1234
000003 0010/12345
000004 0100/123456
000005 1000/1234567
000006 1100/12345678
000007 1110/123456789
000008 1111/1234567890
|
F2 file: VB with Record length . . . : 32000
| Code: |
=COLS> ----+----1----+----2----+----3----+
****** ***************************** Top o
000001 @(#)@1000/1234567 566 :16R:GENL
000002 @(#)@1100/12345678 566 :16R:GENL
000003 @(#)@1100/12345678 566 :16R:GENL
000004 @(#)@0110/12345 566 :16R:GENL
000005 @(#)@0000/12345678 566 :16R:GENL
000006 @(#)@1010/1234567890 566 :16R:GENL
|
expected output:
F3 VB with Record length . . . : 32000
| Code: |
=COLS> ----+----1----+----2----+----3----+
****** ***************************** Top o
000001 @(#)@1000/1234567 566 :16R:GENL
000002 @(#)@1100/12345678 566 :16R:GENL
000003 @(#)@1100/12345678 566 :16R:GENL
|
F4 VB with Record length . . . : 32000
| Code: |
=COLS> ----+----1----+----2----+----3----+
****** ***************************** Top o
000001 @(#)@0110/12345 566 :16R:GENL
000002 @(#)@0000/12345678 566 :16R:GENL
000003 @(#)@1010/1234567890 566 :16R:GENL
|
|
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2290 Location: USA
|
|
|
|
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 |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
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. |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
| Sebin89, Please don’t create multiple topics for the same problem, I deleted the other one and reply to this topic with what you tried , the JCL. |
|
| Back to top |
|
 |
Sebin89
New User
Joined: 14 Dec 2020 Posts: 10 Location: Germany
|
|
|
|
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:
| Code: |
----+----1----+
***************
0000/123
0001/1234
0010/12345
0100/123456
1000/1234567
1100/12345678
1110/123456789
1111/1234567890
|
- 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
|
JCL used:
| Code: |
//STEP1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//VBIN DD DSN=P104219.MT566.FULL.RECORDS.ADD.SORTOUT,DISP=SHR
//FBIN DD DSN=P104219.FOMT566.TLWL.T3011.FINAL,DISP=SHR
//F1MT DD DSN=P104219.MT566.FULL.RECORDS.MATCH,
// DISP=(,CATLG,DELETE),SPACE=(CYL,(5,5),RLSE),
// LRECL=32000,RECFM=VB
//F2NM DD DSN=P104219.MT566.FULL.RECORDS.NONMATCH,
// DISP=(,CATLG,DELETE),SPACE=(CYL,(5,5),RLSE),
// LRECL=32000,RECFM=VB
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(5,20,A),SORTED
JOINKEYS FILE=F2,FIELDS=(1,15,A),SORTED
JOIN UNPAIRED,F1,F2
REFORMAT FIELDS=(F1:19)
OPTION COPY
OUTFIL FNAMES=F1MT,BUILD=(19,32000)
OUTFIL FNAMES=F2NM,BUILD=(19,32000)
/*
|
|
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1448 Location: Bamberg, Germany
|
|
|
|
| The first solution is NOT complex. The Job is about 30 lines. |
|
| Back to top |
|
 |
Sebin89
New User
Joined: 14 Dec 2020 Posts: 10 Location: Germany
|
|
|
|
| could you please share the JCL? |
|
| Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
| You want the JCL but not the sort control statements (which are NOT JCL)??? |
|
| Back to top |
|
 |
Sebin89
New User
Joined: 14 Dec 2020 Posts: 10 Location: Germany
|
|
|
|
| I am fine with anything. sort control or JCL |
|
| Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
Ok - here is some JCL
| Code: |
//STEP1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//VBIN DD DSN=P104219.MT566.FULL.RECORDS.ADD.SORTOUT,DISP=SHR
//FBIN DD DSN=P104219.FOMT566.TLWL.T3011.FINAL,DISP=SHR
//F1MT DD DSN=P104219.MT566.FULL.RECORDS.MATCH,
// DISP=(,CATLG,DELETE),SPACE=(CYL,(5,5),RLSE),
// LRECL=32000,RECFM=VB
//F2NM DD DSN=P104219.MT566.FULL.RECORDS.NONMATCH,
// DISP=(,CATLG,DELETE),SPACE=(CYL,(5,5),RLSE),
// LRECL=32000,RECFM=VB
//SYSIN DD *
your sort control cards go here
/*
|
|
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1448 Location: Bamberg, Germany
|
|
|
|
Use PARM='MSG=AP' after EXEC PGM=SORT to get all the Messages. Should be known.
Your code uses different key lengths, why? Also the records in F1 are NOT sorted
| Code: |
JOINKEYS FILE=F1,FIELDS=(5,20,A),SORTED
JOINKEYS FILE=F2,FIELDS=(1,15,A),SORTED |
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.
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.
| Code: |
OUTFIL FNAMES=F1MT,BUILD=(19,32000)
OUTFIL FNAMES=F2NM,BUILD=(19,32000) |
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. |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2290 Location: USA
|
|
|
|
The suggested
JOINKEYS FILE=F1/F2
does not correspond to the JCL code presented in all examples here.
Definitely will not work, causing the TS to ask for help again (and again, and again, and again...)
The right parameter FNAMES= is shown at the very end; need to attract the TS attention to this “extremely complicated issue”. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|