*OMIT v/s *NOPASS
In RPGLE, *OMIT and *NOPASS are the two options used to specify the optional parameters for the procedures. It is essential to understand the difference between *OMIT and *NOPASS because knowing which keyword to use for the specific case helps in writing the clean code.
Before we jump on to the key differences, let's have a look at the use of each of the keywords.
*OMIT
By using the *OMIT on the parameter while declaring a procedure, we can make this parameter an optional parameter.
We could either pass the data to this parameter or simply pass '*OMIT' to while calling the procedure.
This procedure can be called in one of the two ways,
- Either by passing the data for the optional parameter.
- Or by passing '*OMIT' to avoid passing this parameter.
*NOPASS
By using the *NOPASS on the parameter while declaring a procedure, we can make this parameter an optional parameter.
We could either pass the data to this parameter or not pass this parameter at all while calling the procedure.
This procedure can be called in one of the two ways,
- Either by passing the data for the optional parameter.
- Or by not passing the parameter at all.
The Difference
There are couple of main differences between using *OMIT and *NOPASS.
- *OMIT can be used on any parameter, whereas *NOPASS can only be used on the last parameter(s) i.e., no mandatory parameter can be declared after *NOPASS is specified.
- *OMIT needs to passed to avoid passing the parameter declared with *OMIT, whereas no parameter needs to be passed when specified using *NOPASS (considering it is the last parameter).
I hope this post has help in understanding what is the use of *OMIT, *NOPASS and the difference.
If you have any Suggestions or Feedback, Please leave a comment below or use Contact Form.
No comments:
Post a Comment