SAP CL ABAP CORRESPONDING 3



Get Example source ABAP code based on a different SAP table
  



CL_ABAP_CORRESPONDING, Assignment of Values
The method CREATE_WITH_VALUE of the system class CL_ABAP_CORRESPONDING has essentially the same function as the method CREATE. Additionally, the values of any data objects can be assigned to the components of the target structure or target table.
The factory method CREATE_WITH_VALUE creates a mapping object:
DATA(mapper) =
cl_abap_corresponding=>create_with_value( source = struct$|itab
destination = struct$|itab
mapping = mapping_tab
discarding_duplicates = flag ).
For the parameters source and destination, the same applies as to the method CREATE . An internal table of the type CL_ABAP_CORRESPONDING=>MAPPING_TABLE_VALUE that contains the mapping rule, must be passed to the parameter mapping. This mapping table has the same components, with the same meaning as a mapping table of type CL_ABAP_CORRESPONDING=>MAPPING_TABLE with an additional column and further values for the column KIND:
VALUE In this column, a reference to a suitable data object can be specified, whose value is assigned to the component of the target structure that is specified in DSTNAME.
KIND The additional values for the mapping type are:
CL_ABAP_CORRESPONDING=>MAPPING_VALUE (16), the value specified in VALUE is always assigned. The column SRCNAME must be initial
CL_ABAP_CORRESPONDING=>MAPPING_DEFAULT_VALUE (32), the value specified in VALUE is only assigned if the component specified in the column SRCNAME is initial. The component name in SRCNAME must exist in the source structure.
A mapping object created with CREATE_WITH_VALUE is used like a mapping object created with CREATE with the method EXECUTE.

ABAP_EXAMPLE_VX5
The component b2 is given the value xxx and the component b3 is given the value yyy. The components b1 and b4 are given the values of the assigned components a1 and a4 of the source structure.
ABEXA 00863
ABAP_EXAMPLE_END