Get Example source ABAP code based on a different SAP table
ABAP_RAP - Field Extension This example demonstrates how extension fields are added and behavior- enabled in a RAP BO extension scenario.
Original RAP BO DDIC data model> The DDIC data model consists of one database table: DEMO_ROOT_EXT>>: DDIC DEMO_ROOT_EXT This database table includes structure DEMO_EXTENSION>>. DDIC DEMO_EXTENSION CDS data model> The CDS data model consists of one root entity without child entities: DEMO_RAP_FIELD_EXT>>: DDLS DEMO_RAP_FIELD_EXT CDS transactional interface> The following CDS transactional interface is created as stable public interface for extensions: DDLS DEMO_RAP_FIELD_EXT_INT Behavior definition> The RAP behavior definition> DEMO_RAP_FIELD_EXT>> is defined in RAP BDL> as shown below. It defines global authorization control and adds field attributes to multiple fields. BDEF DEMO_RAP_FIELD_EXT Behavior implementation> For the RAP behavior definition, one ABAP behavior pool (ABP)> is created. The global class of the behavior pool is BP_DEMO_RAP_FIELD_EXT>>, see BP_DEMO_RAP_FIELD_EXT=========CCIMP>>. This global class implements two methods:
get_instance_features>: Implements dynamic feature control for field DataField>: If field CharField> has value A>, then field DataField> is read-only. If field CharField> has any other value, then field DataField> can be accessed without any restrictions.
get_global_auth>: Defines global feature control for the complete RAP BO: Update requests are generally authorized and delete requests are generally unauthorized. RAP BO Interface> The following RAP BO interface is used as stable public interface for extensions. BDEF DEMO_RAP_FIELD_EXT_INT
Extension RAP BO DDIC data model extension> Extension fields are added to the DDIC data model via the structure extension DEMO_EXTEND_STR>>: DDIC DEMO_EXTEND_STR CDS data model extension> The extension fields are added to the CDS data model via the CDS view entity extension DEMO_EXTENSION_RAP_BO> >: DDLS DEMO_EXTENSION_RAP_BO CDS transactional interface extension> The extension fields are added to the CDS transactional interface by means of an entity extension DEMO_RAP_TI_FIELD_EXT> >: DDLS DEMO_RAP_TI_FIELD_EXT BDEF extension> The BDEF extension DEMO_EXTENSION_RAP_BO >> adds field attributes to the extension fields using the BDEF interface. BDEF DEMO_EXTENSION_RAP_BO ABP extension> The ABP extension is implemented in the global class BP_DEMO_EXTENSION_RAP_BO>>, see BP_DEMO_EXTENSION_RAP_BO======CCIMP>>. This global class implements dynamic feature control for the extension field NumFieldExt>: If the value of field IntFieldExt> is greater than 1000, then field NumFieldExt> is read-only. If the value of field IntFieldExt > is less than or equal to 1000, access to field NumFieldExt> is unrestricted.
ABAP_SOURCE_CODE DEMO CL_DEMO_RAP_FIELD_EXT
ABAP_DESCRIPTION Access with ABAP using EML> The source code above uses ABAP EML> to access the RAP business object> from an ABAP class:
It inserts two entity instances using MODIFY ENTITIES CREATE>>.
It updates both entity instances using MODIFY ENTITIES UPDATE>>. For the entity instance with key value 1>, both fields DataField> and NumFieldExt> are dynamically set to read-only by the field feature control. These two fields are not updated, but error messages are returned. Execution order for CREATE>:
Global authorization control specified in the original ABP. Execution order for UPDATE>:
Global authorization control specified in the original ABP.
Field feature control specified in the original ABP.
Field feature control specified in the extension ABP.