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

To Get Pevious Month End Date Using SYNCSORT


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ballaswaroop

New User


Joined: 20 Sep 2005
Posts: 25

PostPosted: Mon Jun 18, 2012 8:26 pm
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

Global Moderator


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

PostPosted: Mon Jun 18, 2012 8:46 pm
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
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.software.ibm.com/storage/dfsort/mvs/sortugph.pdf

subtracting months from a date is described here:
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
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: 25

PostPosted: Tue Jun 19, 2012 11:28 am
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

Global Moderator


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

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

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

Superior Member


Joined: 14 Mar 2007
Posts: 10879
Location: italy

PostPosted: Tue Jun 19, 2012 11:30 am
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

Superior Member


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

PostPosted: Tue Jun 19, 2012 6:46 pm
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
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

Superior Member


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

PostPosted: Fri Jun 22, 2012 7:18 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts SYNCSORT-DB2 interface SYNCSORT 0
No new posts Sorting Date Field DFSORT/ICETOOL 4
No new posts CONVERT a given date from UTC TO BST CICS 0
No new posts Pull data using date difference betwe... DB2 6
No new posts CA7 count with DATE variable CA Products 0
Search our Forums:

Back to Top