Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Procedure head

&pagelevel(4)&pagelevel

The first five lines of the sample procedure above constitute the procedure head. The procedure head begins with the SET-PROCEDURE-OPTIONS command, which contains global definitions of the procedure format and default settings for important procedure attributes; some of these can be modified dynamically by means of the MODIFY-PROCEDURE-OPTIONS command. Specifying IMPLICIT-DECLARATIONS=*NO prevents a variable from being created (unintentionally) merely by assigning it a value. This facilitates the detection of typing errors in variable names.

Declaration of procedure parameters

Procedure parameters are special variables that may be assigned variable values when the procedure is called, e.g. by means of the CALL-PROCEDURE command. The declaration of procedure parameters is part of the procedure head: DECLARE-PARAMETER
commands declare the name, type, default value and type of value transfer of each procedure parameter. If there is more than one DECLARE-PARAMETER command, they must be enclosed in a block starting with a BEGIN-PARAMETER-DECLARATION command and ending with an END-PARAMETER-DECLARATION command.

The sample procedure declares two parameters: FILE and NUMBER-LINES. The latter can accept integer values only (TYPE=*INTEGER); if no current value is supplied with the procedure call, the preset value (INITIAL-VALUE) for this parameter applies (INIT=10). The FILE parameter, on the other hand, must be assigned a character string (TYPE=*STRING) with the procedure call since no INITIAL-VALUE is defined.

The parameter variables can be assigned current values when the procedure is called; this is done by specifying the parameter values (e.g. in the CALL-PROCEDURE command) in the order of the parameter declarations. As an alternative, values can be assigned to parameters via the parameter names, which may be abbreviated as long as the abbreviations are unequivocal:

/CALL-PROCEDURE P.SHOW-TAIL,(FILE=PROTO.L,NUMBER-LINES=20)
/CALL-PROCEDURE P.SHOW-TAIL,(PROTO.L,20)
/CALL-PROCEDURE P.SHOW-TAIL,(N-L=20,F=PROTO.L)
/CALL-PROCEDURE P.SHOW-TAIL,(PROTO.L)

The first three of these commands are equivalents since FILE is the first and NUMBER-LINES the second parameter declared and both F and N-L are valid abbreviations for the parameter names. In the last procedure call, the default value (INITIAL-VALUE) of 10 will apply for NUMBER-LINES since no value is specified for this parameter.

If an error occurs during parameter transfer or during processing of the procedure head, the procedure will not be executed. Such errors can be handled only by the caller and not by the called procedure. This also applies if a procedure parameter is not supplied with any value, neither explicitly via a specification in the procedure call command nor implicitly via a defined INITIAL-VALUE.

No parameter declaration commands are required at all if a procedure does not expect any parameters. The SET-PROCEDURE-OPTIONS command may likewise be omitted if the preset values are to apply. This means that a very simple procedure may have no procedure head at all.