SAP BDL DRAFT QUERY VIEW



Get Example source ABAP code based on a different SAP table
  


• QUERY ABAP_BDL_PROP

ABAP_RAP - query

ABAP_SYNTAX
... query DraftQueryView

What does it do?
Defines a draft query view DraftQueryView for a RAP draft table . query is an optional addition that can be specified directly after the RAP draft table draft table DraftTableName. It is only mandatory in the context of RAP extensibility, if the BDEF in question is released with the C0 contract for extensibility. This is described in the topic TITLE .
The draft query view DraftQueryView must be a CDS view entity or a ABAP_CDS_V1_VIEW that specifies the RAP draft table as data source after FROM . It must contain all fields from the draft table including administrative fields. Otherwise, a syntax check warning occurs.
The benefit of a draft query view is that read access limitations to the draft data can be defined using data control language (DCL). In general, DCL objects defined for a CDS view selecting from the active database table are not applied to draft data. With a draft query view, read access restrictions for draft data can be defined.

ABAP_AVAILABILITY
The syntax addition query is available in draft-enabled RAP business objects of type managed or unmanaged.
In a projection business object and in an interface BDEF, the draft query view is automatically inherited from the base BDEF (if specified there). All access restrictions to draft data are reused in the projection BO and interface BO. The syntax query is not available there. For details, see topic TITLE .
ABAP_AVAILABILITY_END

ABAP_FURTHER_INFO
Development guide for the ABAP RESTful Application Programming Model, topic Draft Query Views.

ABAP_EXAMPLE_VX5
The following example shows a managed and draft-enabled RAP BO.
It is based on the CDS view entity DEMO_RAP_MANAGED_DRAFT_QUERY. This CDS view entity has read access restrictions defined in the DCL source DEMO_RAP_DRAFT_QUERY .
It specifies the CDS view entity DEMO_RAP_DRAFT_QUERY_VIEW as draft query view. This draft query view has read access restrictions defined in the DCL source DEMO_RAP_DCL_DRAFT.
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
The class CL_DEMO_RAP_DRAFT_QUERY_VIEW accesses the business object using EML and AB_SQL and performs the following operations:
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.
ABAP_EXAMPLE_END

ABAP_EXAMPLE_ABEXA
The example above is explained in detail in the executable example RAP BDL - RAP BO with DCL Access Control .
ABAP_EXAMPLE_END