---
title: "How to Create Report Using DFSORT"
description: "The best way of writing DFSORT JCL to create awesome reports using Headers and Trailers. You will know meanings for different Trailer numbers."
url: https://srinimf.com/2016/09/12/how-to-create-reports-with-dfsort-the-best-way/
date: 2016-09-12
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2016/09/pexels-photo-3760514.jpeg?fit=1767%2C1300&ssl=1
categories: ["DFSORT", "ICETOOL"]
tags: ["Sample DFSORT JCL with Header and Trailer"]
type: post
lang: en
---

# How to Create Report Using DFSORT

You can use DFSORT to create a report. Here is best example [to use](https://srinimf.com/2015/12/25/understanding-the-background-of-dfsort-tip-trlupd-in-jcl/) for your project.

## Creating Report Using DFSORT

- The headers are HEADER1, HEADER2, and HEADER3. Also, you can give trailers TRAILER1, TRAILER2 parameters, and TRAILER3.
- Let you specify multi-line headings with character strings, hexadecimal strings, input fields, the current date, the current time, page numbers and blank lines.
- In addition, you can include edited or converted record counts, and edited or converted totals, maximums, minimums, and averages for numeric fields, in your trailers.

## Example DFSORT Logic

```
//SYSIN DD *
SORT FIELDS=(1,15,CH,A)
OUTFIL FNAMES=RPT4,
HEADER2=(1:'BRANCH',18:'REVENUE',28:'PROFIT'),
OUTREC=(1,15,X,
22,6,PD,EDIT=(SIII,IIT),SIGNS=(,-),X,
28,6,PD,EDIT=(SIII,IIT),SIGNS=(,-),
50:X),
TRAILER1=(2/,
3:'Overall results for branches on ',DATE=(MD4/),':',2/,
3:COUNT=(EDIT=(IIT)),' branches are included',2/,
5:'Total revenue = ',
TOT=(22,6,PD,M12,LENGTH=10),/,
5:'Average revenue = ',
AVG=(22,6,PD,M12,LENGTH=10),/,
5:'Lowest revenue = ',
MIN=(22,6,PD,M12,LENGTH=10),/,
5:'Highest revenue = ',
MAX=(22,6,PD,M12,LENGTH=10))
```

Related Posts

- [Top JCL The Real Usage of IFTHEN in DFSORT](https://srinimf.com/2010/12/12/jcl-sort-examples-and-user-guide/)DateDecember 12, 2010
- [Sample DFSORT JCL to Sort Three Input Files](https://srinimf.com/2016/02/03/how-to-sort-3-input-files-using-dfsort-utility-in-jcl/)DateFebruary 3, 2016
- [How to Use TRLUPD in DFSORT](https://srinimf.com/2015/12/25/understanding-the-background-of-dfsort-tip-trlupd-in-jcl/)DateDecember 25, 2015

### 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%2F09%2F12%2Fhow-to-create-reports-with-dfsort-the-best-way%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2016%2F09%2Fpexels-photo-3760514.jpeg%3Ffit%3D1200%252C883%26ssl%3D1&description=How%20to%20Create%20Report%20Using%20DFSORT)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2016/09/12/how-to-create-reports-with-dfsort-the-best-way/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2016/09/12/how-to-create-reports-with-dfsort-the-best-way/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2016/09/12/how-to-create-reports-with-dfsort-the-best-way/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2016/09/12/how-to-create-reports-with-dfsort-the-best-way/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20How%20to%20Create%20Report%20Using%20DFSORT&body=https%3A%2F%2Fsrinimf.com%2F2016%2F09%2F12%2Fhow-to-create-reports-with-dfsort-the-best-way%2F&share=email)
-

### Like this:

Like Loading…
