Get Example source ABAP code based on a different SAP table
Example for RAP Saver Method map_messages> This example demonstrates the RAP saver method map_messages> within a RAP saver class using unmanaged RAP BOs. Data model> The CDS data model consists of the root entity DEMO_UNMANAGED_MAP_MESSAGES >, which represents the exposed RAP BO, and the foreign entity> DEMO_UNMANAGED_FOREIGN_ENTITY>, i. e. the RAP BO that is not exposed. CDS data model of the exposed BO: DDLS DEMO_UNMANAGED_MAP_MESSAGES CDS data model of foreign entity: DDLS DEMO_UNMANAGED_FOREIGN_ENTITY Behavior definition> The following RAP behavior definitions>, that are defined in RAP BDL>, are relevant for the example:
DEMO_UNMANAGED_MAP_MESSAGES >> BDEF DEMO_UNMANAGED_FOREIGN_ENTITY Behavior implementation> For each of the above RAP behavior definitions, one ABP> is created:
Global class of the behavior pool: BP_DEMO_UNMANAGED_MAP_MESSAGES>>. The actual behavior implementation takes place in local classes that are defined and implemented in the BP_DEMO_UNMANAGED_MAP_MESSAGESCCIMP>> of the behavior pool.
Global class of the behavior pool: BP_DEMO_UNMANAGED_FOREIGN_ENTI>>. The BP_DEMO_UNMANAGED_FOREIGN_ENTICCIMP>> contains the actual behavior implementation. The ABPs purposely include only a few method implementations to keep the example small. In this case, only the create> method is implemented on handler> side. On saver> side, only the save> method is implemented. The ABP of the exposed BO also includes the implementation of the map_messages> method. In this simple example, the map_messages> method is implemented as follows: The messages that are available in the REPORTED LATE>> table of the foreign entity are sequentially processed within a LOOP AT>> statement. Here, the message from the foreign entity is first replaced, and then inserted into the REPORTED LATE> table of the exposed BO. After the loop, the content of the REPORTED LATE > table of the foreign entity is deleted.
ABAP_DESCRIPTION Access with ABAP using EML> The above source code uses EML> to access the RAP business object from an ABAP class. The example includes two ABAP_EML MODIFY> requests within one RAP transaction>. Each of the MODIFY> requests includes a create operation> using CREATE>> statements that create two instances for the exposed BO and the foreign entity. A COMMIT ENTITIES>> statement triggers the save sequence and terminates the RAP transaction. The output shows the result of the MODIFY> requests. The instances that have been saved to the database table are selected from the database table into an internal table. The COMMIT ENTITIES> statement includes the REPORTED> response. The content of this response is output, too, demonstrating the effect of the map_messages> method. The original messages for the instances of the foreign entity are available for the exposed BO. Furthermore, the messages have been changed and the REPORTED> table of the foreign entity does not show any entries since the content has been deleted.