sapdev logo background
sapdev logo sapdev logo
Comments

SAP NEW CONSTRUCTOR PARAMS STRUCT documentation, setup help and example usage



Return to SAP documentation index


ARTICLE

NEW - Structures

Syntax
... NEW 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 new anonymous data object 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 components are addressed.

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. This affects tabular components, for example. This is also possible for structured components but is not necessary sin
    ce the subcomponents can be addressed using the structure component selector.

    Example
    Constructs an anonymous data object with a nested structure type and tabular components. The subcomponents of col2 are addressed directly using the structure component selector. VALUE must be used to construct the tabular component col3 . This is because the syntax used to construct internal tables cannot be specified directly as an argument.
    TYPES: t_itab TYPE TABLE OF i WITH EMPTY KEY,
    BEGIN OF t_struct,
    col1 TYPE i,
    BEGIN OF col2,
    col1 TYPE i,
    col2 TYPE t_itab,
    END OF col2,
    col3 TYPE t_itab,
    END OF t_struct.

    DATA itab TYPE t_itab.

    DATA dref TYPE REF TO data.

    dref = NEW t_struct( col1 = 1
    col2-col1 = 2
    col2-col2 = itab
    col3 = VALUE #( ( 1 )
    ( 2 )
    ( 3 ) ) ).

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




    NEW_CONSTRUCTOR_PARAMS_SINGLE
    NEXT_DYNPRO_GLOSRY




    comments powered by Disqus