SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP Programming Guidelines → Robust ABAP → Modularization units →Type of Formal Parameters in Procedures
Background
The parameter interface of a procedure consists of formal parameters and specifies the exceptions possible in the procedure. The possible types of formal parameters are:
The actual behavior of a formal parameter, however, is in part determined by the combination of the parameter type and the transfer type.
Rule
Choose the appropriate formal parameter type
Select a formal parameter type that corresponds to the parameter semantics:
Details
For the user of a procedure, the parameter types provide important information on how they are used in the procedure and leads the user to expect the procedure to behave in a certain way. If you do not select a suitable parameter type, this increases the risk of an inappropriate use.
Input parameters or input/output parameters that are not necessarily required for the execution of a procedure should be defined as optional by using OPTIONAL or by specifying a DEFAULT value. Otherwise, calling programs are forced to pass unnecessary parameters and create helper variables especially for this purpose.
A narrow parameter interface in line with a procedure with an appropriate number of statements only requires a few input parameters and one return value. However, this cannot really be applied consistently in practice and is therefore not set out as a rule here.
Note
Another parameter type are table parameters that can be declared for function modules and subroutines using TABLES. Basically, they have the same effects as input/output parameters for internal tables. This parameter type is obsolete and should no longer be used.
Bad example
The following source code shows a formal parameter that is declared as an output parameter using EXPORTING, but is used in the method like an input/output parameter declared with CHANGING. This does not correspond to the semantics that a calling program expects.
Good example
The following source code corrects the above example by declaring the parameter as an input/output parameter with CHANGING according to its use.