SAP REDUCE TYPE INFERENCE ABEXA



Get Example source ABAP code based on a different SAP table
  



Reduce Operator, Type Inference
This example demonstrates a type inference for the conversion operator REDUCE.

ABAP_SOURCE_CODE
DEMO CL_DEMO_REDUCE_TYPE_INFERENCE

ABAP_DESCRIPTION
Constructor expressions with the conversion operator REDUCE are passed to differently typed formal parameters of methods. In the case of generic formal parameters, special rules apply when determining the operand type.
Completely typed formal parameter When the method meth1 is called with a completely typed formal parameter, the operand type for # is determined by this parameter and the result of the reduction is converted to c with length 10 in both calls.
Formal parameter typed generically with c The operand type for # is determined by the first declaration after INIT.
In the first call, the type c with length 20 of the declaration after INIT matches the generic type and is used.
It is not possible to perform a call with the type i of the declaration after INIT, since it does not match the typing and there are no inference rules for the generic type c.
Formal parameter typed generically with csequence
In the first call, the type c with length 20 of the declaration after INIT matches the generic type and is used.
In the second call, the type i of the declaration after INIT does not match the generic type and the type string is used, which is indicated by a syntax check warning.