---
title: "JCL: DFSORT, IFTHEN, Overlay,When,HIT"
description: "Here is a sample DFSORT JCL on how to use IFTHEN, OVERLAY, WHEN and HIT. How to Use IFTHEN, OVERLAY, WHEN, HIT in DFSORT.. //SYSIN     DD     *. INREC  IFTHEN  =(WHEN=(10,1,CH,EQ'C'),OVERLAY(10:C'+'),..."
url: https://srinimf.com/2010/12/04/jclsort-syntax-ifthen/
date: 2010-12-04
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2010/12/pexels-photo-6180668.jpeg?fit=1880%2C1253&ssl=1
categories: ["DFSORT", "JCL"]
tags: ["JCL DFSORT", "JCL IF Then Else"]
type: post
lang: en
---

# JCL: DFSORT, IFTHEN, Overlay,When,HIT

Here is a sample DFSORT JCL on [how to use](https://srinimf.com/2016/02/02/dfsort-best-example-for-multiple-overlay/) IFTHEN, OVERLAY, WHEN and HIT.

[![dfosrt tricky questions](https://i0.wp.com/srinimf.com/wp-content/uploads/2019/12/dfosrt-tricky-questions.png?resize=560%2C315&ssl=1)](https://www.slideshare.net/srinipdn/20-dfsort-tricks)

## How to Use IFTHEN, OVERLAY, WHEN, HIT in DFSORT..

```
//SYSIN     DD     *
INREC  IFTHEN =(WHEN=(10,1,CH,EQ'C'),OVERLAY(10:C'+'),HIT=NEXT),
IFTHEN=(WHEN=(27,1,CH,EQ'C'),OVERLAY(27:C'+'),HIT=NEXT),
and so on
SORT FIELDS=COPY
OUTREC FIELDS=(1,3122)
//
Note: HIT=NEXT, tells that to process next IFTHEN
```

**[Recent Posts](https://srinimf.com/2020/04/19/db2-how-to-compare-dates/)**

- [30 SQL Practice Queries with Solutions — Run Them Live](https://srinimf.com/2026/10/01/30-sql-practice-queries-with-solutions-run-them-live/)
- [Supercharge Your Database Skills: Try Our New Interactive SQL Plugin!](https://srinimf.com/2026/09/30/supercharge-your-database-skills-try-our-new-interactive-sql-plugin/)
- [How to Count Spark Stages by Sight and Optimize Shuffles](https://srinimf.com/2026/09/27/how-to-count-spark-stages-by-sight-and-optimize-shuffles/)

### 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%2F2010%2F12%2F04%2Fjclsort-syntax-ifthen%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2010%2F12%2Fpexels-photo-6180668.jpeg%3Ffit%3D1200%252C800%26ssl%3D1&description=JCL%3A%20DFSORT%2C%20IFTHEN%2C%20Overlay%2CWhen%2CHIT)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2010/12/04/jclsort-syntax-ifthen/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2010/12/04/jclsort-syntax-ifthen/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2010/12/04/jclsort-syntax-ifthen/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2010/12/04/jclsort-syntax-ifthen/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20JCL%3A%20DFSORT%2C%20IFTHEN%2C%20Overlay%2CWhen%2CHIT&body=https%3A%2F%2Fsrinimf.com%2F2010%2F12%2F04%2Fjclsort-syntax-ifthen%2F&share=email)
-

### Like this:

Like Loading…
