SHIFT

SHIFT =LEFT will left-squeeze by removing all of the blanks, shifting the remaining characters to the left and padding on the right with blanks if needed.

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.

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).

MID=C’ ‘ will insert one blank for each group of blanks SQZ removes.

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 processing begins (for example, character sequences of /*, //*, */, // and * are all replaced with blanks).

If you want DFSORT to “ignore” blanks and PREBLANK characters between pairs of quotes, you can use PAIR=QUOTE with SQZ.

If you want DFSORT to “ignore” blanks and PREBLANK characters between pairs of apostrophes, you can use PAIR=APOST with SQZ.

EXAMPLES using SHIFT

Example-01: Remove SPACES/BLANKS out of a string

Input Data containing extra Spaces:

Kevin   James R
Douglas Philips    K
Smith   John   L

As we have to remove the white space (blanks), you can use the following statements to left-squeeze the data:

 OPTION COPY
 INREC BUILD=(1,40,SQZ=(SHIFT=LEFT))

The results produced for this OUTREC statement:

KevinJamesR
DouglasPhilipsK
SmithJohnL

If you want to right-squeeze the data then below-mentioned statement will produce the required result:

  OPTION COPY
  OUTREC FIELDS=(1,40,SQZ=(SHIFT=RIGHT))

Example-02: Add leading and trailing words after removal of SPACES/Blanks.

DFSORT 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 [Start] and [/End]

   OPTION COPY
   OUTREC FIELDS=(1,40,SQZ=(SHIFT=LEFT,LEAD=C'[Start]',
   TRAIL=C'[/End]'))

The results produced for this OUTREC statement are:

 [Start]KevinJamesR[/End]
 [Start]DouglasPhilipsK[/End]
 [Start]SmithJohnL[/End]

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. XX – Number of bytes you want the output result.

Example-03: Insert one blank for each group of blanks SQZ removes from the string.

Input Data containing extra Spaces:

 Kevin   James R
 Douglas Philips    K
 Smith   John   L

As we have to remove the white space (blanks) and add one space (blank) to each group, you can use the following statements to left-squeeze the data:

 OPTION COPY
 INREC BUILD=(1,48,SQZ=(SHIFT=LEFT,MID=C' '))

The results produced for this OUTREC statement:

 Kevin James R
 Douglas Philips K
 Smith John L

Example-04: Remove a particular character & shift the remaining characters to Left or Right.

Input Data containing special characters:

 abcd!efghi!jklm!0!
 abcdefgh!ijklmnopq!0!

The ask is to find and remove “!” characters and shift the remaining characters to the left.

  OPTION COPY
  INREC OVERLAY=(1,25,SQZ=(SHIFT=LEFT,PREBLANK=C'!'))

The results produced for this OUTREC statement:

 abcdefghijklm0
abcdefghijklmnopq0

Example – 05: Remove all spaces and pace one space in after group along with protecting all characters in Quote.

Input Data containing extra Spaces & Quote:

 “Kevin     James R -”        +800
 “Douglas Philips     K -”    +100
 “Smith   John L   +”         -300

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:

   OPTION COPY
   OUTREC FIELDS=(1,80,SQZ=(SHIFT=LEFT,PAIR=QUOTE,
   PREBLANK=C'+-',MID=C' '))

The results produced for this OUTREC statement are:

 “Kevin James R -” 800
 “Douglas Philips K -” 100
 “Smith John L +” 300

If we want to protect the data within apostrophes then mention control card will achieve the result.

Input Data containing extra Spaces & apostrophes:

 ‘Kevin James R-’        +800
 ‘Douglas Philips K-’    +100
 ‘Smith John L+’         -300
   OPTION COPY
   OUTREC FIELDS=(1,80,SQZ=(SHIFT=LEFT,PAIR=APOST,
   PREBLANK=C'+-',MID=C' '))

The results produced for this OUTREC statement are:

 ‘Kevin James R-’ 800
 ‘Douglas Philips K-’ 100
 ‘Smith John L+’ 300

Example – 06: Left-justifying and right-justifying data

Input Data:

    Kevin James R
 Douglas Philips K
          Smith John L

As we have to remove the white space (blanks), you can use the following statements to left-squeeze the data:

 OPTION COPY
 INREC BUILD=(1,40,JFY=(SHIFT=LEFT))

The results produced for this OUTREC statement:

 Kevin James R
 Douglas Philips K
 Smith John L

You can use all of the above keywords like LEAD, TRAIL, LENGTH, etc. with JFY

Read JCL blogs : Click Here SYNCSORT Manual : Click Here

Scroll to Top