Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Creating Objects and Values →  VALUE - Value Operator →  VALUE - Initial Value for All Types 

Value Operator, Type Inference

This example demonstrates a type inference for the value operator VALUE.

Other versions: 7.31 | 7.40 | 7.54

Source Code

    demo=>meth1( p = VALUE #(  ) ).
    cl_demo_output=>line( ).

   "demo=>meth2( p = value #(  ) ). "not possible
    cl_demo_output=>line( ).

    demo=>meth3( p = VALUE #(  ) ) ##type.
    cl_demo_output=>display( ).

Description

Passes constructor expressions with the value operator VALUE for initial values to differently typed formal parameters of methods.

  • Fully typed formal parameter
When the method meth1 is called with a fully typed formal parameter, the operand type for # is identified using this parameter and the result of the value operator is an initial field of type c with length 10.
  • Formal parameter typed generically with c
No call is possible here, since there is no inference rule for the generic type c.
  • Formal parameter typed generically with csequence
In accordance with the inference rule for csequence, the result of the value operator is an initial field of type string. This is indicated by a syntax check warning.