MOVE-CORRESPONDING

MOVE-CORRESPONDING Syntax Diagram

Effect

Interprets struc1 and struc2 as structures. If, for example, struc1 and struc2 are tables, it executes the statement for their header lines.
Searches for the sub-fields which occur both in struc1 and struc2 and then generates, for all relevant field pairs which correspond to the sub-fields ni , statements of the form

MOVE struc1-ni TO struc2-ni.

The other fields remain unchanged.

With complex structures, the full names of the corresponding field pairs must be identical.


Example

 
DATA: BEGIN OF INT_TABLE OCCURS 10, 
WORD(10),
NUMBER TYPE I,
INDEX LIKE SY-INDEX,
END OF INT_TABLE,
BEGIN OF RECORD,
NAME(10) VALUE 'not WORD',
NUMBER TYPE I,
INDEX(20),
END OF RECORD.
...
MOVE-CORRESPONDING INT_TABLE TO RECORD.

This MOVE-CORRESPONDING statement is equivalent to both the following statements:

 
MOVE INT_TABLE-NUMBER TO RECORD-NUMBER. 
MOVE INT_TABLE-INDEX TO RECORD-INDEX.

Example

 
TYPES: BEGIN OF ROW1_3, 
CO1 TYPE I,
CO2 TYPE I,
CO3 TYPE I,
END OF ROW1_3.
TYPES: BEGIN OF ROW2_4,
CO2 TYPE I,
CO3 TYPE I,
CO4 TYPE I,
END OF ROW2_4.
TYPES: BEGIN OF MATRIX1,
R1 TYPE ROW1_3,
R2 TYPE ROW1_3,
R3 TYPE ROW1_3,
END OF MATRIX1.
TYPES: BEGIN OF MATRIX2,
R2 TYPE ROW2_4,
R3 TYPE ROW2_4,
R4 TYPE ROW2_4,
END OF MATRIX2.
DATA: ROW TYPE ROW1_3,
M1 TYPE MATRIX1,
M2 TYPE MATRIX2.

ROW-CO1 = 1. ROW-CO2 = 2. ROW-CO3 = 3.
MOVE: ROW TO M1-R1, ROW TO M1-R2, ROW TO M1-R3.
MOVE-CORRESPONDING M1 TO M2.

The last MOVE-CORRESPONDING statement is equivalent to the statements:

 
MOVE: M1-R2-CO2 TO M2-R2-CO2, 
M1-R2-CO3 TO M2-R2-CO3,
M1-R3-CO2 TO M2-R3-CO2,
M1-R3-CO3 TO M2-R3-CO3.

Note

This statement assigns values based on pairs of fields with identical names. To avoid unwanted assignments, you should consider all fields of the source and target structures. If either is defined with reference to an ABAP Dictionary type (for example, a database table), remember that any subsequent extension to the type could cause coincidental pairs of identically-named fields, which could lead to incorrect program logic.

Related

MOVE,
ADD-CORRESPONDING,
SUBTRACT-CORRESPONDING ,
MULTIPLY-CORRESPONDING ,
DIVIDE-CORRESPONDING


Additional help



Assigning Values with MOVE