|
View previous topic :: View next topic
|
| Author |
Message |
Martin-2000
New User
Joined: 15 Jun 2015 Posts: 1 Location: UK
|
|
|
|
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.
Many thanks.
Martin. |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10902 Location: italy
|
|
|
|
if the file is empty there is nothing to overlay
You will have to use three steps
find out if the file is empty ( gazillions of example in the forum )
if empty BUILD the header
if not OVERLAY the header |
|
| Back to top |
|
 |
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1216 Location: Dublin, Ireland
|
|
|
|
For the DATE calculation function :
| Code: |
SORT FIELDS=COPY
INREC BUILD=(1501:DATE1)
OUTREC OVERLAY=(1501:1501,8,Y4T,SUBDAYS,+1,TOGREG=Y4T)
|
Garry |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 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.
| Code: |
//STEP001 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
DUMMY RECORD
//SORTOUT DD DSN=&S1,DISP=(,PASS),UNIT=SYSDA
//SYSIN DD *
SORT FIELDS=COPY
INREC BUILD=(C'PREV-DATE,''',DATE1-1,C'''',80:X)
//*
//STEP002 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&S1,DISP=SHR
//SORTIN DD *
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL REMOVECC,
HEADER1=('TRANSACTION FOR:',PREV-DATE),
TRAILER1=(COUNT=(M11,LENGTH=07)) |
|
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1441 Location: Bamberg, Germany
|
|
|
|
Temporary datasets should start with &&, not?. This is why I like system generated stuff.
| Code: |
//STEP001 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
DUMMY RECORD
//SORTOUT DD DISP=(NEW,PASS),UNIT=SYSALLDA
//SYSIN DD *
OPTION COPY
INREC BUILD=(C'PREV-DATE,''',DATE1-1,C'''',80:X)
END
/*
//STEP002 EXEC PGM=SORT
//SYMNAMES DD DISP=(SHR,PASS),DSN=*.STEP001.SORTOUT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
WHATEVER
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL REMOVECC,
HEADER1=('TRANSACTION FOR:',PREV-DATE),
TRAILER1=(COUNT=(M11,LENGTH=07))
END
/* |
|
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|