DFSORT OUTREC squeezing Data

DFSORT OUTREC: Justifying Data DFSORT OUTREC: Reformatting with OVERLAY

Advertisements


OUTREC statement can be used to squeeze the content in the file while sorting.


Syntax:

OPTION COPY
OUTREC FIELDS=(Starting position of field1, Length of field1,
		SQZ=(SHIFT=LEFT/RIGHT,LEAD=charset, TRAIL=charset),…)

Name Description
Starting position of field1Specifies field1 starting position in the input file after sorting.
Length of feild1Field1 physical length in input file.
SHIFTSpecifies the justification

SHIFT=LEFT indicates the 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 the 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=charset Specifies the leading characters/string adding to data
TRAIL=CharsetSpecifies the trailing characters/strings adding to data

PREBLANK=


Syntax:

OPTION COPY
OUTREC FIELDS=(Starting position of field1, Length of field1,SQZ=(SHIFT=LEFT/RIGHT, PREBLANK=charset),…)

Name Description
Starting position of field1Specifies field1 starting position in the input file after sorting.
Length of feild1Field1 physical length in input file.
SHIFTSpecifies the justification
SHIFT=LEFT indicates that you want to left-justify
SHIFT=RIGHT indicates that you want to right-justify
PREBLANK=charsetSpecifies the characters that replaced or blank out as leading and trailing to data
PREBLANK=list specifies a list of characters to replace with blanks before DFSORT starts to squeeze the data.

Note:

The each character in the list isindependent of the other characters.


MID=


MID=string specifies the string to replace removed blanks or PREBLANK characters as a character or hexadecimal constant (1 to 10 bytes).


Syntax:

OPTION COPY
OUTREC FIELDS=(Starting position of field1, Length of field1,SQZ=(SHIFT=LEFT/RIGHT,MID=String),…)

PAIR=


If DFSORT to "ignore" blanks and PREBLANK characters between pairs of quotes, PAIR=QUOTE with SQZ can be used.


Syntax:

OPTION COPY
OUTREC FIELDS=(Starting position of field1, Length of field1, SQZ=(SHIFT=LEFT/RIGHT, PAIR=QUOTE),…)

All Parameters


Syntax:

OPTION COPY
OUTREC FIELDS=(Starting position of field1, Length of field1, 
		SQZ=(SHIFT=LEFT/RIGHT, PAIR=QUOTE, PREBLANK=charset, MID=String),…)

Example: -

Remove the () from data in first 29 bytes and remove spaces between the data and separate the data with ‘,’.


Input File: MTHUSER.SORT.INPUT01 - FB file of 80 length

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
(  student1     )            dept1          560       01012015                  
  (   student2   )           dept2          520       03032015                  
        (  student3  )       dept1          540       06022015                  
(student4    )               dept2          500       09202015                  
    (   student5   )         dept3          510       05182015                  
******************************** Bottom of Data ********************************

Job:

000100 //Jobcard 
000400 //*                                                                     
000500 //**********************************************************************
000600 //*                                                                     
000700 //* SORT FOR OUTREC STATEMENT                                           
000800 //*                                                                     
000900 //**********************************************************************
001100 //STEP01   EXEC PGM=SORT                                                
001300 //SORTIN   DD DSN=MTHUSER.SORT.INPUT03,DISP=SHR                    
001800 //SORTOUT  DD SYSOUT=*                                                  
001900 //SYSOUT   DD SYSOUT=*                                                  
002400 //SYSIN    DD *                                                         
002411      OPTION COPY                                                        
002420      OUTREC FIELDS=(1,80,SQZ=(SHIFT=LEFT,PREBLANK=C'()',                
002430                     MID=C','))                                          
003500 /*                                                                      
****** **************************** Bottom of Data ****************************

Output:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* TOP OF DATA **********************************
student1,dept1,560,01012015                                                     
student2,dept2,520,03032015                                                     
student3,dept1,540,06022015                                                     
student4,dept2,500,09202015                                                     
student5,dept3,510,05182015                                                     
******************************** BOTTOM OF DATA ********************************

Explaining Solution:

  1. OUTREC FIELDS=(1,80,SQZ=(SHIFT=LEFT,..)) - Squeezes the data in 1-80 bytes to the left.
  2. OUTREC FIELDS=(1,80,SQZ=(..,PREBLANK=C'()',..)) - Blanks out the ()
  3. OUTREC FIELDS=(1,80,SQZ=(.., MID=C',')) - the data which had spaces in between separated by ‘,’.

DFSORT OUTREC: Justifying Data DFSORT OUTREC: Reformatting with OVERLAY

Advertisements