Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Assignments →  Value Assignments 

MOVE-CORRESPONDING

Short Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


MOVE-CORRESPONDING [EXACT] struc1 TO struc2. 

Effect

Structures must be specified for struc1 and struc2. struc1 is a functional operand position. The system searches for all components with the same name in struc1 and struc2 and the content of components in struc1 is assigned to the components with the same name in struc2. Other components are not affected.

Nested structures are fully expanded. The names of the components are compared down to the lowest common level. For each component pair with the same name comp, the statement

MOVE [EXACT] struc1-comp TO struc2-comp.

is executed for each component pair comp with the same name. Any associated conversion are performed and the relevant exceptions may be raised. If the addition EXACT is specified for MOVE-CORRESPONDING, it is passed to every single assignment. If an exception is raised, all components are assigned up to the component that raised the exception. This component, and all following components, are not assigned.

Untyped field symbols, field symbols with the generic type ANY, or formal parameters can be used for struc1 und struc2. These must be structures when the statement is executed, otherwise an unhandleable exception is raised.

If struc1 or struc2 are empty customizing includes when the statement is executed (that is they do not contain any components), the statement is ignored. If struc1 is a structure that contains empty customizing includes as components, these are also ignored when the structure is evaluated.


Notes

  • If structures are specified for struc1 and struc2, the names are compared once when the program is generated by the ABAP Compiler. If untyped field symbols or formal parameters are used, the names must be compared each time the statement is executed.
  • The compiler optimizes the MOVE-CORRESPONDING statement so that sequences of components that have the same names in both structures are grouped and copied together. We therefore recommend that you set up the relevant structures in the same way whenever possible.
  • MOVE-CORRESPONDING ignores names that were only defined with the AS name addition of the INCLUDE statement or when structures were integrated into ABAP Dictionary. However, components that were renamed using the RENAMING WITH SUFFIX addition of the INCLUDE statement or similarly in ABAP Dictionary are not ignored.

Example

The structure struc1 contains the components:

  • struc1-comp1
  • struc1-struci-comp1
  • struc1-struci-comp2-col1
  • struc1-struci-comp2-col2

The structure struc2 contains the components:

  • struc2-struci-comp1
  • struc2-struci-comp2
  • struc2-struci-comp3

Over the length of the shorter path, the components struci-comp1 and struci-comp2 have the same name. These are assigned from struc1 to struc2. In struc1, struci-comp2 is self-structured; in struc2, struci-comp2 is elementary. When struc1-struci-comp2 is assigned to struc2-struci-comp2, the source field is documented as an elementary field of type c in accordance with the conversion rules for structures. The components struc1-comp1 and struc2-struci-comp3 do not have any equivalents with the same name and are not taken into account in the assignment.

DATA: BEGIN OF struc1, 
        comp1 TYPE c LENGTH 1 VALUE 'U', 
        BEGIN OF struci, 
          comp1 TYPE c LENGTH 1 VALUE 'V', 
          BEGIN OF comp2, 
            col1 TYPE c LENGTH 1 VALUE 'X', 
            col2 TYPE c LENGTH 1 VALUE 'Y', 
          END OF comp2, 
        END OF struci, 
     END OF struc1. 

DATA: BEGIN OF struc2, 
        BEGIN OF struci, 
          comp1 TYPE string, 
          comp2 TYPE string, 
          comp3 TYPE string, 
        END OF struci, 
     END OF struc2. 

MOVE-CORRESPONDING struc1 TO struc2. 

Non-Catchable Exceptions

  • Cause: One of the operands is not a structure.
    Runtime Error: OBJECT_NOT_STRUCTURED:
  • Otherwise, the same runtime errors can occur as for MOVE.