Ansicht
Dokumentation

ABENBDL_DRAFT_ACTION2_ABEXA - BDL DRAFT ACTION2 ABEXA

ABENBDL_DRAFT_ACTION2_ABEXA - BDL DRAFT ACTION2 ABEXA

RFUMSV00 - Advance Return for Tax on Sales/Purchases   RFUMSV00 - Advance Return for Tax on Sales/Purchases  
This documentation is copyright by SAP AG.
SAP E-Book

- Draft Actions Edit, Discard, Prepare

This example demonstrates how the draft actions Edit, Discard, and Prepare are defined, implemented, and consumed in a managed RAP BO.

Data model

The CDS data model consists of the root entity DEMO_RAP_MANAGED_DRAFT_ACTIONS:

Behavior definition

The CDS behavior definition DEMO_RAP_MANAGED_DRAFT_ACTIONS is defined in CDS BDL as shown below. It is draft-enabled and strict mode is switched on. Therefore, it is mandatory to explicitly declare all draft actions.

The determination setCharField is defined. It is executed on save whenever the field Timestamp is modified. It is implemented in the ABAP behavior pool and it sets the value of the field CharFieldRoot of the respective entity instance to 'A'.

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_RAP_MANAGED_DRAFT_ACTI. This global class implements the local handler class LHC_PARENTENTITY, which contains the method setCharField to implement the determination. The actual implementation takes place in the BP_DEMO_RAP_MANAGED_DRAFT_ACTICCIMP. It sets the value of the field CharFieldRoot of the respective entity instance to 'A'.

Source Code

Execute

Description

Access with ABAP using EML

The above source code uses EML to access the RAP business object from an ABAP program:

  • Two active BO instances are created with the statement MODIFY ENTITY.
  • The draft action Edit is executed on both instances with the statement EXECUTE. No changes are made, the only effect of the draft action Edit in this example is that the active instances are copied to the draft database table.
  • The draft action Prepare is executed for the two draft instances that were copied from the persistent table to the draft table during the Edit. The assigned determination setCharField is executed and it inserts a value into field CharFieldRoot.
  • The draft action Discard is executed. It deletes both instances from the draft database table.
  • Using the SELECT statement, the content of the draft and persistent tables are displayed. It can be seen that the draft action Edit copies the active BO instances to the draft database table. The action Prepare fills the field CharFieldRoot of the draft database table. The draft action Discard deletes the instances from the draft database table.






SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up   SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up  
This documentation is copyright by SAP AG.

Length: 4707 Date: 20240425 Time: 121022     sap01-206 ( 75 ms )