Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
HEADER1 with Date arithmetic

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: HEADER1 with Date arithmetic
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

Senior Member


Joined: 14 Mar 2007
Posts: 10632
Location: italy

PostPosted: Thu Feb 21, 2019 5:59 pm    Post subject: Reply to: HEADER1 with Date arithmetic
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: 1054
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Thu Feb 21, 2019 6:26 pm    Post subject:
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    Post subject:
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

New User


Joined: 15 Aug 2015
Posts: 46
Location: Germany

PostPosted: Sat Feb 23, 2019 3:03 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Mainframe datasets without any last r... rajatbagga All Other Mainframe Topics 1 Tue Sep 24, 2019 8:47 am
No new posts Date insertion returns -180 Raghu navaikulam CICS 1 Mon Jul 29, 2019 5:12 pm
This topic is locked: you cannot edit posts or make replies. Need to write the date at the end of ... Poha Eater DFSORT/ICETOOL 16 Tue Jul 23, 2019 2:33 pm
No new posts SQL to retrieve latest Eff date and then vinu78 DB2 8 Tue Apr 30, 2019 3:45 pm
No new posts how to add date & timestamp to th... dharmaraok DFSORT/ICETOOL 5 Thu Apr 18, 2019 2:45 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us