For those who don't have/know/use MPEX....
If you just want to schedule the job for end-of-month, you can always :STREAM
WHATEVER; DAY=-1
Otherwise, you can build a job with whatever you want in it, using command
files with the echo command. (examples on request)
You can use the following command file to set variables for the last day of
the current month, or the last day of whatever month you pass it (assuming
that I didn't mess anything up when I adapted the logic from the command-file
on jazz that would tell you if today was the last day :)
option nolist
parm CCYYMMDD = '!HPYYYYMMDD'
setvar EOM_INPUT '!CCYYMMDD'
if (len(EOM_INPUT) <> 8) or (not numeric(EOM_INPUT))
echo Must enter an 8-digit date (CCYYMMDD format)
return
endif
setvar EOM_YYYY str(EOM_INPUT,1,4)
setvar EOM_YEAR !EOM_YYYY
setvar EOM_MM str(EOM_INPUT,5,2)
setvar EOM_MONTH !EOM_MM
if EOM_MM > "12"
echo Month can't be more than 12
return
endif
if ( EOM_MONTH = 2 and EOM_YEAR mod 4 = 0 ) &
and ( EOM_YEAR mod 100 <> 0 or EOM_YEAR mod 400 = 0 )
setvar EOM_DD '29'
else
setvar EOM_DD &
word("31,28,31,30,31,30,31,31,30,31,30,31",,EOM_MONTH)
endif
setvar EOM_DAY !EOM_DD
setvar EOM_CCYYMMDD EOM_YYYY+EOM_MM+EOM_DD
setvar EOM_DATE !EOM_CCYYMMDD
return
#
# Command-file to set a bunch of 'EOM@' variables to the
# last day of a month.
#
# Input an 8-character date, CCYYMMDD format, like
# HPYYYYMMDD. Optional, defaults to current date.
# Note: the last 2 digits (for the day) can be invalid
# days like '00' or '99'.
#
# Output 'EOM_@' variables, like
# EOM_CCYYMMDD (string) EOM_DATE (numeric equivalent)
# EOM_DD (2-digit string) EOM_DAY (numeric equivalent)
# etc.
Dave ("once had to do without MPEX and never comfy depending on it since")
Powell, MMfab
----- Original Message -----
From: "Johnson, Tracy" <[log in to unmask]>
To: <[log in to unmask]>
Sent: Thursday, November 04, 2004 06:55
Subject: [HP3000-L] MPEX Feature of the Day - Last Day of The Month
This is one of those things discovered when
trying to find a solution to an old problem.
Putting the Last Day of Last Month automatically
into a job stream parameter. Our site puts
variables into job streams all the time.
It was calculating this one variable that was
difficult.
I spent a hour or so perusing VESoft Expressions
section of the MPEX manual.* And played around
with the DATEBUILD function to no success.
Finally I take a look at the DATEADD function,
and get the proverbial "light-bulb" of Eureka,
and get what I need with two SETVARs just
prior to the JOB card:
::SETVAR EOM DATEADD(TODAY,0,0,-!HPDATE)
::SETVAR EOMSTR CDATE(!EOM,"MMDDYY")
!JOB ...
...
{EOMSTR}
...
!EOJ
If you wanted the last day of the current
month you could use DATEADD(TODAY,0,1,-!HPDATE)
Although it may go wrong if the you're already
on the last day, and the next month has less
days than the current month. Given it was
an MPS calculation and not an GL program, it
may be livable a few days out of the year.
(It could easily be fixed with a few ::IF
statements.)
- - - - - - -
* (Sorry VESoft, the online help is a neat
feature, and there is a Windows help file out
there, there is nothing like flipping through
an actual paper manual when trying to find
something. Those of you that have paper
versions, hoard them like gold. I'm sure
there is a method of printing it in the
online help section, although getting it to a
printer double-sided in the notebook's 6" x
8.5" paper, which is something between A5 and
Foolscap Quarto, is a bit difficult. If
VESoft had stayed with the original US-A
notebook size of over 15 years ago. Then I
could update a regular manual by printing it.)
BT
Tracy Johnson
MSI Schaevitz Sensors
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|