Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Alter &DATENS field in HEADER1

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Angad

New User


Joined: 22 Apr 2017
Posts: 2
Location: US

PostPosted: Mon Apr 24, 2017 11:49 am    Post subject: Alter &DATENS field in HEADER1
Reply with quote

Hi All,
I need to populate the 1st date of previous month in the header section of my output file.
The job is scheduled to run on first friday of every month.

Example, today's date is 23rd April 2017.
The date in header needs to be 1st March 2017 (20170301 - CCYYMMDD)

I have taken two different approaches to overcome this, however not able to achieve desired results:

1. Subtracting 30 days from &DATENS in HEADER1, below sort card:

SORT FIELDS=COPY
OUTFIL HEADER1=('H',1' ',&DATENS=(4MD)-30)

- This gives me the required Year and Month i.e. previous.
- However the date needs to be the 1st.
- As date of job execution varies, cannot subtract a precise count from date.
- In case I try to overlap the date in header with '01' is gives an error.

2. Using SYMNAMES with SORT:

//SYMNAMES DD *
MDT,S'&YR4.&LMON'

SORT FIELDS=COPY
OUTFIL HEADER1=('H',1' ',MDT,'01')

- This gives me the required Year and date.
- However the current month is populated.
- No subtraction can be performed here in SORT card.

Kindly share in case desired results can be achieved using any of the above method.
Any new approach is also welcome.
Back to top
View user's profile Send private message

John Del

New User


Joined: 27 Apr 2012
Posts: 25
Location: NY

PostPosted: Mon Apr 24, 2017 8:56 pm    Post subject:
Reply with quote

I would build a symbolic for the date in a previous sort step, similar to the following:

Code:

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD *

//XORTOUT  DD DSN=&&S,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY,STOPAFT=1

  OUTFIL BUILD=(C'FIRST-OF-LAST-MONTH,',DATE2-1,C'01',80:X)
//


Output:
Code:

FIRST-OF-LAST-MONTH,20170301


/*
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Mon Apr 24, 2017 9:28 pm    Post subject:
Reply with quote

Alternatively, you could also append the calculated date value in an OUTREC, and just use it in your HEADER.
Code:
//STEP01  EXEC PGM=SORT                     
//SYSOUT    DD SYSOUT=*                     
//SORTOUT   DD SYSOUT=*                     
//SORTIN    DD *                             
RECORD                                       
//SYSIN     DD *                             
 SORT FIELDS=COPY                           
 OUTREC OVERLAY=(81:DATE2-1,C'01')           
 OUTFIL NODETAIL,REMOVECC,HEADER1=('H ',81,8)

SORTOUT
Code:
----+----1--
H 20170301 
Back to top
View user's profile Send private message
Angad

New User


Joined: 22 Apr 2017
Posts: 2
Location: US

PostPosted: Wed Apr 26, 2017 6:21 am    Post subject:
Reply with quote

Arun Raj wrote:
Alternatively, you could also append the calculated date value in an OUTREC, and just use it in your HEADER.
Code:
//STEP01  EXEC PGM=SORT                     
//SYSOUT    DD SYSOUT=*                     
//SORTOUT   DD SYSOUT=*                     
//SORTIN    DD *                             
RECORD                                       
//SYSIN     DD *                             
 SORT FIELDS=COPY                           
 OUTREC OVERLAY=(81:DATE2-1,C'01')           
 OUTFIL NODETAIL,REMOVECC,HEADER1=('H ',81,8)

SORTOUT
Code:
----+----1--
H 20170301 


Thank you Arun for sharing your approach.
Using the above sort card the required date is populated in the Header section of output file.
However the OVERLAY function populates the required date on the 81st position of all the detail records read from INPUT file.

Any method to populate required date in header section without altering the detail records from input.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Wed Apr 26, 2017 10:11 am    Post subject: Reply to: Alter &DATENS field in HEADER1
Reply with quote

It is only required in that position prior to you using it. Once you have used it, it is no longer required, so you get rid of it. BUILD=(1,80) or IFOUTLEN=80 (if you have at least one IFTHEN already).

I'd go with John Del's suggestion. Both solutions work.
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 READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm
No new posts outrec field outside range Danielle.Filteau SYNCSORT 10 Sat Mar 04, 2017 2:37 am
No new posts 2 byte YEAR from Y'DATE2' field tecnokrat DFSORT/ICETOOL 2 Tue Feb 07, 2017 12:05 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us