Ansicht
Dokumentation

ABENCOND_TYPE_INFERENCE_ABEXA - COND TYPE INFERENCE ABEXA

ABENCOND_TYPE_INFERENCE_ABEXA - COND TYPE INFERENCE ABEXA

Addresses (Business Address Services)   PERFORM Short Reference  
This documentation is copyright by SAP AG.
SAP E-Book

Conditional Operator, Type Inference

This example demonstrates a type inference for the conversion operator COND.

Source Code

Execute

Description

Constructor expressions with the conditional operator COND are passed to differently typed formal parameters of methods. In the case of generic formal parameters, special rules apply when determining the operand type. Replacing the conditional operator COND with SWITCH produces the same results.

  • 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 the result of the conditional expression is converted to c with length 10 in all three calls.
  • Formal parameter typed generically with c
The operand type for # is determined from the data type of the operand after THEN.
  • In the first call, the type c with length 20 of the operand after THEN matches the generic type and is used.

  • In the second call, the type i of the operand after THEN does not match the generic type and the call is not possible.

  • In the third call, no type can be derived from the generically typed field symbol <fs> after THEN. No call is possible here, since there is no inference rule for the generic type c.

  • Formal parameter typed generically with csequence
  • In the first call, the type c with length 20 of the operand after THEN matches the generic type and is used.

  • In the second call, the type i of the operand after THEN 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 is derived from the generically typed field symbol <fs> after THEN and the type string is used, which is indicated by a syntax check warning.






Vendor Master (General Section)   ROGBILLS - Synchronize billing plans  
This documentation is copyright by SAP AG.

Length: 2928 Date: 20240423 Time: 202854     sap01-206 ( 44 ms )