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
 

 

To Get Pevious Month End Date Using SYNCSORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
ballaswaroop

New User


Joined: 20 Sep 2005
Posts: 24

PostPosted: Mon Jun 18, 2012 8:26 pm    Post subject: To Get Pevious Month End Date Using SYNCSORT
Reply with quote

Hi,

Is there a way to get Previous month end date?

Eg Today date is 18-June-2012. I would need to get the date as 31052012.

So, what ever is today's date - the sort card should be able to get the previous month end date.

Thanks,Swaroop
Back to top
View user's profile Send private message

Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Mon Jun 18, 2012 8:46 pm    Post subject:
Reply with quote

Hi,

Given the date Convert it into Yyyymmdd format
Use DATE1
Generate the control card dynamically as DATE1 - DD
You would get previous months end date

Untested
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Jun 18, 2012 8:55 pm    Post subject:
Reply with quote

also there is a LASTDAYM function,
take LASTDAYM from (todays date - 1 month)
as Pandora said,
use the above to generate a SYSNAMES record.

LASTDAYM is described in
ftp://ftp.software.ibm.com/storage/dfsort/mvs/sortugph.pdf

subtracting months from a date is described here:
ftp://ftp.software.ibm.com/storage/dfsort/mvs/sorttrck.pdf
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Jun 18, 2012 9:46 pm    Post subject: Reply to: To Get Pevious Month End Date Using DFSORT
Reply with quote

ballaswaroop,

The following DFSORT JCL will give you the desired results. I assumed your last month date needs to be at position 10.

Code:

//STEP0100 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                       
//SORTIN   DD *                                             
RECORD                                                       
//SORTOUT  DD SYSOUT=*                                       
//SYSIN    DD *                                             
  SORT FIELDS=COPY                                           
  INREC IFOUTLEN=80,IFTHEN=(WHEN=INIT,                       
  OVERLAY=(81:DATE2-1,C'01',81:81,8,Y4T,LASTDAYM,TOGREG=Y4T,
           10:87,2,85,2,81,4))                               
//*


Alternatively you can use Date1 - DD to get the Last day of previous month.

Code:

//*                                                         
  SORT FIELDS=COPY                                           
  INREC IFOUTLEN=80,IFTHEN=(WHEN=INIT,                       
  OVERLAY=(81:DATE1,81:81,8,Y4T,SUBDAYS,87,2,ZD,TOGREG=Y4T, 
           10:87,2,85,2,81,4))                               
//*
Back to top
View user's profile Send private message
ballaswaroop

New User


Joined: 20 Sep 2005
Posts: 24

PostPosted: Tue Jun 19, 2012 11:28 am    Post subject: Reply to: To Get Pevious Month End Date Using DFSORT
Reply with quote

Thank you! But, looks like our vesion of SORT doesn't support Y4T. Is there any othere way to get the last date of the previous Month ?

Code:
 SYNCSORT FOR Z/OS  1.3.0.2R    U.S. PATENTS: 4210961, 5117495   (C) 2007 SYNCSO
 SYSIN :                                                                       
      SORT FIELDS=COPY                                                         
      INREC IFOUTLEN=80,IFTHEN=(WHEN=INIT,                                     
      OVERLAY=(10:DATE2-1,C'01',10:10,8,Y4T,LASTDAYM))                         
                        *                                       
                                                                               
 WER268A  INREC STATEMENT   : SYNTAX ERROR                                     
 WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000                                 
 WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Tue Jun 19, 2012 11:30 am    Post subject:
Reply with quote

Phew Syncsort question not on DFSORT forum
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Tue Jun 19, 2012 11:30 am    Post subject: Reply to: To Get Pevious Month End Date Using DFSORT
Reply with quote

since You posted in the DFSORT/ICETOOL section of the forum
You were given a DFSORT solution.
nothing more, nothing less...

if You had posted in the right section, or told that You were using SYNCSORT
nobody would have wasted time posting a solution not suited for Your environment.

topic moved where it belongs, the JCL section

and anyway Your problem determination was wrong...
SYNCSORT does not complain about the Y4T but about DATE2-1
( unless the post was badly formatted )
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Tue Jun 19, 2012 6:46 pm    Post subject:
Reply with quote

Try this, this works with SYNCSORT FOR Z/OS 1.3.2.2R
Code:
//STEP01   EXEC PGM=ICEMAN                                         
//SYSOUT   DD SYSOUT=*                                             
//SYMNAMES DD *                                                   
JULIAND,S'&LJDAY'                                                 
PMONTH,S'&LDAY'                                                   
YEAR2,S'&LYR2'                                                     
//SORTIN   DD *                                                   
//*                                                                   
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                   
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:JULIAND,PMONTH,YEAR2)),     
  IFTHEN=(WHEN=INIT,OVERLAY=(88:81,3,ZD,SUB,84,2,ZD,M11,LENGTH=3)),
  IFTHEN=(WHEN=INIT,OVERLAY=(91:X'01',86,5,ZD,TO=PD,LENGTH=3)),   
  IFTHEN=(WHEN=INIT,OVERLAY=(81:91,4,DT1,EDIT=(TTTTTTTT)))         
                                                                   
  SORT FIELDS=COPY                                                 
  OUTREC BUILD=(85,2,C'/',87,2,C'/',81,4)                         
/*                                                                 
I've not verified if DT1 is available with SYNCSORT FOR Z/OS 1.3.0.2R.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Jun 19, 2012 11:25 pm    Post subject:
Reply with quote

Anuj Dhawan,

Couple of Questions.

1. Your sortin does NOT have any records. Does it still generate a record with an empty output?

2. What happens if the current date happens to be in January?(Jan 1st - January 31st ). The Julian date and day of the month will be the same and when you subtract them you end up with zero.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Fri Jun 22, 2012 7:18 pm    Post subject:
Reply with quote

For both the points You're correct Kolusu. For point

1. I managed to put a comment but did not realize that input is absent. It should have been:
Code:
//SORTIN   DD *                                                   

//*           


2. I plotted a time-bomb, will explode in Jan. I should have created symbols using some DATE function of sort... icon_redface.gif

Removing the egg from face ...slowly.

PS.: And you could call me Anuj, that salutation sounded too rude. Specially when we "know" each other... icon_smile.gif.
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 -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 1 Fri Dec 02, 2016 9:47 am
No new posts TOT & DATE parameter in ICEMAN hemanthj642 DFSORT/ICETOOL 4 Mon Nov 14, 2016 5:19 am
No new posts Syncsort - Hard coded Value in output PORYES SYNCSORT 1 Thu Nov 03, 2016 9:23 am
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
No new posts How to get previous month in SYMNAMES Suganya87 SYNCSORT 9 Fri Oct 28, 2016 1:37 pm


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