SAP EML AUTH CHECK DISABLE ABEXA



Get Example source ABAP code based on a different SAP table
  


VX_EXA_ONLY

ABAP_EML - AUTHORITY-CHECK DISABLE
This example demonstrates the ABAP_EML statement AUTHORITY-CHECK DISABLE BEGIN CONTEXT ... AUTHORITY-CHECK DISABLE END. with an unmanaged RAP business object.
Data model
The CDS data model consists of the root entity DEMO_UNMANAGED_AUTH:
DDLS DEMO_UNMANAGED_AUTH
Behavior definition
The RAP behavior definition DEMO_UNMANAGED_AUTH is defined in RAP BDL as follows:
BDEF DEMO_UNMANAGED_AUTH
Behavior implementation
For the above BDEF, one behavior pool is created. The global class of the behavior pool is BP_DEMO_UNMANAGED_AUTH. The actual behavior implementation takes place in local classes that are defined and implemented in the BP_DEMO_UNMANAGED_AUTH========CCIMP of the behavior pool. The handler methods do not contain any implementations. To demonstrate the statement AUTHORITY-CHECK DISABLE, multiple AUTHORITY-CHECK OBJECT statements are included in the read method that check the authorization. One of these statements is inside an AUTHORITY-CHECK DISABLE statement. An internal table that is declared in the global class is filled to log sy-subrc values that are returned by the individual AUTHORITY-CHECK OBJECT statements.

ABAP_SOURCE_CODE
DEMO CL_DEMO_RAP_AUTH_CHECK_DISABLE

ABAP_DESCRIPTION
Access with ABAP using EML
The above source code uses EML to access the RAP business object from an ABAP class:
A RAP read operation is carried out.
As shown above, the BDEF defines two RAP authorization contexts using the demo authorization objects AUTHOBJ1 and AUTHOBJ2. For AUTHOBJ2, an authority check is disabled for read.
The output shows the entries of an internal which demonstrates the effect of the AUTHORITY-CHECK DISABLE statements that are implemented in the local class of the behavior pool. When an AUTHORITY-CHECK DISABLE BEGIN CONTEXT ... AUTHORITY-CHECK DISABLE END statement is used, the field EML_STMNT_USED is flagged. When an authorization context is activated, authority checks for the associated authorization objects are always successful and the returned value for sy-subrc is 0. See more information on the sy-subrc values returned by AUTHORITY-CHECK OBJECT statements in the ABAP Keyword Documentation .
Table entries:
The first two entries show the sy-subrc values returned by AUTHORITY-CHECK OBJECT statements that are used with the respective authorization objects. sy-subrc is only 0 for AUTHOBJ2 because the authorization context is defined with the addition ... for disable ( read ) in the BDEF which shows that the AUTHORITY-CHECK DISABLE BEGIN CONTEXT ... AUTHORITY-CHECK DISABLE END is implicitly wrapped around this authorization context. This is not true for the authorization context ac1.
The third entry shows the effect of AUTHORITY-CHECK DISABLE BEGIN CONTEXT ... AUTHORITY-CHECK DISABLE END statement which is used for the authorization context ac1. An AUTHORITY-CHECK OBJECT statement that is used within an AUTHORITY-CHECK DISABLE BEGIN CONTEXT ... AUTHORITY-CHECK DISABLE END statement has the effect that the sy-subrc value shows 0 indicating that the authorization context is disabled.
Note that putting the authorization context ac2 inside an AUTHORITY-CHECK DISABLE BEGIN CONTEXT ... AUTHORITY-CHECK DISABLE END statement is irrelevant because it is implicitly there due to the BDEF specification.