22 Jul, 2012

SORT using SYNCSORT

//STEP01   EXEC PGM=SYNCSORT                           

//SYSPRINT DD SYSOUT=*                                 

//SYSOUT   DD SYSOUT=*                                 

//SORTIN   DD DISP=SHR,DSN=XXXXXXX.NONX.SAMPLE1        

//SORTOUT  DD DSN=XXXXXXX.NONX.SAMPLE2,DISP=(NEW,CATLG),

//            DCB=*.SORTIN,SPACE=(TRK,(1,2),RLSE),     

//            UNIT=TESTDA                              

//SYSIN    DD *                                        

  SORT FIELDS=(1,5,CH,A)                               

The above example sorts the input dataset on the first five characters.  The control card is explained below.

SORT FIELDS=(1,5,CH,A)  - Specifying SyncSort to sort the input dataset on the first five bytes of data in ascending order. 

1 = Starting Position in input dataset

5 = Length

CH = Format of the data on which we are performing SORT

A = Ascending

Examples –

SORT FIELDS=(1,5,A,11,25,D),FORMAT=CH

– In the above example we are trying to sort zip code on ascending order and city name on descending order.  As both the zip code and city name are of same format we are specifying the format in last.

SORT FIELDS=(1,5,A,11,25,D),FORMAT=CH,STOPAFT=100

SORT and copies only the first 100 records into output dataset

SORT FIELDS=(1,5,A,11,25,D),FORMAT=CH,SKIPREC=100

Ignores the first 100 records from input dataset

Supported data formats not limited to –

CH – Character, PD – Packed Decimal, ZD – Zoned Decimal, BI – Binary etc.,

SORT FIELDS=(1,5,A,11,25,D)

SUM FIELDS=NONE

Remove the duplicate records.  If we want to capture the duplicate records that are removed from the input dataset then mention the SUM control statement as below.

SUM FIELDS=NONE,XSUM

Note: If the input dataset is of variable block type then add 4 to the starting position.  This is required for variable length records.

SORT

Tags:

No Responses to "SORT using SYNCSORT"

Subscribe to Comment follow up

Comment Form

Trackbacks