View previous topic :: View next topic
Author
Message
ballaswaroop New User Joined: 20 Sep 2005Posts: 25
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
Pandora-Box Global Moderator Joined: 07 Sep 2006Posts: 1592 Location: Andromeda Galaxy
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
dbzTHEdinosauer Global Moderator Joined: 20 Oct 2006Posts: 6966 Location: porcelain throne
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
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
ballaswaroop New User Joined: 20 Sep 2005Posts: 25
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
Pandora-Box Global Moderator Joined: 07 Sep 2006Posts: 1592 Location: Andromeda Galaxy
Phew Syncsort question not on DFSORT forum
Back to top
enrico-sorichetti Superior Member Joined: 14 Mar 2007Posts: 10879 Location: italy
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
Anuj Dhawan Superior Member Joined: 22 Apr 2006Posts: 6248 Location: Mumbai, India
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
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
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
Anuj Dhawan Superior Member Joined: 22 Apr 2006Posts: 6248 Location: Mumbai, India
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:
2. I plotted a time-bomb, will explode in Jan. I should have created symbols using some DATE function of sort...
Removing the egg from face ...slowly.
PS.: And you could call me Anuj, that salutation sounded too rude. Specially when we "know" each other... .
Back to top
Please enable JavaScript!