Get Example source ABAP code based on a different SAP table
Functions and Expressions as Actual Parameters Functions and expressions> can be specified as actual parameters in the following formal parameters:
Write Positions
Output parameters>, input/output parameters>, and return values> in method calls>.
Read Positions
Input parameters> of methods> in method calls>, when objects are created>, or when exceptions are raised using RAISE EXCEPTION>> or THROW>> in a conditional exception>
Input parameters> of function modules> for all variants of the statement CALL FUNCTION>>. The parameters are evaluated from left to right (and from inside to outside) and the procedure is executed. A parameter cannot be affected by the method itself but by the evaluation of a preceding expression. This applies in particular to writable expressions > in result positions>. Special rules apply to typing checks, identifying the calculation type, and parameter passes. ITOC
Latest notes:
In the case of dynamic method calls>, the same rules apply as to static method calls. However, handling at runtime is time-consuming. Therefore, helper variables should be used in a dynamic call instead of functions or expressions if possible. Function module calls are always dynamic and, compared to method calls, fewer rules apply. NON_V5_HINTS
A system field> should never be used an actual parameter >. ABAP_HINT_END
Checking Typing
A numeric function>, a description function>, or an arithmetic expression> can
be bound to any numeric or any input parameter typed using the type any> in a method call.
be bound to any appropriately typed input parameter in a function module call.
A bit function> or a bit expression> can
be bound to any byte-like or general typed input parameter in a method call.
be passed to input parameters of type x> or a generic type including x> in function module calls.
A string function> or a string expression> can
be bound to any character-like or general typed input parameter in a method call.
be passed to input parameters of type string> or a generic type including string> in function module calls.
A constructor expression> can
be passed to every input parameter that matches the specified type type>> of the constructor expression in method calls. In this case, with the exception of conversion operator CONV>> in the constructor expression, the #> character can only be specified for type> if the input parameter is typed completely and this type is used.
be passed to every input parameter that matches the specified type type>> of the constructor expression in function module calls. The character #> cannot be specified for type> in the constructor expression since no static derivations of types are possible in function module calls.
A table expression> can
be passed in method or function calls to every input parameter that matches the type of the result.
Latest notes:
In function module calls, the typing is not checked until runtime.
No arithmetic expressions, description functions, or numeric functions can be passed to formal parameters with the generic type data>>. This restriction can be bypassed using the conversion operator> CONV>> on the actual parameter. This restriction does not apply to the generic type any>. NON_V5_HINTS ABAP_HINT_END
Calculation Type and Calculation Length If calculation expressions are specified as actual parameters, the calculation type and calculation length are determined as follows:
The calculation type> of an arithmetic expression is determined
in method calls from the operands of the expression and the typing of the input parameter, if this parameter is completely typed. If the input parameter is typed generically, only the operands of the expression are evaluated.
in function module calls from the operands of the expression. The typing of the input parameter is ignored.
The calculation length> of a bit expression is the length of the largest operand of the expression.
Passing Parameters When binding a function, a calculation expression, a constructor expression, or a table expression, the parameters are always passed by value>, even if the formal parameter is defined as to be passed by reference>.
Complete Typing The return value of a function or the result of a calculation expression, a constructor expression, or a table expression is converted>, if necessary, to the type of the input parameter and passed.
Generic Typing
In a function, a constructor expression, or a table expression, the formal parameter inherits the type of the return value or result. Only bit functions are handled like bit expressions (see below).
With an arithmetic expression, the formal parameter inherits the calculation type determined by the operand. If the calculation type is p>, the length is always 16. The number of decimal places is determined by the accuracy required for the calculation and therefore depends on the values of the operands.
In a bit expression or a bit function, the formal parameter is set to type x> in the calculation length determined by the operands.
In a string expression, the formal parameter is set to the type string> for completely generic typing or the generic types csquence> clike>. In the case of the types c> and n> with generic length, the length is set to the length of the result of the string expression.
ABAP_EXAMPLE_VX5 The functional method m1> is called twice for each assignment to result>. The first call is executed in an arithmetic expression, which is passed as an actual parameter in the second call. In the first call of each assignment, the formal parameter p1> has type p > of length 16. The number of decimal places is 0 in the first assignment, 14 in the second, and 1 in the third assignment. In the se cond call, the formal parameter p1> has the type decfloat34> in each assignment, because the calculation type of the arithmetic expression is determined by the return value of m1>. ABEXA 01364 ABAP_EXAMPLE_END