I 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.
//SYSIN DD *
* Skip the first three records
* Keep records that meet the specified field-to-field or
* field-to-constant selection criteria
* Add a sequence number to the remaining records.
* Sort the records.
* Produce one record for each unique sort key with totals
* for the specified summary fields
* Produce output records displaying the sort and sum fields
* intermixed with constants and arithmetic operations.
* 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.