Ansicht
Dokumentation
ABENBDL_ACTION2_ABEXA - BDL ACTION2 ABEXA
PERFORM Short Reference Fill RESBD Structure from EBP Component StructureThis documentation is copyright by SAP AG.
- Action with Input Parameter
This example demonstrates how a RAP action with input parameter is defined, implemented, and consumed in a managed RAP BO.
Data model
The CDS data model consists of only one root entity DEMO_CDS_ACTION_INPUT_PARAM. The root entity represents a purchase order item.
Behavior definition
The CDS behavior definition
DEMO_CDS_ACTION_INPUT_PARAM is defined in CDS BDL as follows:
Action definition
The behavior definition defines one action: deductDiscount. The action has one input parameter that is typed with the CDS abstract entity DEMO_CDS_ABSTRACT_DISCOUNT and it defines the output parameter as the same type as the entity for which the action is executed. The purpose is to reduce the purchase order item price by the discount specified via the input parameter.
action deductDiscount
parameter DEMO_CDS_ABSTRACT_DISCOUNT
result [1] $self;
The following CDS abstract entity is used for typing the input parameter:
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_ACTION_INPUT_PARAM. This global class implements the local handler class LHC_DEMO_CDS_ACTION_INPUT_PARA, which contains the method deductDiscount to implement the action. This method is a FOR MODIFY method and it is typed based on the PurchaseItem entity. Its signature includes the result parameter. The actual implementation takes place in the BP_DEMO_CDS_ACTION_INPUT_PARAMCCIMP.
Source Code
Description
Access with ABAP using EML
The above source code uses EML to access the RAP business object from an ABAP program:
- The user is requested to enter the discount percentage.
- Two BO instances are created with the statement MODIFY ENTITY.
- The action deductDiscount 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 using the statement COMMIT ENTITIES RESPONSE OF.
- A SELECT statement is used to read the changed data from the persistent table DEMO_PURCH_DOC_I. As a result of the action, the price of a purchase order item is reduced by the percentage specified via the input parameter.
PERFORM Short Reference ABAP Short Reference
This documentation is copyright by SAP AG.
Length: 4332 Date: 20240426 Time: 091249 sap01-206 ( 64 ms )