I have a requirement wherein I need to match records based on a key value. I know it can be done using JOIN KEYS. But, I kind of have a different requirement this time.
Two PS files that need to be compared are VB. But, First file has a LRECL of 3770 and the second file has a LRECL of 4704.
And, the key in the first file is a packed decimal. Its position is 193 (Including 4 bytes of VB) and its of length 7. Whereas, the same key in the second file is a zoned decimal and it's position is 22 and it is of length 13.
I need to compare these two files based on the keys mentioned above and match the records based on the keys and write it in a new file.
And the output file should also contain a couple of more fields from the first file and the second file.
From first file :
A field of 2 characters in position 14
A field of 7 PD in position 16.
From second file :
A field of 2 characters in position 24
A field of 7 PD in position 26.
Could anyone help me with the SORT jcl for the above requirement?
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
If you look at the sysout from the step, you will see something like 1.4.x.x or 1.3.x.x. It probably also shows the Client company name, which we don't need to see.
A short record is one that is shorter than you are expecting. If you look at your JNF2CNTL you'd be making them if it is being used. You BUILD, so that only the key is on the extract, but then you specify the original position of the data on the JOINKEYS statement.
Often VB files will contain a mix of record-types, even if the other types are only header or trailer records. You may have this anyway.
For testing it is best not to use tape, but to use test data. If you have a file on tape you are allowed to use and extract data from, you can do that. Else create some.
Code:
OPTION COPY
INCLUDE COND=(1,4,BI,LE,199)
If you run that against F1, and a similar one for (different length for F2) you can check for short records anyway.
JNFCNTL statements are supported in Syncsort V1.4.2 version.
Syncsort v1.4.1 supports other Formats like CH, AQ, FI, PD and ZD in JOINKEYS apart from the default BI. The syntax is
JOINKEYS FIELDS=(POSITION,LENGTH,FORMAT,ORDER)
If Format value is omitted, then default format of BI (BINARY) is assumed.
An example JOINKEYS using different formats
Joined: 16 Feb 2015 Posts: 13 Location: Madrid, Spain
I see a mistake. In my opinion both keys must be the same format, or ZF or PD.
Why do you use JNF2 card? This correspond to File2 and this file has the key as ZD.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Rinsio,
Welcome to the forum.
It is not an opinion, but a fact that the keys for JOINKEYS must be of the same type across statements.
At the moment we have to assume that Kunal Surpurkar is getting the key from the correct file. There is a lot which doesn't match to what has been said.