The OPTIONS(*NOPASS) parameter gives us a quick and easy way of making certain parameters optional. There is one major drawback though.
Let's say for example that we also want our IsWorkday procedure to return an optional indicator to the calling procedure to indicate if the date is a weekday or weekend. The procedure now has two optional parameters. Let's say we set up our procedure interface like this:
Because of the limitations of OPTIONS(*NOPASS), if the user wants the procedure to return the error code, the @Weekday parameter MUST also be passed. This forces the user to setup a dummy field for the undesired return value.
A better way to handle this situation is to use the OPTIONS(*OMIT) keyword. This allows users of the procedure to pass the literal value "*OMIT" instead of an actual field. *OMIT may be used on any of the parameters. Parameters following a *OMIT do not also have to be coded with *OMIT.
The *OMIT parameter may be used in conjunction with *NOPASS to indicate that the parameter can be omitted either with the *OMIT literal or by leaving the position empty.
Using the *OMIT and *NOPASS keywords, our procedure interface now looks like this:
The procedure may be called with any of these methods:
Now, with one statement, a user can return three different pieces of information about one date - is it a valid date, is it a weekday, and is it a workday.
Although you can, it doesn't really make sense to code *OMIT on the last parameter.
Determining if a parameter has been *OMIT-ted
If *OMIT has been passed as a parameter, it will be included in the %PARMS built in function. For example:
will set the %PARMS built in function to 3.
The only way to check if *OMIT was passed is to check the memory address of the parameter in question. If the address is set to *NULL, then *OMIT was passed. If both *OMIT and *NOPASS are allowed for a parameter, you should use both %PARMS and %ADDR to check for a valid value. For example:
Send mail to email@example.com
with questions or comments about this web site.
Last Modified: September 07, 2000