sapdev logo background
sapdev logo sapdev logo
Comments

SAP VALUE CONSTRUCTOR PARAMS STRUC documentation, setup help and example usage



Return to SAP documentation index


ARTICLE

VALUE - Structures

Syntax
... VALUE dtype|#( comp1 = dobj1 comp2 = dobj2 ... ) ...

Effect
If dtype is a structured data type or # represents a type like this, the individual components can be specified as named arguments
comp1 , comp2 , ... Each component of the return value can be assigned a data object with the same data type as the component (or whose data type can be converted to this data type). This assignment is made for all data types in accordance with the appropriate assignment rules . dobj1 , dobj2
, ... are general expression positions .
If a component is itself structured, either a suitable data object can be assigned to the entire substructure or its components can be specified using the structure component selector ( - ).
Any components not specified are ignored and retain their type-specified initial value. It is not possible to assign multiple values to a component, regardless of how the component is addressed.
If the VALUE is used as a source of an assignment to a structure, this is initialized first and the assignments in the parentheses are executed directly (from left to right) with the structure components as target fields

Notes
  • The assignments can be specified in any order within the parentheses.

  • If a component with a complex data type is constructed in an argument position, the value operator VALUE can be used again. This affects tabular components, for example. This is also possible for structured components but is not necessary since the subcomponents can be addressed using the structure component selector.

  • The rule that a target structure of an assignment is initialized and then edited directly can produce unexpected results if structure components on the left side are specified as data objects pending assignment on the right side. Instead of the right side being evaluated and assigned first, the current value is used in every assignment.


  • Example
    Three different ways of filling a nested structure struct with values. The structure is given the same values each time.
    TYPES: BEGIN OF t_col2,
    col1 TYPE i,
    col2 TYPE i,
    END OF t_col2.

    TYPES: BEGIN OF t_struct,
    col1 TYPE i,
    col2 TYPE t_col2,
    END OF t_struct.

    DATA: struct TYPE t_struct,
    col2 TYPE t_col2.

    struct = VALUE t_struct( col1 = 1
    col2-col1 = 1
    col2-col2 = 2 ).

    col2 = VALUE t_col2( col1 = 1
    col2 = 2 ).
    struct = VALUE t_struct( col1 = 1
    col2 = col2 ).

    struct = VALUE t_struct( col1 = 1
    col2 = VALUE #( col1 = 1
    col2 = 2 ) ).
    Example ABAP Coding This example displays the effects produced if components of a target structure are used as assignment sources. After the assignment, col1 and col2 have the value 0 and col3
    and col4 have the value 5. The original values of col1 and col2 are not switched and col3 is not given the original value of col4 .
    DATA:
    BEGIN OF struct,
    col1 TYPE i VALUE 1,
    col2 TYPE i VALUE 2,
    col3 TYPE i VALUE 3,
    col4 TYPE i VALUE 4,
    END OF struct.

    struct = value #( col1 = struct-col2
    col2 = struct-col1
    col4 = 5
    col3 = struct-col4 ).

    Example
    See also the example for NEW
    .
    Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved




    VALUE_CONSTRUCTOR_PARAMS_ITAB
    VALUE_HELP_GLOSRY




    comments powered by Disqus