Ansicht
Dokumentation

ABENVALUE_CONSTRUCTOR_PARAMS_STRUC - VALUE CONSTRUCTOR PARAMS STRUC

ABENVALUE_CONSTRUCTOR_PARAMS_STRUC - VALUE CONSTRUCTOR PARAMS STRUC

RFUMSV00 - Advance Return for Tax on Sales/Purchases   ROGBILLS - Synchronize billing plans  
This documentation is copyright by SAP AG.
SAP E-Book

VALUE, Structures

... VALUE dtype$|#( $[let_exp$]
                   $[BASE dobj$]
                   comp1 = dobj1 comp2 = dobj2 ... ) ...


Effect

If dtype is a structured data type or # stands for 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 that has 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 corresponding assignment rules.

An addition BASE can be specified in front of the individual component assignments, followed by a data object dobj. dobj is a functional operand position. The type of dobj must be convertible to the type of the return value. If BASE is specified, the content of dobj is assigned to the return value before the individual components are assigned. If the character # is specified for the type of the return value and the type cannot be determined from the operand position of the VALUE expression, the type of dobj is used for this expression if it is known and structured.

dobj1, dobj2, ... are general expression positions. An optional LET expression let_exp can be specified in front of the assignments to define local helper fields that can be used on the right side of the assignments.

If a component is structured itself, either a suitable data object can be assigned to the entire substructure or its components can be listed individually using the structure component selector (-). Non-specified components are ignored and keep their type-specific initial value or the value assigned using BASE. If the addition BASE is used, at least one component must also be specified.

If the VALUE operator is used as the source of an assignment to a structure, this structure is first initialized after any LET expressions are evaluated or the structure is first assigned the data object dobj after BASE. The assignments are then executed directly in the parentheses, with the structure components as target fields.

It is not possible to assign multiple values to a component, if the component is addressed by the same name. In structures that contain component groups the respective components can be addressed as usual as components of the including structures or by using the name of the component group. Then, a component might be assigned more than one value and the latest assignment is considered.

Notes

  • The assignments can be specified in any order in the parentheses after the optional additions LET ... IN and BASE, in any order.
  • If a component with a complex data type is to be constructed in an argument position, the value operator VALUE can be used again. Tabular components, for example, are affected by this. This is also possible for structured components, but not necessary since the subcomponents can be addressed using the structure component selector.
  • The rule that a target structure of an assignment is first completely overwritten and then processed directly can produce surprising results if structure components on the left side are specified as data objects to be assigned on the right side. The assignments on the right are not evaluated and assigned first, but the current value is used for each assignment. If the entire structure or structure components on the left side are needed on the right side, however, they can be saved in local helper variables using a LET expression, since this expression is evaluated first.
  • If the target table is specified as dobj after BASE in an assignment to an existing structure, no assignment takes place before the component assignments are evaluated, and the target structure just keeps its value instead.

Three different ways of filling a nested structure struct with values. The structure is given the same values each time.

Example

This example shows the effects that occur when components of a target structure are used as assignment sources. After the assignment to struct1, 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. The assignment to struct2 demonstrates how the behavior can be changed by saving the target object to a helper variable x and using it. In struct2, the original values of col1 and col2 are switched and col3 is given the original value of col4.

Example

Use of BASE. The type of the return value of base1 is transferred in the construction of struct1. This is not possible in the construction of struct2, since base2 is not structured. In both results, col1 and col3 have the values xx or zz assigned using BASE, whereas col2 has the directly assigned value BB.

Use of BASE with a CORRESPONDING expression for an assignment between two incompatible structures. struct1 is first assigned only the identically named components of struct2 and then the remaining components are explicitly supplied. The same can be done for the columns of an internal table by performing an appropriate assignment within an iteration using FOR.

Constructing a structure with component groups. All VALUE operators have the same effect.

Examples

See also the examples for the instance operator NEW.






Addresses (Business Address Services)   TXBHW - Original Tax Base Amount in Local Currency  
This documentation is copyright by SAP AG.

Length: 7474 Date: 20240329 Time: 095430     sap01-206 ( 153 ms )