Are you saying that when column 5 = '5' then you want ' Target' appended to the end of that record (or, at least, at column 17)? Also what is the RECFM and LRECL of the dataset?
For an up-to-date DFSORT, you want INREC with IFTHEN=(WHEN=GROUP and KEYBEGIN for your key field, and PUSH a SEQ to a temporary extension of the record. The SEQ= must be long enough to cater for the maximum number of records in a group. SEQ=2 gives 99, SEQ=3 gives 999, you get the picture.
After that, you have IFHTEN=(WHEN=(logical expression to test the extened field to see if it is one. If it is, you OVERLAY your C'TARGET'.
Use IFOUTLEN= for your original record-length, so that the extended data does not get beyond INREC.
NicC wrote:Are you saying that when column 5 = '5' then you want ' Target' appended to the end of that record (or, at least, at column 17)? Also what is the RECFM and LRECL of the dataset?
NicC - Nope. Whenever value at position 12 is KEY1, I would want 'TARGET' populated in position 17. It is also important to note that there are other multiple records for the same value of KEY1 - for those other records, I do not want to overlay TARGET at position 17.
For an up-to-date DFSORT, you want INREC with IFTHEN=(WHEN=GROUP and KEYBEGIN for your key field, and PUSH a SEQ to a temporary extension of the record. The SEQ= must be long enough to cater for the maximum number of records in a group. SEQ=2 gives 99, SEQ=3 gives 999, you get the picture.
After that, you have IFHTEN=(WHEN=(logical expression to test the extened field to see if it is one. If it is, you OVERLAY your C'TARGET'.
Use IFOUTLEN= for your original record-length, so that the extended data does not get beyond INREC.
That's about it.
William - you gave a lot of info here, I was not able to absorb all of it.
Please give me a SORT JCL for the above, I would be in a better position to relate the above description to it.
TIA!
If you run that (untested, you'll have to fix any typos) with the sample data you showed and look at what is produced.
You should then notice that the first record in a group has "01" on it. Brilliant. Now it is an easy task. If that value is "01" use OVERLAY to get "TARGET" where you want.
Read up on IFOUTLEN in the manual. It sets the record-length for when all the IFTHEN processing is finished. If you run the above with IFOUTLEN=15 in INREC, you won't see the SEQ that has been added.
KEY1, KEY2, KEY3..........& so on are just unique identifiers for these records (record set).
so for every KEY1 or KEY2 or KEY3 we have multiple records (having the same Key value = KEY1/2/3). For the 1st occurence of this record, we need to have TARGET at 17th position. All other occurences/records of same KEY need not be overlayed with TARGET. We need to do the same for other KEY2, KEY3..so on
So what you are wanting is: on change of key append 'TARGET' to the first record of the new key. If that understanding is correct then I am beginning to see what William is getting at with his hints.
You mean you haven't already? What was the point of me suggesting anything? You just want to wait for someone to give you the code? Kick back for a long wait. After a few hours waiting, you may as well just try out what I've suggested anyway. Never know, maybe you can do it?
William - Sorry; I didn't mean to offend you, but I was looking for a simpler way (if any).
I did try out what you had suggested, but I could not get the desired results out of that. I basically could not understand (practically) the effect of having a PUSH.
Will get back to you on this, if needed for this issue.
Therefore, as of now I have adopted an altogether different approach :-
I found out that 1st 2 bytes of every record set (having same KEY1) has a definite pattern, so I used this -