IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search Log in to check your private messages Log in
 

Alter &DATENS field in HEADER1


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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: 40
Location: NY

PostPosted: Mon Apr 24, 2017 8:56 pm
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: 2481
Location: @my desk

PostPosted: Mon Apr 24, 2017 9:28 pm
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7312
Location: Inside the Matrix

PostPosted: Wed Apr 26, 2017 10:11 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 

Search our Forum:

Similar Topics
Topic Forum Replies
No new posts BMS map length field greater than zero CICS 3
No new posts Break a record into fields, each fiel... SYNCSORT 2
No new posts SYNCSORT Error - CONTROL FIELD BEYOND... SYNCSORT 10
No new posts How do i verify the char field is hav... PL/I & Assembler 1
No new posts VSAM Alter Command - Cylinder Extent ... JCL & VSAM 3

Back to Top