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

How to get previous month in SYMNAMES


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Suganya87

New User


Joined: 09 May 2016
Posts: 12
Location: India

PostPosted: Fri Oct 28, 2016 1:37 pm
Reply with quote

Code:
//SYMNAMES DD *                                               
 CURDATE,S'&YR4.-&MON.-18'                                     
 PREDATE,S'&LYR4.-&LMON-17'                                   
/*                                                             
//SYSPRINT DD SYSOUT=*                                         
//SYSOUT   DD SYSOUT=*                                         
//SORTIN    DD DISP=SHR,DSN= dsn name     
//SORTOUT   DD DSN=dsn name1,                     
//            DISP=(NEW,DELETE,DELETE),                       
//            SPACE=(CYL,(10,05)),MGMTCLAS=LUSE180,           
//            DCB=(RECFM=FB,LRECL=58,BLKSIZE=5800)             
//SYSIN    DD *                                               
   INCLUDE COND=(001,10,CH,GE,CURDATE,&,                           
              001,10,CH,LE,PREDATE,PM)                         
   SORT FIELDS=(1,04,CH,A)                                     
   END                                                         
/*             

My requirement is to get the details from 17 of previous month to 18th of current month . Can you please help me how to get previous month details in SYMNAMES.

Edited typo in topic title.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


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

PostPosted: Fri Oct 28, 2016 5:51 pm
Reply with quote

If you don't already have a "calendar file" (dates you need for your system) to generate from, then just generate the symbols you need in a prior step, so you can "calculate" the start of your range.
Back to top
View user's profile Send private message
Suganya87

New User


Joined: 09 May 2016
Posts: 12
Location: India

PostPosted: Mon Oct 31, 2016 3:19 pm
Reply with quote

Hi bill,

I got the calendar dates from CURDATE using "SYMNAMES" but am not sure how to calculate the previous month date (PREDATE) PREDATE,S'&LYR4.-&LMON-17'
using "SYMNAME" . Can you please let me know how to achieve the same.

Thanks
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


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

PostPosted: Mon Oct 31, 2016 4:21 pm
Reply with quote

There are date functions. Those may be the simplest ways to work out month-and-year of previous month. Apply those to your source-date, hard-code the 17/18 (so that it works) and generate the symbols with the values you need for the run.
Back to top
View user's profile Send private message
Suganya87

New User


Joined: 09 May 2016
Posts: 12
Location: India

PostPosted: Tue Nov 01, 2016 5:50 pm
Reply with quote

Can you please post me the date function code, because I tried it with different function, nothing is working out . Please help me on this .
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


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

PostPosted: Tue Nov 01, 2016 8:16 pm
Reply with quote

We can best help if you show what you tried and the results of that. Input and expected output, and what you got, including error messages (with codes).
Back to top
View user's profile Send private message
dneufarth

Active User


Joined: 27 Apr 2005
Posts: 326
Location: Inside the SPEW (Cincinnati OH USA)

PostPosted: Wed Nov 02, 2016 2:06 am
Reply with quote

What about rerun situations for prior periods or testing scenario.

Always needed eventually.

Always like the run date seeded in a dataset or calendaring dataset as mentioned previously.
Back to top
View user's profile Send private message
John Del

New User


Joined: 27 Apr 2012
Posts: 42
Location: NY

PostPosted: Wed Nov 02, 2016 7:25 pm
Reply with quote

dneufarth wrote:
What about rerun situations for prior periods or testing scenario.

Always needed eventually.

Always like the run date seeded in a dataset or calendaring dataset as mentioned previously.


Agreed.

When implementing sort parameters with include/omit date dependencies, I like to use symbolic parameters that can be manually configured via set/proc statements (JPn) overrides when needed. Whether this particular solution is meant for production or not, sooner or later you will come across a situation that you'll benefit by building in the JPn feature.

Don't quote me on this as I am not a Syncsort user but I think newer Syncsort releases now support JPn symbolic parameters.

My recommendation for the OP would be to see what release of Syncsort they have, consult the documentation and if available, consider a solution that leverages symbolic parameters.

J
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 310
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Thu Nov 03, 2016 6:04 pm
Reply with quote

I'm using SYNCSORT FOR Z/OS 1.4.2.0R. It supports JPn symbolic parameters.
Back to top
View user's profile Send private message
John Del

New User


Joined: 27 Apr 2012
Posts: 42
Location: NY

PostPosted: Thu Nov 03, 2016 11:07 pm
Reply with quote

mistah kurtz wrote:
I'm using SYNCSORT FOR Z/OS 1.4.2.0R. It supports JPn symbolic parameters.


In that case, here is an option for the OP to consider if they also have JPn support in their Syncsort version. I use a variation of this all the time (DFSORT) to convert Gregorian parm dates to Julian dates for comparison.

Code:
// SET BEGDATE='20160101',ENDDATE='20160330'
//*SET BEGDATE='CCYYMMDD',ENDDATE='CCYYMMDD'
//********************************************************
//* GENERATE SYMBOLICS FOR BEGIN & END DATE PARMS
//********************************************************
//STEP0010 EXEC PGM=SORT,PARM=('JP0"&BEGDATE"','JP1"&ENDDATE"')
//SYMNAMES DD DISP=SHR,DSN=&SYMBLIB(SYMCONST)
//         DD *
BEG-DAY,'17'
END-DAY,'18'
//SYMNOUT  DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//SORTIN   DD *
CCYYMMDD MMDDCCYY  CCYYDDD
//DATEPARM DD DSN=&&S,DISP=(,PASS,DELETE),UNIT=SYSDA,SPACE=(TRK,(1,1))
//DATEPARX DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY,STOPAFT=1

* EDIT TO SEE IF THERE IS A PARM DATE OVERRIDE,
*  OTHERWISE USE CURRENT DATE FOR DEFAULT

   INREC IFOUTLEN=80,
          IFTHEN=(WHEN=(1,8,CH,NE,JP0),
            OVERLAY=(01:JP0,01:01,8,Y4T,TOGREG=Y4T(-),
                     11:JP1,11:11,8,Y4T,TOGREG=Y4T(-)),HIT=NEXT),
          IFTHEN=(WHEN=(1,8,CH,EQ,JP0),
            OVERLAY=(01:DATE2-1,BEG-DAY,01:01,8,Y4T,TOGREG=Y4T(-),
                     11:DATE2,END-DAY,11:11,8,Y4T,TOGREG=Y4T(-)))

 * BUILD THE SYMBOLICS USED BY SUBSEQUENT SORT STEPS
 *
   OUTFIL FNAMES=(DATEPARM,DATEPARX),
          BUILD=(C'BEG-DATE,C',Q,01,10,Q,80:X,/,
                 C'END-DATE,C',Q,11,10,Q,80:X)
 /*


J
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 -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts To get previous month from current ti... SYNCSORT 7
No new posts Write a current record plus previous ... DFSORT/ICETOOL 4
No new posts How to append Previous date into a S... JCL & VSAM 2
No new posts Execute step regardless of previous s... JCL & VSAM 2
No new posts Last day of the month via SYNCSORT. SYNCSORT 5
Search our Forums:

Back to Top