All standard function types other than EXCUSRPGM and EXCUSRSRC have an implicit parameter, the return code. The return code is used to inform the calling program of the circumstances under which the called program is exited. The return code is not shown on the Edit Function Parameters panel but is automatically declared in the generated source code as the first parameter.
Therefore, when calling your application program from a menu or a command line you must always specify a parameter for the return code. This parameter must be the first parameter.
For example, when calling a function from a command line:
CALL ABCDEFR ' '
Note: You can also use the Call a Program (Y2CALL) command to call the function. This command is especially useful if the function’s parameter interface is complex or has changed. It determines the parameters, including the return code, required by a function directly from details contained in the model. You can provide values for all input-capable fields and you can reuse these values for subsequent calls.
For more information on the Y2CALL command, see the Command Reference Guide.
You can retrieve or change the value of the return code parameter within the action diagram of a function by referencing the PGM context field *Return Code. This field can be set by CA 2E to one of its defined conditions, such as, *Record not found. The conditions that are supplied for the *Return Code field are:
You can test against any of these supplied conditions or you can add other conditions to the list.
The best way to check for not equal to *NORMAL can be done using a CASE condition with an *OTHERWISE or by using a compound condition.
For example:
-
. .-CASE . -PGM.*Return Code is *NORMAL . Print Customers - Customer * . -*OTHERWISE . Print Customers Credit - Customer * . -ENDCASE ;-
| Copyright © 2011 CA. All rights reserved. | Tell Technical Publications how we can improve this information |