I've got a dataset with a key and 1 to n lines of text, and it looks something like this:
KEY2 Text (ends with X'0D')
KEY3 Text (ends with X'0D')
Text (ends with X'0D')
The Text will vary in length, to a maximum of 80 chars per line. I want to merge all lines of text into one record per key, removing trailing spaces and the X'0D' indicator in the process. Can I do this with SORT?
All keys has at least one record, showing the key value (of 20 chars) and the first 80 chars of the text. If the text is longer than 80 chars, the last char is X'0D', and the text continues in the next record, but WITHOUT the key value. Only if the text continues in the next record does it have the X'0D' indicator.
The output will be VB 424 (as a max. of 5 textlines of 80 chars can be found).
I still need you to clarify some things about the structure of the various records.
No continuation. so it has the 4-byte RDW, a 20 byte key, and 80 characters of text, or can it be less than 80 characters of text? In other words, would this type of record always be 104 bytes (4+20+80) or could it be less than 104 bytes (e.g. 4+20+50)?
KEY2 text2 (ends with X'0D')
Continuation, so the first line has the 4-byte RDW, a 20 byte key, 80 characters of text and a X'0D'? That would be 105 bytes so the LRECL would have to be VB 105? Or would it only have 79 characters of text followed by the X'0D' to get VB 104? Would this type of line always have the X'0D' in position 105 (or 104?) or could it have less than 80 characters with the X'0D' earlier on, e.g. 4-byte RDW, a 20 byte key, 50 characters of text and a X'0D'?
Would the second line always be padded out to 80 characters (4-byte RDW + 80 bytes), or could it have less than 80 characters (e.g. 4-byte RDW + 50 bytes)?
You don't actually want a space between the key and each text segment - right?
Finally, is the key identifiable in some way (e.g. it starts with 'KEY')? If not, how do we know when we have the start of a line of text? Is it just that the previous line did not end with X'0D'?
Here's a DFSORT/ICETOOL job that will do what you asked for. You'll need z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006) in order to use DFSORT's PARSE function. If you don't have the April, 2006 PTF, ask your System Programmer to install it (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTF, see:
Look at the Sort manual, there is a parameter that handles that.
If the variable-length record was too short to contain all SORT, MERGE, or SUM fields, use the VLSHRT option to prevent DFSORT from terminating.
If a variable-length record was too short to contain all INCLUDE or OMIT fields, use the VLSCMP or VLSHRT option to prevent DFSORT from terminating.