SAP CORRESPONDING USING ABEXA



Get Example source ABAP code based on a different SAP table
  



Component Operator, Lookup Table
This example demonstrates the component operator with FROM ... USING.

ABAP_SOURCE_CODE
DEMO CL_DEMO_CRRSPNDNG_USING

ABAP_DESCRIPTION
This example joins two internal tables itab and itab2 in a constructor expression with the component operator CORRESPONDING in the variant with lookup table.
The first assignment specifies the conditionb1 = a1 b2 = a2 without a mapping rule after USING. In the lookup_tab, a line is found for the first and third line of itab and its identically named components are assigned to the corresponding line of itab, where b1 and b2 from lookup_tab and a1 and a2 from itab are ignored. The only identically named component remaining is c1. All other components keep their previous value from itab. The second line is transferred unchanged from itab1.
In the second assignment, the default handling is overridden by specifying a mapping rule a1 = a1 a2 = a2 b1 = b1 b2 = b2 c2 = d2 , where a mapping relationship for all components that were ignored until now is listed. Accordingly, the content of all components in the first and third line of itab are modified.
Finally, the third assignment demonstrates the assignment of the expression to an internal table jtab that does not have the type of itab but is compatible with it. The result of the expression is completely assigned to jtab. The pragma ##operator hides the syntax check warning stating that a temporary copy of itab needs to be created.