File 1 contains a field at 99th position which is 16 bytes alphanumeric. When this field is equal to first 16 bytes of File 2 then two fields in File 1 (at position 18th and 71st) both of which are 6 bytes long should be replaced with 6-Bytes field in File 1 (6 bytes from position 18th). For this to happen I wrote the following JCL which is working fine.
However, there is a sub record too associated with the main record in which there is a field at 34th byte that also needs to be updated with the
same field from File 1 (6 bytes from position 18th) when a match is found. The 16 bytes key field is only appearing in the main record and not in the sub record.
This sub record is recognized with values '04' at position 3. The main record is recognized with values '01' at position 3. This is explained as shown below:
First record starting with DT01 - First occurrence of 155901 is at 18th position and second is at 71st position which was updated from File 2. And my above JCL is correctly updating this.
For the sub record I need help to update 6 bytes starting from 34th position when 16 bytes at pos 99th in the main record of File 1 match with the first 16 bytes in File 2.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Why do you have JOIN UNPAIRED,F1?
You only want matches, so don't specify a JOIN.
You then don't need the ? or the test for its value being C'B'.
Put your main file on as F1, and in JNF1CNTL temporarily extend the records so that a new field, populated by IFTHEN=(WHEN=GROUP for your data header) contains the key (PUSH=(251:keystart,length).
In JNF2CNTL, cut down the record so it only contains what is needed.
If either of the files is already in key order, specify SORTED for it on the JOINKEYS.
In the Main Task, you will get two matches, one for the main record and one for the sub-record. Identify those by type and put data from F2 into the correct position.
The output file will have both matched as well as unmatched records. however, the change that I have mentioned will be applicable only for the matched ones and hence the unmatched ones will remain as is.
BTW I have got the thing working with the below two steps:
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
I'm glad you have something working, but I think there are some confusions.
Firstly, you use SS for a field-type where CH would do. Look up SS in the manual, and samples of its use. Understand it. Change these SSs to CHs.
Next, your separate step can be coded in JNF1CNTL instead. Saving a step. It is fine to save a step when not needed.
The positions you have chosen for your extra fields are fine for developing the solution (makes it easier to see what is where) but for your final version you probably are better with the fields being contiguous.
You could use JNF2CNTL to cut down the F2 to only the data needed (key + value). This will use fewer resources, especially if you need to sort the field (which JOINKEYS does by default).
Are the files in order already?
The use of IFOUTLEN is to set your final record-length from a particular process. There should be no need to then have a BUILD in a following process just to change the length. Set IFOUTLEN=250 and drop the OUTREC altogether.