SAP NetWeaver AS ABAP Release 750, ©Copyright 2016 SAP AG. All rights reserved.
ABAP - Keyword Documentation →
ABAP - Reference →
Processing Internal Data →
Assignments →
Assigning Structure Components →
CORRESPONDING - Component Operator →
CORRESPONDING - Basic Form
Syntax
... { CORRESPONDING dtype|#( [DEEP] [BASE ( base )] struct|itab) }
| { CORRESPONDING dtype|#( [BASE ( base )] struct|itab
mapping ) } ...
Addition:
... BASE ( base ) ...
Effect
This expression constructs a result with the target type specified using dtype
or # from the components of a parameter struct or itab struct and itab are
general expression positions.
- If the target type is a structured type, a structure struct must be used
as a parameter. The expression creates a structure of the target type. The target structure is either
initial or is assigned the value of base after the optional addition
BASE as a start value. The target structure is then by default assigned the identically named
components of struct in accordance with the rules of MOVE-CORRESPONDING for structures.
- If the target type is a table type, an internal table itab must be used
as a parameter. The expression creates an internal table of the target type. The target table is either
initial or is assigned the value of base after the optional addition
BASE as a start value. The target table is then by default assigned the identically named columns
of itab in accordance with the rules of
MOVE-CORRESPONDING for internal tables using the addition KEEPING TARGET LINES.
If the addition DEEP is specified, the assignment is made in the same way
as with the addition EXPANDING
NESTED TABLES of the statement MOVE-CORRESPONDING. A mapping rule
mapping can
be used to override the matching name assignment rule of MOVE-CORRESPONDING.
If a mapping rule is specified, the addition DEEP is set implicitly. It is not allowed to be set explicitly.
Notes
- An assignment of structures
-
struct2 = CORRESPONDING #( struct1 ).
-
without the addition BASE is not the same as an assignment
-
MOVE-CORRESPONDING struct1 TO struct2.
-
In MOVE-CORRESPONDING, all not identically named components in struct2
keep their value. If the result of the constructor expression is assigned, however, they are assigned
the value from there. This value is initial for ignored components. This behavior can be overridden using the addition BASE.
- In the case of an assignment of a parameter to the target type and its assignment to a data object
-
dobj = CORRESPONDING type( ... ).
-
the target object is used directly (for optimization reasons) and a temporary version of the expression
is not created and assigned. This is not possible when the target object and parameter are identical
and a mapping rule is used. This enables, for example, the content of two components to be switched.
In cases like this, a temporary copy of the target object must be created and used and an appropriate
syntax warning is produced. This warning can be hidden using a pragma. If this is not detected until
runtime, the information needed to create the necessary temporary copy of the target object is missing and runtime error CORRESPONDING_SELF occurs. See the example
Reflexive Component Assignments.
Examples
See
Addition
... BASE ( base ) ...
Effect
The addition BASE can be used to specify a start value base for the new structure or internal table. base is a
functional operand position in which a database convertible to the target type can be specified.
If the addition BASE is specified, the value of base is assigned to the target structure or target table in accordance with the general
assignment rules before the remainder of the expression is evaluated.
Notes
- Unlike the operators NEW and VALUE, parentheses must be placed around base in CORRESPONDING .
- Unlike the operators NEW and VALUE, the data
type of base is not used in CORRESPONDING to determine a result type specified using #.
- The addition BASE can be used with the component operator to replace
the statement MOVE-CORRESPONDING as follows:
- An assignment of structures
struct2 = CORRESPONDING #( BASE ( struct2 ) struct1 ).
is the same as an assignment
MOVE-CORRESPONDING struct1 TO struct2.
- An assignment of internal tables
itab2 = CORRESPONDING #( BASE ( itab2 ) itab1 ).
is the same as an assignment
MOVE-CORRESPONDING itab1 TO itab2 KEEPING TARGET LINES.