Ansicht
Dokumentation

ABENCORRESPONDING_CONSTR_MAPPING - CORRESPONDING CONSTR MAPPING

ABENCORRESPONDING_CONSTR_MAPPING - CORRESPONDING CONSTR MAPPING

ABAP Short Reference   PERFORM Short Reference  
This documentation is copyright by SAP AG.
SAP E-Book

CORRESPONDING, mapping

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


Additions

1. ... MAPPING  t1 = s1 $[duplicates$] t2 = s2 $[duplicates$] ...

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 behind MAPPING.

Notes

  • When using the basic form with a mapping rule, assignments can currently only be made to the same structure or internal table specified as an argument if this is known statically. The information need to create the necessary temporary copy of the target object is missing at runtime and a runtime error occurs.
  • The system class CL_ABAP_CORRESPONDING is used for assignments between structures or internal tables with a dynamic mapping rule.

Addition 1

... MAPPING  t1 = s1 $[duplicates$] t2 = s2 $[duplicates$] ...

Effect

Behind MAPPING, the components s1, s2,... of a source structure or source table are assigned to the components of a target structure or target table t1, t2, .... in mapping relationships.

If the components specified on the left and right of an equal sign of a mapping relationship are themselves structured or tabular with a structured line type, a separate mapping rule can be nested for them. Here, the mapping relationship is set in parentheses ( ... ) and a further mapping rule MAPPING ... and/or EXCEPT ... is specified behind 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.

If the components specified to the left and right of an equal sign of a mapping relationship are tabular, the addition duplicates can be used to control the behavior used when duplicate lines appear in target tables with unique table keys.

A component of a target object cannot occur more than once in a list behind MAPPING and the structure component selector cannot be used to access subcomponents. This is allowed for components of the source object. If MAPPING is used, the table types involved must also have structured line types in the basic form and the addition DEEP is set implicitly.

  • In the basic form, t1, t2, ... are components of the target type and s1, s2, ... are components of the parameter struct or itab.
  • In the variant with lookup table, t1, t2, ... are columns of the parameter itab and s1, s2, ... are columns of the parameter lookup_tab.

The content of the component specified on the right side of an equal 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 listed 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 listed on the right and left side of the equal sign of a mapping relationship. This is a good idea in the following cases:

  • If the variant with lookup table 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 listed in a mapping relationship if a nested mapping rule is to be specified for these components.
  • Identically named tabular components can be listed in a mapping relationship to control the behavior of duplicate lines using duplicates.

If the line type of a source table is elementary, the pseudo component table_line can be specified as a component on the right of an equal sign of a mapping relationship and the entire table line is mapped to the target component. In all other cases, the behavior is undefined when the pseudo component table_line is specified.

Assignment of the components of the structure struct1 to the components of the structure struct2 using mapping rules for the components at the top level and the components of the substructure.

Example

Specification of the pseudo component table_line as the right side of a mapping rule. The content of the table lines of an internal table of type itab1 are copied to column col1 of an internal table of type itab2.

Addition 2

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

Effect

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

  • If explicit components t1, t2, ... are listed, these components of the result are not assigned content and remain initial.
  • If an asterisk, *, is specified, all components of the result remain 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 also not allowed in the list behind EXCEPT either.

If components of the target structure are included using INCLUDE TYPE$|STRUCTURE and these components are assigned a name using AS, this name can be specified behind EXCEPT. In that case, all the components of the included structure are handled as if they had been specified explicitly in the EXCEPT list and are not assigned content.

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.

Example

Effect of the addition EXCEPT. In struct3, the components col2 and col3 remain initial.






ROGBILLS - Synchronize billing plans   BAL_S_LOG - Application Log: Log header data  
This documentation is copyright by SAP AG.

Length: 10534 Date: 20240418 Time: 151657     sap01-206 ( 151 ms )