Ansicht
Dokumentation

ABENTYPING_ARITH_EXPR - TYPING ARITH EXPR

ABENTYPING_ARITH_EXPR - TYPING ARITH EXPR

RFUMSV00 - Advance Return for Tax on Sales/Purchases   Addresses (Business Address Services)  
This documentation is copyright by SAP AG.
SAP E-Book

Functions and Expressions as Actual Parameters

Functions and expressions can be specified as actual parameters in the following formal parameters:

  • Write Positions

  • Read Positions

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.

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.

Checking Typing

  • 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.

  • 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.

  • 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.

  • 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.

  • be passed in method or function calls to every input parameter that matches the type of the result.

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.

Calculation Type and Calculation Length

If calculation expressions are specified as actual parameters, the calculation type and calculation length are determined as follows:

  • 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.

Example

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 second 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.






General Material Data   ABAP Short Reference  
This documentation is copyright by SAP AG.

Length: 11026 Date: 20240329 Time: 012609     sap01-206 ( 147 ms )