Ansicht
Dokumentation

ABENCONSTRUCTOR_EXPRESSIONS - CONSTRUCTOR EXPRESSIONS

ABENCONSTRUCTOR_EXPRESSIONS - CONSTRUCTOR EXPRESSIONS

rdisp/max_wprun_time - Maximum work process run time   Addresses (Business Address Services)  
This documentation is copyright by SAP AG.
SAP E-Book

Constructor Operators for Constructor Expressions

... NEW$| VALUE$| CONV$| CORRESPONDING$| CAST$| REF$| EXACT$| REDUCE$| FILTER$| COND$|SWITCH
     type( ... ) ...


Effect

A constructor expression consists of the following:

  • A data type or object type type that matches the operator and that can be derived implicitly from the operand position using the specification #
  • Type-specific parameters specified in parentheses

Each constructor expression creates a result whose data type is determined by the specified type. The parameters specified in parentheses are used to pass input values. The following constructor operators exist:

  • The instance operator NEW is used to create objects in operand positions. The result is a reference variable of the static type type that points to the created object. The input values determine the content of the created object.
  • The value operator VALUE is used to fill complex data objects with values in operand positions, create initial values of any data type, or control the result of table expressions. The result is a data object of the specified type type. The input values determine the content of the result.
  • The conversion operator CONV is used for conversions between data types in operand positions. The result is a data object of the specified type type produced by the conversion from an input value.
  • The casting operator CAST is used for downcasts of reference variables in operand positions. The result is a reference variable of the static type type produced by the assignment from an input value.
  • The component operator CORRESPONDING is used to construct a structure or an internal table in an operand position. The result is a structure or internal table whose components are filled with values from identically named components or components of a parameter specified using a mapping rule.
  • The reduction operator REDUCE constructs a value from conditional iterations or from table iterations.
  • The filter operator FILTER constructs an internal table by filtering the lines of an internal table.
  • The conditional operators COND and SWITCH are used to create values or raise class-based exceptions in operand positions in accordance with conditions. The result depends on any logical expressions or on a case distinction.

A constructor expression can be specified in general expression positions and functional positions with an appropriate operand type. The result is used as an operand here. In a calculation expression or relational expression, the specified type type is used in the calculation type or comparison type. An expression with the operator VALUE that is not used to create an initial value cannot be specified directly in an arithmetic expression because it never matches the operand type here. Expressions with the operators NEW and CAST can be positioned directly in front of the object component selector -> and can occur in chainings.

Data types and classes that are visible and usable in the current operand position can be specified for type. This includes the built-in ABAP types, types defined using TYPES, types from the ABAP Dictionary, and both local and global classes. If the operand type is not unique and is not known completely, if possible, a type inference is performed to determine a data type. This is described in each constructor expression.

LET expressions can be used to define local helper fields in all suitable constructor expressions.

Notes

  • Constructor operators can be classified as follows:
  • Constructor operators like NEW and VALUE construct new values, for which components are passed except when the initial value is created, whereas constructor operators like CONV, CAST, REF, and EXACT convert a single passed value.

  • Constructor operators like NEW, CAST, and REF always return reference variables, whereas constructor operators like VALUE, CONV, and EXACT return all types of data objects.

  • If a data type from ABAP Dictionary is used for the type, the result of a constructor is given its semantic attributes.
  • A calculation expression does not determine the type of its operands. If constructor expressions are used as operands of calculation expressions, the # character can only be specified for type if the type can be determined from the constructor expression itself.

Filling of an internal table itab with the value operator VALUE. The data type is inferred from the left side of the assignment.






rdisp/max_wprun_time - Maximum work process run time   BAL Application Log Documentation  
This documentation is copyright by SAP AG.

Length: 10247 Date: 20240426 Time: 165258     sap01-206 ( 135 ms )