Re: exception handling for intrinsic functions

From: Joe Zitzelberger (joe_zitzelberger_at_nospam.com)
Date: 04/16/04


Date: Thu, 15 Apr 2004 18:09:50 -0400

In article <c5m7bn$3dl1p$1@ID-184804.news.uni-berlin.de>,
 "Frank Swarbrick" <Frank.Swarbrick@efirstbank.com> wrote:

> Can someone point me in the right direction to a section of a manual that
> describes how to handle when an intrinsic function is called with invalid
> data. For instance, I do the following:
>
> move "1 23.4" to my-string
> compute my-val = function numval-c(my-string)
>
> This causes an LE COBOL runtime error of:
> "IGZ0152S Invalid character 3 was found in column 5 in argument-1 for
> function NUMVAL-C in program TEST6 at displacement X'0402'. From compile
> unit TEST6 at entry point TEST6 at compile unit offset +00000402 at address
> 0060047A."
>
> I guess my main question is, must I pre-validate my data before calling the
> function or is there some way I can "capture" the run-time error and send a
> sensible error message to my user? If the latter, how (in general) do I do
> it?
>
> I am using IBM COBOL for VSE/ESA, but I'm sure IBM Enterprise COBOL for z/OS
> et al are similar, so answers based on that product would probably be OK.
>
> Thanks!

 
You could use an LE condition handler with a resume point. That is
something of a pain though.

I have found that a state machine that validates the input data to be a
valid numeric works well.