SORT-Overlay Command In JCL

DB2+Mainframe+Hadoop+Bigdata+JOBSI came from office during rush hour to home, and decided to write something on SORT Overlay. In recent interviews, I found some guys confused to tell about overlay. Below details are an excellent examples to understand OVERLAY.

* Skip the first three records
* Keep records that meet the specified field-to-field or
* field-to-constant selection criteria
INCLUDE COND=(7,5,PD,LE,22,5,PD,OR,25,3,CH,EQ,C’J69′)
* Add a sequence number to the remaining records.
* Sort the records.
SORT FIELDS=(20,8,ZD,A,11,2,CH,D)
* Produce one record for each unique sort key with totals
* for the specified summary fields
SUM FIELDS=(45,4,BI,8,2,PD)
* Produce output records displaying the sort and sum fields
* intermixed with constants and arithmetic operations.
OUTREC BUILD=(8C’0′,20,8,ZD,M11,4X,11,2,4C’‘,
* Produce three output data sets from one pass over the input

Detailed Explanation for Overlay:

Using OVERLAY, you reformat each record by specifying just the items that overlay specific columns.
OVERLAY lets you change specific existing columns without affecting the entire record.

In the below example, OUTREC OVERLAY=(45:45,8,TRAN=LTOU)

Starts from position 45, and length 8, translating lower case to upper case. This example clearly tells how we can use Overlay. One of the frequently asked interview Question, in IBM, Tech Mahindra, CTS, and Dell. Why means all financial projects using Sort, to sort all reports.

The OVERLAY we can apply both INREC and OUTREC formatting.