Previous topic |
Next topic |
Contents |
Contact z/OS |
Library |
PDF
Left-justifying and right-justifying data z/OS DFSORT: Getting Started SC23-6880-00 |
|
Suppose you had input records that looked like this:
Since this is rather messy looking, you can use the following statements
to left-justify the data to make it more presentable:
SHIFT=LEFT indicates that you want to left-justify. The results
produced for this OUTREC statement are:
Alternatively, you can use the following statements to right-justify
the data:
SHIFT=RIGHT indicates that you want to right-justify. The results
produced for this OUTREC statement are:
DFSORT's justify 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-justified data with '<'
and '>':
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-justify, the trailing string is placed directly to the right of the last non-blank character in your data. If you want to right-justify instead of left-justify, you can use
the following statements:
The results produced for this OUTREC statement are:
Notice that when you right-justify, 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. For example, suppose you had input records that
looked like this:
and you added a leading string with these control statements:
Since your input field is 7 bytes, your output field is also 7
bytes by default, so your output fields are truncated to:
To avoid truncation, you can use LENGTH=16 to increase the output
field length by the 9 characters you added for the leading and trailing
strings:
The larger output field can accommodate your leading and trailing
strings so you can show your appreciation for these wonderful creatures
with the following output:
The justify feature can also be used to remove leading and trailing
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 leading '('
character and the trailing ')' character before you left-justify the
data:
PREBLANK=list
specifies a list of characters you want to replace with blanks before
DFSORT starts to justify 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 leading or trailing '*' character
and '/' character with a blank before justify procssing begins (for
example, leading and trailing 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-justify the data
and replace the leading '(' character and trailing ')' character with
a leading '<' character and a trailing '>' character:
The results produced for this OUTREC statement are:
For complete details on justify, see z/OS DFSORT Application Programming Guide. |
Copyright IBM Corporation 1990, 2014
|