IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

HEADER1 with Date arithmetic


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Martin-2000

New User


Joined: 15 Jun 2015
Posts: 1
Location: UK

PostPosted: Thu Feb 21, 2019 3:24 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Feb 21, 2019 5:59 pm
Reply with quote

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
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Thu Feb 21, 2019 6:26 pm
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Feb 21, 2019 6:59 pm
Reply with quote

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
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1249
Location: Bamberg, Germany

PostPosted: Sat Feb 23, 2019 3:03 pm
Reply with quote

Temporary datasets should start with &&, not?. This is why I like system generated stuff. icon_wink.gif

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Need help to append a date&tsp at... DFSORT/ICETOOL 9
No new posts Fetch data from programs execute (dat... DB2 3
Search our Forums:

Back to Top