On 11/12/2018 9:21 PM, Jonathan Ball wrote:
Maybe this is general ILE COBOL error handling, I don't know.
I'm trying to replace an inefficient call to an OPM CLP program that
uses CVTDAT to convert a date from *MDY to *YMD. The converted value is *not* used; the purpose of the call is only to see if the date in the parameter is a valid date value.
The calling program is currently OPM CBL, but it could easily be changed
to ILE CBLLE. I want to change the call to another ILE CBLLE program
that basically does the following:
move function convert-date-time
(Date-to-convert Date '%m%d%y')
to Rcv-date
Rcv-date is defined as:
77 Rcv-date format of date '%y%m%d'.
The conversion works great as long as Date-to-convert contains a valid
date in %m%d%y format (mmddyy). I'm *only* interested in calls where
the date is not valid. I want something like this:
move function convert-date-time
(Date-to-convert Date '%m%d%y')
to Rcv-date
on exception
move "Y" to error-sw
not on exception
move "N" to error-sw
end-move.
The MOVE statement doesn't allow the (NOT) ON EXCEPTION feature, so the
code fragment above won't work.
My IBM i COBOL skills are rusty, particularly with respect to ILE COBOL.
What is the easiest/cheapest/dirtiest way to handle the error if the
input date to the function won't convert?
What I'd like is something like an RPGLE MONITOR block:
monitor;
rcv_date = %date(indate:*mdy0);
error_sw = 'N';
on-error;
error_sw = 'Y';
endmon;
I could probably sneak an RPGLE program/module into the mix and get away
with it, but it's largely an IBM i COBOL arena, and I'd prefer to stick
with it.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)