Sunday, September 22, 2019

How to add Header and Trailer with Date, Time and Count through JCL

Header : A Name along with the current System date
Trailer  : A static message along with number of input records count

//***************************************************************
//* ADDING HEADER AND TRAILER ALONG WITH COUNTS AND DATES
//***************************************************************
//STEP01 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=A
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=TTR.SORT.TEST.IN,DISP=SHR
//SORTOUT DD DSN=TTR.SORT.TEST.OT,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(CYL,(5,5)),
// DCB=(RECFM=FB,LRECL=50,BLKSIZE=5000)
//*
//SYSIN DD *
  SORT FIELDS=COPY
  OUTFIL REMOVECC,
  HEADER1=(1:'CARD DETAILS AS ON',20:DATE=(MD4/),'@',TIME),
  TRAILER1=(1:'TOTAL NUM OF RECORDS:',COUNT=(M11,LENGTH=4))
/*


output

1 ----+----1----+----2----+----3----+----4--
2 CARD DETAILS AS ON 07/23/2019@05:32:39
3 001990828GOLD CREDIT3395
4 002990829GOLD DEBIT 3396
5 003990830SILVRCREDIT3396
6 004990831PLTNMDEBIT 3395
7 005990832SILVRDEBIT 3395
8 TOTAL NUM OF RECORDS:0005

Header1: It has a Static message which start from 1st position followed by a date and Time. Here given ‘@’ just to separate date and time. You can give anything here.

Trailer1: Count gives the records count excluding Header and Trailer with length of 4.

MD4/: Is a Date format with ‘/’ as a separator. There are few other date formats as well that can be used here.

M11: This is an Edit mask pattern which gives the numbers in 0005 format if the value is 5. Means it shows the leading zeroes as well. There are many other Patterns which we can use here, but as an example I have used M11.

REMOVECC: It removes the ANSI carriage control character from the Output file.




No comments:

Post a Comment