SAP RAP LUW ABEXA



Get Example source ABAP code based on a different SAP table
  



Phases in a RAP Transaction
This example demonstrates the phases of a RAP transaction using an unmanaged RAP business object with late numbering .
Data model
The CDS data model consists of the root entity DEMO_RAP_LUW_LN_U.
Root entity:
DDLS DEMO_RAP_LUW_LN_U
Behavior definition
The RAP behavior definition DEMO_RAP_LUW_LN_U is defined in RAP BDL as follows:
BDEF DEMO_RAP_LUW_LN_U
Behavior implementation
For the above RAP behavior definition, one ABP is created. The global class of the behavior pool is BP_DEMO_RAP_LUW_LN_U. The actual behavior implementation takes place in local classes that are defined and implemented in the BP_DEMO_RAP_LUW_LN_U==========CCIMP of the behavior pool.

ABAP_SOURCE_CODE
DEMO CL_DEMO_RAP_LUW_LN_U

ABAP_DESCRIPTION
Access with ABAP using EML
The above source code uses EML to access the RAP business object from an ABAP class.
The class demonstrates the following:
A successful save, i.e. the interaction phase and the RAP save sequence have been processed successfully. Two RAP BO instances are created. A COMMIT ENTITIES statement triggers the save sequence. The value of sy-subrc is displayed after the commit. During the execution of the method implementation code in the ABP, an internal table is populated that stores the following information: position of the method call sequence, name of the method, if there is an error, a flag for the interaction, early, or late save phase. This table is displayed as well as the entries of the database table as a result of the RAP create operation.
Failure in the finalize method: An instance is created. The same steps are taken as described above. In this case, the failure in the finalize method triggers the call of the cleanup_finalize method. sy-subrc is set to 4 after the commit. There is then another RAP create operation on the RAP BO consumer. This time, the RAP transaction is completed with a successful save.
Failure in the check_before_save method: The steps are the same as described above. A failure also triggers the cleanup_finalize method. In all other examples, this method is not called. It is only called if an error occurs in the finalize or check_before_save method.
Rollback. This example has no COMMIT ENTITIES statement. The purpose is to demonstrate that the ROLLBACK ENTITIES statement only triggers the call of the cleanup method in the RAP saver class.