Get Example source ABAP code based on a different SAP table
Conversion Operator, Type Inference This example demonstrates the type inference for the conversion operator CONV>>.
ABAP_SOURCE_CODE DEMO CL_DEMO_CONV_TYPE_INFERENCE
ABAP_DESCRIPTION Constructor expressions with the conversion operator CONV>> 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 using this parameter and in all three calls there is a conversion to c> with length 10, whereby the first conversion is redundant here.
Formal parameter typed generically with c> The operand type for #> is determined from the argument.
In the first call, the type c> with length 20 of the argument matches the generic type and is used, which is why this conversion is redundant.
In the second call, the type i> does not match the generic type and the type c> with the predefined output length> 11 of i> is used.
Calls with the generically typed field symbol <(><)>> are not possible, since no type can be derived from the argument.
Formal parameter typed generically with csequence>
In the first call, the type c> with length 20 of the argument matches the generic type and is used, which is why this conversion is redundant.
In the second call, the type i> does not match the generic type and the type string> is used, which is indicated by a syntax check warning.
In the third call, no type can be determined from the generically typed field symbol <(><)>> and the type string> is used, which is indicated by a syntax check warning.