---
title: "DFSORT Best Example, How to Use Multiple Overlay"
description: "The example in this post tells you how to use the OVERLAY parameter, which is useful to overwrite the current field-values with new ones."
url: https://srinimf.com/2016/02/02/dfsort-best-example-for-multiple-overlay/
date: 2016-02-02
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2016/02/pexels-photo-4041198.jpeg?fit=1880%2C1253&ssl=1
categories: ["DFSORT"]
tags: ["DFSORT overlay example", "DFSORT OVERLAY Usage"]
type: post
lang: en
---

# DFSORT Best Example, How to Use Multiple Overlay

Here’s the best example of multiple-overlay. This example shows you [how to](https://srinimf.com/2015/07/19/mainframe-reduce-your-coding-lines-using-output-statement-in-jcl-1-of-2/) replace values using OVERLAY.

## DFSORT Multiple OVERLAY.

```
OPTION COPY
OUTREC IFTHEN=(WHEN=INIT, BUILD=(1:1,40,50:106,4,60:170,4,BI,EDIT=(TT.TT),70:170,4)),
IFTHEN=(WHEN=(50,4,CH,EQ,C’COR’,AND,70,4,BI,GT,+2000), OVERLAY=(70:C’20%’,X)),
IFTHEN=(WHEN=(50,4,CH,EQ,C’COR’,AND,70,4,BI,LE,+2000), OVERLAY=(70:C’10%’,X)),
IFTHEN=(WHEN=(50,4,CH,EQ,C’VALD’),OVERLAY=(70:C’25%’,X)),
IFTHEN=(WHEN=NONE,OVERLAY=(70:C’15%’,X))
```

WHEN the condition is satisfied, it overlays with a value or character.

### The explanations

- **WHEN=INIT:** Use one or more WHEN=INIT clauses to apply BUILD, FINDREP, or OVERLAY items to all of your input records. WHEN=INIT clauses and WHEN=GROUP clauses are processed before any of the other IFTHEN clauses.
- **WHEN=INIT** changes (if any) and WHEN=GROUP changes (if any) are applied to input records that do not meet the criteria for any of the WHEN=(logexp) clauses.
- **WHEN=NONE** It means no other condition is satisfied
- One IFTHEN clause is satisfied, then skips checking for other IFTHEN statement

### Standard Multiple OVERLAY syntax

```
[](https://www.ibm.com/support/knowledgecenter/SSLTBW_2.1.0/com.ibm.zos.v2r1.icea100/ice2ca_INREC_control_statement.htm?view=kc#d99555e2333)   .-,-------------------------------------------------------------------
V                                                                     |   
>>---IFTHEN=(-+-WHEN=INIT-+-,PARSE=(definitions)-+-------------------+-)-+-><
              |           '-+-,BUILD=(items)---+-'                   |       
              |             +-,OVERLAY=(items)-+                     |       
              |             '-,FINDREP=(items)-'                     |       
              +-WHEN=GROUP-+-,BEGIN=(logexp)-+-,PUSH=(items)---------+       
              |            +-,KEYBEGIN=(p,m)-+                       |       
              |            +-,END=(logexp)---+                       |       
              |            '-,RECORDS=n------'                       |       
              +-WHEN=(logexp)-+-,PARSE=(definitions)-+-+-----------+-+       
              |               '-+-,BUILD=(items)---+-' '-,HIT=NEXT-' |       
              |                 +-,OVERLAY=(items)-+                 |       
              |                 '-,FINDREP=(items)-'                 |       
              +-WHEN=ANY-+-,PARSE=(definitions)-+-+-----------+------+       
              |          '-+-,BUILD=(items)---+-' '-,HIT=NEXT-'      |       
              |            +-,OVERLAY=(items)-+                      |       
              |            '-,FINDREP=(items)-'                      |       
              '-WHEN=NONE-+-,PARSE=(definitions)-+-------------------'       
                          '-+-,BUILD=(items)---+-'                           
                            +-,OVERLAY=(items)-+                             
                           '-,FINDREP=(items)-'
```

[*DFSORT*](https://srinimf.com/2017/06/13/2-best-ways-split-a-file-using-dfsort/) | [*SORT* ](https://srinimf.com/2016/01/19/15-precious-uses-of-inrecoutrec-and-outfil-in-jcl-dfsort/)| [*Overlay*](https://srinimf.com/2015/05/12/jcl-include-omit-examples/)

### 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%2F2016%2F02%2F02%2Fdfsort-best-example-for-multiple-overlay%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2016%2F02%2Fpexels-photo-4041198.jpeg%3Ffit%3D1200%252C800%26ssl%3D1&description=DFSORT%20Best%20Example%2C%20How%20to%20Use%20Multiple%20Overlay)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2016/02/02/dfsort-best-example-for-multiple-overlay/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2016/02/02/dfsort-best-example-for-multiple-overlay/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2016/02/02/dfsort-best-example-for-multiple-overlay/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2016/02/02/dfsort-best-example-for-multiple-overlay/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20DFSORT%20Best%20Example%2C%20How%20to%20Use%20Multiple%20Overlay&body=https%3A%2F%2Fsrinimf.com%2F2016%2F02%2F02%2Fdfsort-best-example-for-multiple-overlay%2F&share=email)
-

### Like this:

Like Loading…