Previous topic |
Next topic |
Contents |
Contact z/OS |
Library |
PDF
Left-squeezing and right-squeezing data z/OS DFSORT: Getting Started SC23-6880-00 |
|||
Suppose you had input records that looked like this
If you want to remove the white space (blanks), you can use the
following statements to left-squeeze the data:
SHIFT=LEFT indicates that you want to left-squeeze by removing
all of the blanks, shifting the remaining characters to the left and
padding on the right with blanks if needed. The results produced for
this OUTREC statement are:
Alternatively, you can use the following statements to right-squeeze
the data:
SHIFT=RIGHT indicates that you want to right-squeeze by removing
all of the blanks, shifting the remaining characters to the right
and padding on the left with blanks if needed. The results produced
for this OUTREC statement are:
DFSORT's squeeze feature also lets you add a leading string, a
trailing string, or both, to the data. For example, you can use the
following statements to surround the left-squeezed data with '<tag1>'
and '</tag1>':
The results produced for this OUTREC statement are:
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. If you want to right-squeeze instead of left-squeeze, you can use
the following statements:
The results produced for this OUTREC statement are:
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. The squeeze feature can also be used to remove characters other
than blanks from your data. Suppose you had input records that looked
like this:
You can use the following statements to remove the '(' and ')'
characters before you left-squeeze the data:
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). The results produced for this OUTREC statement are:
You could use the following statements to right-squeeze the data
and remove the '(' character and ')' character:
The results produced for this OUTREC statement are:
The squeeze feature can be used to replace groups of blanks between
the first nonblank and last nonblank with other characters. Suppose
you had input records that looked like this:
You could use the following statements to create comma separated
variable records:
The results produced for this OUTREC statement are:
MID=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. Suppose you had input records that looked like this:
You could use the following statements to "protect" the blanks,
+ and - signs inside the paired quotes while removing them outside
the paired quotes, and leave only one blank between the two squeezed
fields:
The results produced for this OUTREC statement are:
If you want DFSORT to "ignore" blanks and PREBLANK characters between pairs of apostrophes, you can use PAIR=APOST with SQZ. Suppose you had input records that looked like this:
You could use the following statements to "protect" the blanks,
+ and - signs inside the paired apostrophes while removing them outside
the paired apostrophes, and leave only one blank between the two squeezed
fields:
The results produced for this OUTREC statement are:
For complete details on squeeze, see z/OS DFSORT Application Programming Guide.
|
Copyright IBM Corporation 1990, 2014
|