SAP BDL DRAFT QUERY ABEXA



Get Example source ABAP code based on a different SAP table
  



ABAP_RAP - RAP BO with DCL Access Control
This example demonstrates how read access control is implemented and evaluated for a RAP BO for active data and for draft data using the CDS data control language CDS DCL.
Data model
The CDS data model consists of the root view entity DEMO_RAP_MANAGED_DRAFT_QUERY.
DDLS DEMO_RAP_MANAGED_DRAFT_QUERY
This CDS root view entity has the CDS DCL access condition DEMO_RAP_DRAFT_QUERY attached to it, which restricts read access to the active data.
DCLS DEMO_RAP_DRAFT_QUERY
Draft Query View
The following CDS view entity DEMO_RAP_DRAFT_QUERY_VIEW defines a draft query view. It selects all fields from a RAP draft table. It has a CDS DCL source attached to it, which defines read access restrictions for the draft data.
DDLS DEMO_RAP_DRAFT_QUERY_VIEW
This CDS view entity has the CDS DCL access condition DEMO_RAP_DCL_DRAFT attached to it, which restricts read access to the draft data.
DCLS DEMO_RAP_DCL_DRAFT
Behavior definition
The RAP behavior definition DEMO_RAP_MANAGED_DRAFT_QUERY is managed and draft-enabled. It specifies the CDS view entity DEMO_RAP_DRAFT_QUERY_VIEW as draft query view.
ABAP_NOTE This example is intentionally kept short and simple and serves demonstration purposes only. The RAP handler methods are not implemented in the ABAP behavior pool here.
BDEF DEMO_RAP_MANAGED_DRAFT_QUERY

ABAP_SOURCE_CODE
DEMO CL_DEMO_RAP_DRAFT_QUERY_VIEW

ABAP_DESCRIPTION
Access with ABAP using EML and AB_SQL
The above source code uses EML and AB_SQL to access the RAP business object from an ABAP class:
It creates four active entity instances using the EML statement MODIFY ENTITIES CREATE.
It reads these active instances, first with the EML statement READ ENTITIES, and afterwards with AB_SQL SELECT. In the EML read, the DCL access condition is applied and the result set is filtered according to the access condition. Some data sets are filtered out. By contrast, the AB_SQL SELECT displays all instances that were saved on the database.
It creates four draft instances using the EML statement MODIFY ENTITIES CREATE.
It reads these draft instances, first with the EML statement READ ENTITIES, and afterwards with AB_SQL SELECT. In the EML read, the DCL access condition attached to the draft query view is applied and the result set is filtered according to the access condition. Some data sets are filtered out. By contrast, the AB_SQL SELECT displays all instances that were saved in the RAP draft table.
Finally, the RAP draft table is cleared using the draft action Discard.