---
title: "DFSORT: How to OVERLAY Values Best Example"
description: "Using the DFSORT utility, you can OVERLAY values in the input file. How to do this, I have explained with an example."
url: https://srinimf.com/2015/03/30/sort-overlay-command-in-jcl/
date: 2015-03-30
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2015/03/pexels-photo-1174103.jpeg?fit=1733%2C1300&ssl=1
categories: ["DFSORT"]
tags: ["DFSORT overlay example", "DFSORT tips and Tricks"]
type: post
lang: en
---

# DFSORT: How to OVERLAY Values Best Example

OVERLAY, you can use to overlaying with other value [in DFSORT](https://srinimf.com/2015/12/25/understanding-the-background-of-dfsort-tip-trlupd-in-jcl/). Here is an example.

Related[DFSORT Complex Interview Questions](https://srinimf.com/2016/07/05/dfsort-complex-interview-questions/)

Advertisements

## Overlay Example.

```
//SYSIN DD * 
* Skip the first three records 
OPTION SKIPREC=3 
* 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. 
INREC OVERLAY=(73:SEQNUM,8,ZD) 
* 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'*', 
45,4,BI,M11,4X,8,2,PD,M11,
((32,6,PD,MUL,-50),ADD,58,3,ZD),
M11,LENGTH=8, 73,8) 
* Produce three output data sets 
* from one pass over the input 
OUTFIL FNAMES=(OUT1,OUT2,OUT3) 
/*
```

### 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 you can apply in both the INREC and OUTREC formattings.

**Keep Reading**

- [How to Use GitHub Copilot in VS Code for Faster Coding](https://srinimf.com/2026/11/08/how-to-use-github-copilot-with-vs-code-a-complete-step-by-step-guide/)
- [How to Find Databricks Job Status, Owner, and Active Runs Fast](https://srinimf.com/2026/10/17/databricks-find-job-status/)
- [30 SQL Practice Queries with Solutions — Run Them Live](https://srinimf.com/2026/10/01/30-sql-practice-queries-with-solutions-run-them-live/)

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2015%2F03%2F30%2Fsort-overlay-command-in-jcl%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2015%2F03%2Fpexels-photo-1174103.jpeg%3Ffit%3D1200%252C900%26ssl%3D1&description=DFSORT%3A%20How%20to%20OVERLAY%20Values%20Best%20Example)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2015/03/30/sort-overlay-command-in-jcl/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2015/03/30/sort-overlay-command-in-jcl/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2015/03/30/sort-overlay-command-in-jcl/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2015/03/30/sort-overlay-command-in-jcl/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20DFSORT%3A%20How%20to%20OVERLAY%20Values%20Best%20Example&body=https%3A%2F%2Fsrinimf.com%2F2015%2F03%2F30%2Fsort-overlay-command-in-jcl%2F&share=email)
-

### Like this:

Like Loading…
