Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Creating Objects and Values →  VALUE - Value Operator 

VALUE - Initial Value for All Types

Other versions: 7.31 | 7.40 | 7.54

Syntax


... VALUE dtype|#( ) ...

Effect

If no parameters are specified in the parentheses, the return value is set to its type-specific initial value. This is possible for any non-generic data types dtype. The # character can stand for appropriate operand types known statically. When VALUE #( ) is passed to a generically typed formal parameter, the type is also derived from the generic type of this parameter in the following cases:

  • string for csequence and clike
  • xstring for xsequence
  • decfloat34 for numeric and decfloat
  • p with the length 8 and no decimal places if p is generic
  • The standard key for a standard table type with generic primary table key

Other generic data types (except for table types) that are explicitly generic with respect to their secondary table keys cannot be made more concrete and produce a syntax error. More specifically, this applies to the types c, n, and x with generic lengths.


Notes

  • VALUE with pass by value is used only to construct certain complex values (structures and internal tables). VALUE without pass by value, on the other hand, is a general method for creating type-dependent initial values in any operand positions.

  • Rules apply when deriving the type in cases where # is specified for actual parameters that can be passed to generically typed formal parameters. These rules prevent syntax errors in programs that call a procedure and the procedure makes the full typing of a formal parameter type more general by switching to a generic type.

Example

Creates a suitable initial structure for a non-optional input parameter of a method.

CLASS c1 DEFINITION. 
  PUBLIC SECTION. 
    TYPES: BEGIN OF t_struct, 
             col1 TYPE i, 
             col2 TYPE i, 
           END OF t_struct. 
    CLASS-METHODS m1 IMPORTING p TYPE t_struct. 
ENDCLASS. 

CLASS c1 IMPLEMENTATION. 
  METHOD m1. 
    ... 
  ENDMETHOD. 
ENDCLASS. 

START-OF-SELECTION. 

  c1=>m1( VALUE #( ) ).

Executable Example

Value Operator, Type Inference

Continue

Value Operator, Type Inference