I have a FB 1500 input file of Txns. The file contains no Header or Trailer, it can sometimes be empty.
I am required to add a Header containing yesterdays SYSDATE and a Trailer. This is required even for empty input files
The following code gives me what I want, but only when the input file has records in it.
Code:
//SYSIN DD *
SORT FIELDS=COPY
OUTREC OVERLAY=(1501:DATE1-1) -- SYSDATE minus 1 day.
OUTFIL REMOVECC,
HEADER1=('TRANSACTION FOR:', -- Build new header rec
1501,8), -- sysdate -1 from overlay
TRAILER1=(COUNT=(M11,LENGTH=07)) -- count of data recs
//*
If the input file is empty, my overlay produces nothing and I do not get a date in my header.
I get a syntax error if I try and use DATE1-1 in the HEADER1 function.
I can use DATENS(4MD) in the HEADER1 function, however I can not perform the neccesary arithmetic on DATENS.
I’ve tried using BUILD, (on OUTREC and INREC) similar issue, if there are no input records I do not get a header at all.
Does anyone know how to insert a header record with yesterday's sysdate that will work with empty and non-empty files.
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
You could also have a step generate a symbol for previous day and use the symbol in your next step. This would write the previous date in the header regardless of your input being empty/not empty.