How to use Header in Sort JCL

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
Posts: 8
Joined: Tue Oct 30, 2012 5:14 pm

How to use Header in Sort JCL

Post by Harshal_Chaudhari » Tue Oct 30, 2012 5:30 pm


My input file is


DCB parameter as (LRECL=10,BLKSIZE=23470,RECFM=FB)

I want the Output file as,


So please can anyone help me how i will get the output file using HEADER in my SORt JCL?


User avatar
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Tue Oct 30, 2012 5:55 pm


why the need to use HEADER?

why is there no * for this item?

There is such a thing as SORT control cards,
there is such a thing as JCL to define a JOB that invokes SORT

but there is no such thing as SORT JCL.

why not concatenate three DS as input
one would contain:

the next would contain your input file

the third would contain:

you SORT control cards would consist of:
an IFTHEN looking for '-' in column one,
and not finding that
would PARSE the input record ending at space
then BUILD '-SCAN *',%01,'*'

pretty simple actually.
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

Active Member
Posts: 650
Joined: Sun Jul 24, 2011 5:27 pm
Location: Down on the pig farm

Post by NicC » Tue Oct 30, 2012 6:28 pm

You would get a better result if you posted in the sort part of the forum instead of the JCL part as these are distinctly different entities. When posting in the sort section mention which sort product you are using as that section covers all mainframe sort programs. DO NOT REPOST as someone will move your original post.

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Tue Oct 30, 2012 7:19 pm

dbz's is an approach of "utility", although the trailing "*" will not appear correctly due to the PARSED field having, of necessity, a fixed length. Certainly the "concatenation" is an approach which will work.

HEADERn and TRAILERn will also work for you, and I'm sure you should be able to find examples easily.

Getting the trailing "*" in the correct place is interesting. What is the maximum length of your data?

Let's say for now, it is 20, and assume you have FB 80 coming in (cos it looks like control cards being generated).

I'd use FINDREP, with the thing to "find" being 21 spaces, and the thing to "replace" being "*", and DO=1 and don't let is change the rest of the record (you can look that up yourself, as you'll need to understand the FINDREP anyway).

This way, you don't have to worry about embedded blanks. Your volume will be small, I assume, so minimum code to get wrong (else squeezing, PAIR=, etc).

Post Reply


Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Mainframe Interview questions

Other References
Mainframe Tools and others