Ansicht
Dokumentation

ABENBDL__BEHAVIOR_EXT_ABEXA - BDL  BEHAVIOR EXT ABEXA

ABENBDL__BEHAVIOR_EXT_ABEXA - BDL  BEHAVIOR EXT ABEXA

ROGBILLS - Synchronize billing plans   CL_GUI_FRONTEND_SERVICES - Frontend Services  
This documentation is copyright by SAP AG.
SAP E-Book

- Behavior Extension

This example demonstrates how the behavior of a RAP BO is extended by means of a BDEF extension.

Original RAP BO

Data model

The CDS data model consists of one root node without child entities:

Behavior definition

The CDS behavior definition DEMO_RAP_BEH_EXT is defined in CDS BDL as shown below. It defines implementation-relevant components and extension points.

Behavior implementation

For the CDS behavior definition, one ABAP behavior pool (ABP) is created. The global class of the behavior pool is BP_DEMO_RAP_BEH_EXT, see BP_DEMO_RAP_BEH_EXT===========CCIMP. This global class implements the following methods:

  • get_instance_features: Instance feature control for the standard operation update. If the value of field int_field1 is more than 50, updates are not allowed. If the value is equal to or smaller than 50, updates are allowed.
  • get_global_authorizations: Global authorization control defines that create, update, and delete are always allowed.
  • Limit: Validation that checks the value of field int_field2. If the value is more than 500, the validation fails and the entity instance is not saved.

Extension RAP BO

Data model extension

A child node is added to the RAP BO:

A composition association is added to the root node via a view entity extension:

Behavior extension

The BDEF extension DEMO_RAP_BEH_EXT_CH extends the root node and defines behavior for the extension child node.

ABP extension

The ABP extension is implemented in the global class BP_DEMO_RAP_BEH_EXT_CH, see BP_DEMO_RAP_BEH_EXT_CH========CCIMP. This global class implements the following methods:

  • Extension of the parent entity
  • get_global_features: Global feature control for the action setValue. This action can only be executed in the time period between 6 am and 10 pm (day shift).

  • get_global_authorizations: The original RAP BO defines global authorization control. RAP BO operations added via an extension require an own implementation of the global authorization control. This method generally allows execution of the method setValue. There are no access restrictions.

  • setValue: Action that sets field int_field2 to value 888.

  • Extension entity behavior definition for the child entity
  • get_global_authorizations: The original RAP BO defines global authorization control. For the action ActionExt, defined in the child node, a separate implementation of the authorization control method is required. The implementation generally allows execution of the method ActionExt. There are no access restrictions.

  • myDet: Determination on modify. Sets the value of field int_field1 to 777.

  • ActionExt: Action that updates field char_field1 for all requested entity instances.

Source Code

Execute

Description

Access with ABAP using EML

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

  • It inserts two parent entity instances and two child entity instances.
Authorization is granted, the validation Limit is successful.
  • It updates the two parent entity instances
Update requests are subject to instance feature control. This instance feature check fails for one entity instance. The update is successful only for one entity instance.
For the failed entity instance, the error message is displayed.
Authorization is granted.
  • It executes the action setValue.
Authorization is granted, global feature control is successful.
  • It executes the action ActionExt.
Authorization control for parent and child entities is successful.

The screen output includes a table that lists the execution order of handler methods of the ABAP behavior pool. This shows which methods in which order are executed when accessing the RAP BO.






CPI1466 during Backup   CPI1466 during Backup  
This documentation is copyright by SAP AG.

Length: 7281 Date: 20240512 Time: 085300     sap01-206 ( 69 ms )