Ansicht
Dokumentation
ABENBDL_ACTION1_ABEXA - BDL ACTION1 ABEXA
BAL Application Log Documentation Fill RESBD Structure from EBP Component StructureThis documentation is copyright by SAP AG.
- Action
This example demonstrates how a RAP action is defined, implemented, and consumed in a managed RAP BO.
Data model
The CDS data model consists of the root entity DEMO_CDS_PURCH_DOC_M and its child entity DEMO_CDS_PURCH_DOC_I_M. The root entity represents a purchase order and the child entity represents a purchase order item.
Root entity:
Child entity:
Behavior definition
The CDS behavior definition
DEMO_CDS_PURCH_DOC_M is defined in CDS BDL as follows:
Action definition
Two actions are defined: Approve_Order and Reject_Order. If an employee wants to order equipment, the employee creates a purchase order and the manager can approve or reject this purchase order. Both actions have the output parameter $self with cardinality 1, so the parameter result has the same type as the entity for which the action is executed.
action Approve_Order result [1] $self;
action Reject_Order result [1] $self;
Behavior implementation
For the above CDS behavior definition, one ABAP behavior pool (ABP) is created. The global class of the behavior pool is BP_DEMO_CDS_PURCH_DOC_M. This global class implements the local handler class LHC_PURCHASEDOCUMENT, which contains two methods, Approve_Order and Reject_Order, to implement the actions. The actual implementation takes place in the BP_DEMO_CDS_PURCH_DOC_M=======CCIMP and it works as follows:
- For the passed entity instance, column Status is updated with A for Approved or R for Rejected, using the MODIFY ENTITIES statement.
- A local structure lt_purchase is created and filled with the entity instance using the statement READ ENTITIES.
- The output parameter result is filled. If an output parameter is defined, then it must always be filled.
Source Code
Description
Access with ABAP using EML
The above source code uses EML to access the RAP business object from an ABAP program:
- Two BO instances are created with the statement MODIFY ENTITY.
- The action Approve_Order is executed on one of the two instances with the statement EXECUTE.
- The result, failed, and reported parameters are returned.
- The changes that were performed by the action in the transactional buffer are committed to the database with the statement COMMIT ENTITIES.
- A SELECT statement is used to read the changed data from the persistent table DEMO_PURCH_DOC. As a result of the action, the column Status of the respective instance is filled with A for Accepted.
PERFORM Short Reference SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up
This documentation is copyright by SAP AG.
Length: 5149 Date: 20240425 Time: 074952 sap01-206 ( 64 ms )