SORT – JUSTIFY, SQUEEZE and OVERLAY
-
JUSTIFY
Using SORT, you can justify your input records.
Suppose you have your input file as below:
(RAJESH/
RAMS/
SUNIL/
SURESH)
And you want your output file in this format
<RAJESH>
<RAMS>
<SUNIL>
<SURESH>
Your SORT card would look like below:
OPTION COPY
OUTREC FIELDS=(1,20,JFY=(SHIFT=LEFT,PREBLANK=C'()/’,
LEAD=C'<‘,TRAIL=C’>’))
JFY | is used to justify the input record |
SHIFT=LEFT | tells that records needs to be shifted to left (SHIFT=RIGHT for right shift) |
PREBLANK=C'()/’ | tells that the characters ‘(‘, ‘)’ and ‘/’ need to be replaced by blank. |
LEAD=C'<‘ | tells that all records should be appended with ‘<‘ at start |
TRAIL=C’>’ | tells that all records should be appended with ‘>’ at end |
-
SQUEEZE
Using SORT, you can SQUEEZE your input records. That is you can remove unwanted spaces in between in a record.
Suppose you have your input file as below:
A (RAJESH/ A
B RAMS/ B
C SUNIL/ C
D SURESH) D
“E CHIRU ” E
And you want your output file in this format
{A.RAJESH.A}
{B.RAMS.B}
{C.SUNIL.C}
{D.SURESH.D}
Your SORT card would look like below:
OPTION COPY
OUTREC FIELDS=(1,20,SQZ=(SHIFT=LEFT,PREBLANK=C'()/’,MID=C’.’,
LEAD=C'{‘,TRAIL=C’}’))
SQZ | is used to squeeze the input record |
SHIFT=LEFT | tells that records needs to be shifted to left (SHIFT=RIGHT for right shift) |
PREBLANK=C'()/’ | tells that the characters ‘(‘, ‘)’ and ‘/’ need to be replaced by blank. |
LEAD=C'<‘ | tells that all records should be appended with ‘<‘ at start |
TRAIL=C’>’ | tells that all records should be appended with ‘>’ at end |
MID=C’.’ | MID=string specifies the string to replace removed blanks |
PAIR=QUOTE | “ignore” blanks and PREBLANK characters between pairs of quotes |
PAIR=APOST | “ignore” blanks and PREBLANK characters between pairs of apostrophes |
-
OVERLAY
The OVERLAY parameter of the OUTREC statement can be used if you only want to change one or a few items and keep the rest of the record in its original form
Suppose you want to change the data present in bytes 6 to 10 to upper case and leave the other part of the data as it is, you can use below OVERLAY.
OPTION COPY
OUTREC OVERLAY=(6:6,5,TRAN=LTOU)
This will copy the data from bytes 1 to 5 as it is into the output file and convert the chars present in bytes 6 – 10 into upper case.
——————————————————————————————————–
In United States, If you would like to Earn Free Stocks, Credit card Points and Bank account Bonuses, Please visit My Finance Blog
——————————————————————————————————–
You may also like to look at:
Working on Mainframes – Is Change to a different technology necessary |
Pingback: SORT – PARSE – READ EXCEL (CSV) FILE IN MAINFRAMES | F1 for Mainframe
Good document, have tried to implement the above logic and it working fine as per the requirement.