Left-squeezing and right-squeezing data
<tag> History </tag>
<tag> Psychology </tag>
<tag> Business </tag>
<tag>Biology</tag>
<tag> Science </tag> OPTION COPY
OUTREC FIELDS=(1,40,SQZ=(SHIFT=LEFT))<tag>History</tag>
<tag>Psychology</tag>
<tag>Business</tag>
<tag>Biology</tag>
<tag>Science</tag> OPTION COPY
OUTREC FIELDS=(1,40,SQZ=(SHIFT=RIGHT)) <tag>History</tag>
<tag>Psychology</tag>
<tag>Business</tag>
<tag>Biology</tag>
<tag>Science</tag> OPTION COPY
OUTREC FIELDS=(1,40,SQZ=(SHIFT=LEFT,LEAD=C'<tag1>',
TRAIL=C'</tag1>'))<tag1><tag>History</tag></tag1>
<tag1><tag>Psychology</tag></tag1>
<tag1><tag>Business</tag></tag1>
<tag1><tag>Biology</tag></tag1>
<tag1><tag>Science</tag></tag1> LEAD=string
specifies the leading string as a character or hexadecimal constant
(1 to 50 bytes). TRAIL=string specifies the trailing string as a character
or hexadecimal constant (1 to 50 bytes).Notice that when you left-squeeze, the trailing string is placed directly to the right of the last non-blank character in your data.
OPTION COPY
OUTREC FIELDS=(1,40,SQZ=(SHIFT=RIGHT,LEAD=C'<tag1>',
TRAIL=C'</tag1>')) <tag1><tag>History</tag></tag1>
<tag1><tag>Psychology</tag></tag1>
<tag1><tag>Business</tag></tag1>
<tag1><tag>Biology</tag></tag1>
<tag1><tag>Science</tag></tag1>Notice that when you right-squeeze, the leading string is placed directly to the left of the first non-blank character in your data.
If your leading or trailing string causes the output field to be longer than the input field, you will lose characters. In order to avoid that, you can increase the length of the output field with the LENGTH parameter as discussed previously under Left-justifying and right-justifying data.
<tag> (History) </tag>
<tag> (Psychology) </tag>
<tag> (Business) </tag>
<tag>(Biology)</tag>
<tag> (Science) </tag> OPTION COPY
OUTREC FIELDS=(1,40,SQZ=(SHIFT=LEFT,PREBLANK=C'()'))PREBLANK=list specifies a list of characters you want to replace with blanks before DFSORT starts to squeeze the data. You can specify the list as a character or hexadecimal constant (1 to 10 bytes). Remember that each character in the list is independent of the other characters. For example, PREBLANK=C'*/' replaces each '*' character and '/' character with a blank before squeeze procssing begins (for example, character sequences of /*, //*, */, // and * are all replaced with blanks).
<tag>History</tag>
<tag>Psychology</tag>
<tag>Business</tag>
<tag>Biology</tag>
<tag>Science</tag> OPTION COPY
OUTREC FIELDS=(1,40,SQZ=(SHIFT=RIGHT,PREBLANK=C'()')) <tag>History</tag>
<tag>Psychology</tag>
<tag>Business</tag>
<tag>Biology</tag>
<tag>Science</tag> Manufacturing California +100000
Research Arizona +50000
Marketing Texas +75000 OPTION COPY
OUTREC FIELDS=(1,80,SQZ=(SHIFT=LEFT,MID=C','))Manufacturing,California,+100000
Research,Arizona,+50000
Marketing,Texas,+75000MID=string specifies the string to replace removed blanks or PREBLANK characters as a character or hexadecimal constant (1 to 10 bytes).
If you want DFSORT to "ignore" blanks and PREBLANK characters between pairs of quotes, you can use PAIR=QUOTE with SQZ.
"Computer Science A+" +123
"Ancient Civilization B-" +521
"Sanskrit A-" -263 OPTION COPY
OUTREC FIELDS=(1,80,SQZ=(SHIFT=LEFT,PAIR=QUOTE,
PREBLANK=C'+-',MID=C' '))"Computer Science A+" 123
"Ancient Civilization B-" 521
"Sanskrit A-" 263If you want DFSORT to "ignore" blanks and PREBLANK characters between pairs of apostrophes, you can use PAIR=APOST with SQZ.
'Computer Science A+' +123
'Ancient Civilization B-' +521
'Sanskrit A-' -263 OPTION COPY
OUTREC FIELDS=(1,80,SQZ=(SHIFT=LEFT,PAIR=APOST,
PREBLANK=C'+-',MID=C' '))'Computer Science A+' 123
'Ancient Civilization B-' 521
'Sanskrit A-' 263For complete details on squeeze, see z/OS DFSORT Application Programming Guide.
| So far |
|---|
| Now you know how to use the many features available with the BUILD or FIELDS parameter of the OUTREC statement to reformat your input records in many ways for output. Keep in mind that you can use all of these reformatting features with the BUILD or FIELDS parameter of the INREC statement and with the BUILD or OUTREC parameter of the OUTFIL statement, as well as with the OUTREC statement. In fact, you can use all of these statements together, when appropriate. Next, you will learn how to use the OVERLAY parameter of the OUTREC statement to change one or more fields without affecting the rest of your record. |