Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Date validate routine

11 views
Skip to first unread message

Gilbert Cardenas

unread,
Nov 10, 2008, 11:12:41 AM11/10/08
to
Does anyone know of a date validation routine that I can look at
to use as an example for a REXX routine I am working on?
A beginning and ending date will be passed to a another utility but I need
to validate the dates to make sure they are valid and that the FROM date
is older than the TO date.
For example :

FROM DATE 110108
TO DATE 113008

Any examples will be appreciated,
Gil.

This e-mail (and any attachments) may contain information that is
confidential and/or protected by law. Any review, use, distribution or
disclosure to anyone other than the
intended recipient(s) is strictly prohibited. If you are not the intended
recipient, please contact the sender by reply email and delete all copies
of this message.

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to LIST...@VM.MARIST.EDU with the message: INFO TSO-REXX

Hamilton, Robert L

unread,
Nov 10, 2008, 11:20:04 AM11/10/08
to
It's probably best to convert to 'B' format to do the comparisons. This
will also check the validity of the values

bobh

Gilbert Cardenas

unread,
Nov 10, 2008, 2:52:20 PM11/10/08
to
Thanks bobh, this is my first time working with dates in a rexx
routine and I have a tendency to spend too much time making an easy task
harder than it has to be so any insight is appreciated.

Gil.

"Hamilton, Robert L" <rob...@UTDALLAS.EDU>
Sent by: TSO REXX Discussion List <TSO-...@VM.MARIST.EDU>
11/10/2008 10:19 AM
Please respond to
TSO REXX Discussion List <TSO-...@VM.MARIST.EDU>


To
TSO-...@VM.MARIST.EDU
cc

Subject
Re: [TSO-REXX] Date validate routine

Pete Hartung

unread,
Nov 10, 2008, 3:42:54 PM11/10/08
to
Here is an example that might give you some ideas

/********************REXX***********************/
Date1 = Translate("Mm/Dd/Yy",'030108',"MmDdYy") /* insert / */
Date2 = Translate("Mm/Dd/Yy",'022908',"MmDdYy") /* insert / */
Call ProcessDates

Date1 = '22/01/07'
Date2 = '02/29/07'
Call ProcessDates

Date1 = '02/01/07'
Date2 = '02/28/07'
Call ProcessDates
Exit 0

ProcessDates:
DateErr = 0
Signal on syntax name Date1Err
Date1B = Date('B',Date1,'U')
RtnDate1:

Signal on syntax name Date2Err
Date2B = Date('B',Date2,'U')
RtnDate2:

Signal off Syntax
If DateErr then Return

If Date2B > Date1B then say 'Date2' Date2 'is greater than Date1' Date1
else say 'Date2' Date2 'is NOT greater than Date1' Date1
Return

Date1Err:
say 'Date1' Date1 'is invalid'
DateErr = 1
Signal RtnDate1

Date2Err:
say 'Date2' Date2 'is invalid'
DateErr = 1
Signal RtnDate2

Gil.


To
TSO-...@VM.MARIST.EDU
cc

bobh

Disclaimer: This e-mail message is intended only for the personal use of
the recipient(s) named above. If you are not an intended recipient, you
may not review, copy or distribute this message. If you have received this
communication in error, please notify us immediately by e-mail and delete
the original message.

This e-mail expresses views only of the sender, which are not to be
attributed to Rite Aid Corporation and may not be copied or distributed
without this statement.

Gilbert Cardenas

unread,
Nov 10, 2008, 5:20:28 PM11/10/08
to
Thanks Pete. We just upgraded to z/OS 1.9 and I got sidetracked
with some issues but I'll try to incorporate your example and give this a
whirl tomorrow.

Thanks again,
Gil.


Pete Hartung <phar...@RITEAID.COM>


Sent by: TSO REXX Discussion List <TSO-...@VM.MARIST.EDU>

11/10/2008 02:43 PM

KIP3News Provinzial-AG

unread,
Nov 11, 2008, 7:17:18 AM11/11/08
to
Gil,

what I do to validate dates is to use the normal Date() function. It is a
little bit tricky, but it works:

000101 UserMSG = ""
000102 Call CheckData
000103 If ErrorField ^= ""
000104 then do
000105 ztdsels = 0
000106 Arguments = "Cursor("ErrorField") CsrRow("CRP")"
000107 end
- - - - - - - - - - - - - - - - - - - 26 Line(s) not
Displayed
000134 /* -----------------------------------------------------------------
*/
000135 /* -- Check Input ---------------------
*/
000136 /* -----------------------------------------------------------------
*/
000137 CheckData:
- - - - - - - - - - - - - - - - - - - 18 Line(s) not
Displayed
000156 Signal on Syntax Name DateError
000157 ErrorField = "ZLCDATE"
000158 Created = DATE('S',zlcdate,'O')
000159 ZLC4Date=
Substr(Created,1,4)"/"substr(Created,5,2)"/"substr(Created,7)
- - - - - - - - - - - - - - - - - - - 52 Line(s) not
Displayed
000211 ErrorField = ""
000212 Return
000213 /* -----------------------------------------------------------------
*/
000214 /* -- Trapped Date - Syntax error ---------------------
*/
000215 /* -----------------------------------------------------------------
*/
000216 DateError:
000217 RetStrS = "Ungültig"
000218 RetStrL = "Datum unplausibel: Unbedingt die Form JJ/MM/TT
beihalten!"
000219 Call SetMessage
000220 Return

In line 102 I call a subroutine to check all data. The Stack for return
will contain the address of line 103.
In the CheckData I will raise Signal on Syntax trap. So in case there is an
error with the date, program flow will continue on 216 DateError
In 220 it will return to the address of the last address on the return
stack (i.e. line 103).
In case there is no error program will return on line 212 Return.

So no need to write your own date checking routine. Rexx will do it for
you.

Hope this helps...

Regards
Heinz-Bernd

--
Provinzial Rheinland AG
Sender: Heinz-Bernd Leifeld
ETS: C00 / PEP 3
D-40195 Düsseldorf



Gilbert Cardenas
<GilbertCardenas@
GROCERYBIZ.COM> An
Gesendet von: TSO TSO-...@VM.MARIST.EDU
REXX Discussion Kopie
List
<TSO-...@VM.MARI Thema
ST.EDU> [TSO-REXX] Date validate routine


10.11.2008 17:12


Bitte antworten
an
TSO REXX
Discussion List
<TSO-...@VM.MARI
ST.EDU>

Gilbert Cardenas

unread,
Nov 11, 2008, 12:12:46 PM11/11/08
to
Pete, this works great. Makes lots a sense for someone just starting to
work with dates.

Thanks a lot,
Gil.


Pete Hartung <phar...@RITEAID.COM>


Sent by: TSO REXX Discussion List <TSO-...@VM.MARIST.EDU>

11/10/2008 02:43 PM

Gilbert Cardenas

unread,
Nov 11, 2008, 2:17:40 PM11/11/08
to
Thanks for the function code Heinz-Bernd. Between Pete and your
examples, I have now a better grasp on the date routines.

I certainly appreciate your helping me on this.
Gil.

KIP3News Provinzial-AG <kip3...@PROVINZIAL.COM>

Sent by: TSO REXX Discussion List <TSO-...@VM.MARIST.EDU>

11/11/2008 06:17 AM


Please respond to
TSO REXX Discussion List <TSO-...@VM.MARIST.EDU>


To
TSO-...@VM.MARIST.EDU
cc

Subject
Re: [TSO-REXX] Date validate routine

Scott Gonyea

unread,
Nov 11, 2008, 7:48:42 PM11/11/08
to
Hi everyone,

This is my first e-mail to this list--I decided to write this while
suicide prevention has me hold. I've been digging through Rexx reference
materials and Google with no success. I am attempting to call a program
("MGCKLST"). The programs expects there to be a FILE name of "MGCPRINT"
where it will place its output. I was informed by the company that wrote
this program that I could catch the output with OUTTRAP() if I am
associating that FILE with sysout, yet that doesn't seem to be the case.

Here's my code with some further explanation after:

/**********************************************************************/
/* */
/* Trap the output from the RACF SEARCH command into mgcklst. array. */
/* */
x = OUTTRAP('mgcklst.')
Address TSO "SEARCH ALL CLASS(FACILITY) FILTER(MGCKEYS.*.**)"
x = OUTTRAP('OFF')

/* Allocate MGCPRINT. MGCK will print its key output to the sysout */
/* */
Address TSO "ALLOC F(MGCPRINT) DA(*)"

/* Cycle through the list of General Resources that RACF search has */
/* returned and tell MGCK (MGCKLST) to list each key's data. */
/* */
x = OUTTRAP('mprint.')

DO i = 1 TO mgcklst.0
Address LINKMVS "MGCKLST" mgcklst.i
END

x = OUTTRAP('OFF')
/**********************************************************************/


So the "mprint." stem is empty and all of the junk from the MGCKLST
program ends up on my screen anyway. I am thoroughly frustrated and I'm
sending the company an e-mail as well... But I figure I'll try to get some
input from you folks while I'm at it.

One way that I can get around this is to allocate MGCPRINT to a dataset,
although that's a much less appealing solution.

Is there a way to pipe whatever goes to MGCPRINT back into REXX? Perhaps
the output can be placed on the stack, rather than the sysout? Or maybe
there's an alternative to OUTTRAP that will catch "more" data?


Yours,
Scott Gonyea
Enterprise Information Security Office
(310) 972-4495


The information contained in this electronic message and any attachments
to this message is intended for the exclusive use of the addressee(s) and
may contain confidential or privileged information. If you are not the
intended recipient, please notify the sender at American Honda Motor Co.,
Inc. or scott_...@ahm.honda.com immediately and destroy all copies of
this message and any attachments.

John McKown

unread,
Nov 11, 2008, 10:37:21 PM11/11/08
to
On Tue, 11 Nov 2008, Scott Gonyea wrote:

> Hi everyone,
>
> This is my first e-mail to this list--I decided to write this while
> suicide prevention has me hold. I've been digging through Rexx reference
> materials and Google with no success. I am attempting to call a program
> ("MGCKLST"). The programs expects there to be a FILE name of "MGCPRINT"
> where it will place its output. I was informed by the company that wrote
> this program that I could catch the output with OUTTRAP() if I am
> associating that FILE with sysout, yet that doesn't seem to be the case.

OUTTRAP can only trap output that is written via the PUTLINE or PUTGET
service. If the program opens a DCB and writes to it, then I don't think
it can be trapped. However, as a fast test, try

ALLOC DDN(MGCPRINT) DSN(*)

which directs MGCPRINT to your TSO terminal. See if you can OUTTRAP that.
I'd try, but I'm at home right now and logging into work is a PITA.

<snip>


> Yours,
> Scott Gonyea
> Enterprise Information Security Office
> (310) 972-4495

--
Q: What do theoretical physicists drink beer from?
A: Ein Stein.

Maranatha!
John McKown

John McKown

unread,
Nov 11, 2008, 10:51:25 PM11/11/08
to
Well, I tried the DSN(*) method. That got the output to the terminal, but
I couldn't OUTTRAP() it.

Now, I can think of a possibility that I've used. However, it is weird and
only works for a small amount of data. Use the SYSCALLS environment. That
allows use of UNIX services. Create a named pipe with a unique name in the
/tmp subdirectory. Allocate the MSGPRINT dd statement to that UNIX file.
Run your program. Now use the UNIX REXX "readfile()" function to read all
the lines from that named pipe. Granted, this is similar to writing to a
disk dataset, except that the data is buffered in memory. The problem is
that if you exceed the buffer size, your REXX program will hang for no
apparent reason. Not a good general solution.

--
Q: What do theoretical physicists drink beer from?
A: Ein Stein.

Maranatha!
John McKown

----------------------------------------------------------------------

0 new messages