SAP EQUALS RETURN VALUES



Get Example source ABAP code based on a different SAP table
  


• = ABAP_RETURN_VALUE

=, Assign Return Values and Results

ABAP_SYNTAX
destination = meth( ) $| func( ) $| constr_expr $| table_expr.

What does it do?
If one of the following calls or expressions is specified on the right side of the assignment operator =, their return value or result is determined and assigned to the left side, destination. If necessary, type-dependent conversions are performed in accordance with the conversion rules. The following items are possible on the right side:
A functional method call meth( ) including method chainings. The return value of a function method or an attribute addressed using a method chaining always has a complete type that must match the type of the left side.
A built-in function func( ). The type of the return value, which can depend on the data type of the argument in some numeric functions, must match the type of the left side.
A constructor expression constr_expr. The type of the result is determined by the type specified for the constructor expression and must match the type of the left side.
A table expression table_expr. The type of the result must match the type on the left side.
The following can be specified for destination:
A variable that is compatible with the return value or result, or in whose type the return value or result can be converted.
An inline declaration DATA(var) or FINAL(var). The data type of the declared variable var is the statically known type of the return value or result. If an offset/length specification is applied to the result of a chaining where a constructor expression or a table expression is involved, the data type of the declared variable is the data type of the result in its full length and not in the length of the substring.



Latest notes:

If an arithmetic expression is specified as an argument for one of the overloaded numeric functions, the function itself works like an arithmetic expression and its assignment is one of the assignments of arithmetic expressions, which can cause a different order of conversions.
BEGIN_SECTION SAP_INTERNAL_HINT
If on the right side a single functional method call is given that is included by parentheses, the parentheses are ignored and the right side is not handled like an arithmetic expression.
END_SECTION SAP_INTERNAL_HINT
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
Assignment of the return value of a method to an internal table declared inline. METHOD m1.
DATA(itab) = m2( ).
...
ENDMETHOD.
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
The example shows different results when assigning offset/length specifications to inline declarations. The first offset/length specification is directly applied to a data object and the resulting data object has type n of length 2. The second offset/length specification is applied to the result of a constructor expression and the resulting data object has type n of length 8. The last output shows that the data type of the substring is used at runtime when passed to a method.
ABEXA 01480
ABAP_EXAMPLE_END