SAP BDL PRECHECK



Get Example source ABAP code based on a different SAP table
  


• PRECHECK ABAP_BDL_BODY

ABAP_RAP - precheck

ABAP_SYNTAX
... precheck ...

What does it do?
A method that is called before a modify request is executed on the transactional buffer to prevent unwanted changes from reaching the application buffer.
A precheck can be defined for the following RAP BO operations:
standard operations
operations for associations
actions
An implementation in the RAP handler method FOR PRECHECK in the local ABAP behavior pool is required.

ABAP_AVAILABILITY
Managed RAP BOs
Unmanaged RAP BOs
Projection BOs
ABAP_AVAILABILITY_END

Projection Implementation
If a precheck is defined in a projection implementation, an ABAP behavior pool is required.
If the base BO defines a precheck, this is automatically reused. The projection can also define a new precheck. Also, it is possible to define a precheck for both layers. In this case, first, the precheck of the projection layer is called and afterwards the precheck of the base layer.

ABAP_FURTHER_INFO
Development guide for the ABAP RESTful Application Programming Model, section Operation Precheck.



Latest notes:

Cannot be used for internal operations using the keyword internal.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The following example shows an unmanaged BDEF based on the CDS view entity DEMO_RAP_UNMANAGED_PRECHECK. It defines the RAP BO operation addition precheck for the standard operation create.
BDEF DEMO_RAP_UNMANAGED_PRECHECK
In the ABAP behavior pool BP_DEMO_RAP_UNMANAGED_PRECHECK, the precheck method implements a uniqueness check. It checks that the primary keys for new entity instances are unique. If the primary key values already exist, an entry is written into the failed and reported structures and the respective entity instance does not reach the application buffer.
Code snippet:
METH BP_DEMO_RAP_UNMANAGED_PRECHECK(CCIMP)=>precheck_create
For the complete implementation in the ABAP behavior pool, see BP_DEMO_RAP_UNMANAGED_PRECHECKCCIMP.
The class CL_DEMO_RAP_UNMANAGED_PRECHECK accesses the business object using EML and performs the following steps:
It inserts data into the database using AB_SQL INSERT.
It creates two valid new entity instances with unique keys. They pass the precheck and are written to the database.
It creates two more new entity instances - one is valid, one has a duplicate key value (value '1' already exists).
The entity instance with duplicate key is written into the failed and reported structures. The valid entity instance is committed to the database.
ABAP_EXAMPLE_END