6 Sept 2012

How to sort using SORT FIELDS

  • The basic operation performed in SORT is as the name mentions.
  • We are the sorting the input records based on the sort fields we are mentioning.
  • Here records will be sorted based on record position 1 to 10  of the input.
  • Data format explains the format of data in sort field.
  • Data formats like CH(CHaracter) , ZD(Zoned Decimal), PD(Packed Decimal), BI(BInary) are very commonly used.
  • Sequence tells on what sequence the output needs to be stored whether Ascending or Descending.

//SYSIN DD *
  SORT FIELDS=(1,10,CH,A)
/*


1    --> Starting sort position

10  --> Length  of sort field

CH --> Data Format (Character)

A    --> Sequence (Ascending)

  • We can also mention more than one sort fields.
  • First the record will be sorted based on the first sort fields and it continues.


//SYSIN DD *
  SORT FIELDS=(1,10,CH,A,15,5,CH,A)

/*

No comments:

Post a Comment