Ansicht
Dokumentation

ABENEML_PRIVILEGED_ABEXA - EML PRIVILEGED ABEXA

ABENEML_PRIVILEGED_ABEXA - EML PRIVILEGED ABEXA

RFUMSV00 - Advance Return for Tax on Sales/Purchases   ROGBILLS - Synchronize billing plans  
This documentation is copyright by SAP AG.
SAP E-Book

Using the Addition PRIVILEGED with an Statement

This example demonstrates MODIFY statements executing an action with and without the addition PRIVILEGED using a managed RAP BO.

Data model

The CDS data model consists of the root entity DEMO_MANAGED_PRIVILEGED.



Behavior definition

The CDS behavior definition DEMO_MANAGED_PRIVILEGED is defined in CDS BDL as follows:

Behavior implementation

For the above CDS behavior definition, there is an ABAP behavior pool (ABP) available. The global class of the behavior pool is BP_DEMO_MANAGED_PRIVILEGED. This global class implements the local handler class LHC_DEMO_MANAGED_PRIVILEGED. The actual implementation takes place in the BP_DEMO_MANAGED_PRIVILEGED====CCIMP. The following method is relevant for the example:

  • check_privileged
First, the privileged mode is checked. The privileged mode can be queried by the RAP BO provider using the method GET_CURRENT_CONTEXT of the class CL_ABAP_BEHV_AUX. If the privileged mode is active, a flag is set appropriately. For demonstration purposes in this implementation, the flag for the privileged mode is stored in a variable of the global class of the behavior pool so that the RAP BO consumer (i. e. the program) can access it. As a next step, an authority check for demonstrating the privileged mode is carried out using the statement AUTHORITY-CHECK OBJECT. Like the flag for the privileged mode, the value of sy-subrc is stored in a variable in the global class. After the check, the imported key fields are looped across. In this implementation, only the RAP response parameters are manually filled (failed and reported). In case the authorization is not granted, both failed and reported are filled. In the other case, only the reported structure is filled containing a success message.

Source Code

Execute

Description

The above source code uses EML to access the RAP business object from an ABAP program. There are two modify requests:

  1. modify request without using the addition PRIVILEGED
The action check_privileged is executed based on two key fields. The output includes the sy-subrc value that is set when calling the method and carrying out the authority check. Here, it shows the value 12 indicating that the authorization has not been granted. It also shows a phrase whether the privileged mode is active or not based on a flag that has been set during the method call. For the modify request, the response parameters for failed and reported are filled which are output, too. In this case, they include all instances for which the authorization has not been granted and a failure message.
  1. modify request with using the addition PRIVILEGED
Same as above, the action check_privileged is executed based on two key fields. The output demonstrates the effect of the addition PRIVILEGED that circumvents authority checks. Here, the sy-subrc value is 0 indicating that the authorization has been granted. For this request, only the response parameter for reported is filled containing a success message.





Fill RESBD Structure from EBP Component Structure   CPI1466 during Backup  
This documentation is copyright by SAP AG.

Length: 4835 Date: 20240512 Time: 122313     sap01-206 ( 81 ms )