ABAP Keyword Documentation → ABAP - Reference → Program structure → Modularization Statements → Procedures → Parameter Interface of Procedures
Passing Parameters
The example demonstrates the difference between passing a parameter in a procedure by value or by reference.
Other versions: 7.31 | 7.40 | 7.54
Source Code
fill_table( CHANGING g_param = param ).
solve_table( EXPORTING g_param = param ).
Description
Method fibb
calculates the sequence term with number range
of a Fibonacci sequence using the start values x
and y
.
As a rule, the next sequence term is always the total of two previous sequence terms (therefore two
start values). The method takes the parameters, a structured parameter l_line
used to pass the input values, and a parameter r
of type i
used to output the result. Since the parameter l_line
is defined as an
IMPORTING parameter but still has to be changed in the method, the method definition must contain
the keyword value
before the parameter; otherwise a syntax error occurs.
This ensures that within the method a local copy of the parameter is used. The addition value
to the output parameter r
has the effect that the result is assigned to the
static class attribute res
only after the method has been processed completely. Otherwise res
would be changed in each single step of the algorithm.
The internal table param
contains the input values for calculating three
different sequence terms of the Fibonacci sequence. Method fill_table
is
used to fill param
with values, and method solve_table
is used to calculate and output fibb
for each line of param
.