Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Processing Internal Data →  Assignments →  Assigning Components →  CORRESPONDING - Component Operator 

CORRESPONDING - mapping

Other versions: 7.31 | 7.40 | 7.54

Syntax


... [ MAPPING {t1 = s1}|( t1 = s1 mapping ) 
              {t2 = s2}|( t2 = s2 mapping )
              ...  ]
    [ EXCEPT {ti tj ...}|* ] ...

Extras

1. ... MAPPING  t1 = s1 t2 = s2 ...

2. ... EXCEPT  {t1 t2 ...}|*

Effect

Mapping rule for the component operator CORRESPONDING. The optional mapping rule overrides the default assignment of identically named components only. The additions MAPPING and EXCEPT can be used individually or together. EXCEPT must always be specified after MAPPING.


Notes

  • It is best to use the component operator (see the example) for mapping tasks that can be solved using either the component operator or table comprehensions.

  • When using the components of an argument with a mapping rule, assignments can currently only be made to the same structure or internal table specified as an argument if this is statically identifiable. The information need to create the necessary temporary copy of the target object is missing at runtime and a runtime error occurs.

Addition 1

... MAPPING  t1 = s1 t2 = s2 ...

Effect

After MAPPING, t1, t2, ... are used to assign the components s1, s2,... of a source structure or source table in mapping relationships to the components of a target structure or target table. A component of a target object cannot appear more than once in the list after MAPPING and the structure component selector cannot be used to access subcomponents. Neither of these rules apply for components of the source object. If MAPPING is used, the table types involved must also have structured row types when the components of an argument are used and the addition DEEP is set implicitly.

The content of the component specified on the right side of an equals sign in a mapping relationship is assigned to each component specified on the left side. If there is an identically named component in the target structure for a component specified on the right side, it is also assigned content (unless it is specified on the left side of a mapping relationship itself). In elementary components the assignment is made in accordance with the associated assignment rules. In structured and tabular components, the assignment is made in accordance with the rules of MOVE-CORRESPONDING with the addition EXPANDING NESTED TABLES.

Identically named components can also be specified on the right and left side of the equals sign. This is a good idea in the following cases:

  • If the components of two arguments are used, identically named components in a mapping relationship override the rule that the components s1, s2, ... and t1, t2, ... used for searches are not assigned by default.
  • Identically named components must be specified in a mapping relationship if a nested mapping rule is to be specified for these components.

If the components specified on the left and right of an equals sign of a mapping relationship are themselves structured or tabular with a structured row type, a separate mapping rule can be nested for these components. Here, the mapping relationship is set in parentheses ( ... ) and a mapping rule is specified after the mapping relationship in accordance with the same rules as on the top level. The parentheses are not allowed if a nested mapping rule is not used.

Addition 2

... EXCEPT  {t1 t2 ...}|*

Effect

After EXCEPT, components t1, t2, ... of the target structure or target table that are not specified in a preceding mapping relationship or an asterisk, *, can be specified:

  • If explicit components t1, t2, ... are specified, these components of the result are not assigned content and remain initial.
  • If an asterisk, *, is specified, all components of the result are initial that are not specified explicitly in a preceding mapping relationship.

Access to subcomponents of components of the target object using the structure component selector is not allowed in the list after EXCEPT either.


Notes

  • If there are identically named components in the source and target object that are not compatible or convertible, they can be excluded from the assignment using EXCEPT. This avoids syntax errors or runtime errors.

  • If EXCEPT * is specified without preceding mapping relationships, all components of the result remain initial.

Examples

See