SAP GET PERM ONLY ABEXA



Get Example source ABAP code based on a different SAP table
  



ABAP_EML - GET PERMISSIONS, only_clause
This example demonstrates all variants of the only_clause with a simple managed RAP BO.
Data model
The CDS data model consists of the root entity DEMO_MANAGED_ROOT_3 and its child entity DEMO_MANAGED_CHILD_3.
Root entity:
DDLS DEMO_MANAGED_ROOT_3
Child entity:
DDLS DEMO_MANAGED_CHILD_3
Behavior definition
The RAP behavior definition DEMO_MANAGED_ROOT_3 is defined in RAP BDL as follows:
BDEF DEMO_MANAGED_ROOT_3
Behavior implementation
For the above RAP behavior definition, one ABP is created. The global class of the behavior pool is BP_DEMO_MANAGED_ROOT_3. The actual implementation takes place in the BP_DEMO_MANAGED_ROOT_3========CCIMP.
The following methods are relevant for this example:
get_instance_features The method returns information on whether certain fields ( data_field3_root and data_field4_root) are read-only or can be modified based on certain conditions. Additionally, information is returned if the creation of instances for an associated entity ( _child) is enabled or disabled. As a prerequisite in the BDEF, the two fields and the associated entity have the required notation ( features: instance ).
get_global_features The method returns information on whether update operations on entities are allowed or not based on a certain condition, that is, updating is only allowed within a certain time span. As a prerequisite in the BDEF, update has the required notation ( features: global ).
get_global_authorizations The method is implemented in a way that create and delete operations are only enabled for users with the appropriate authorizations. In the interest of having a simple demo, the example goes without an authorization object which is, for example, a way to handle the authorization granting in production applications. The variable auth_flag represents the authorization that is granted or not. In this case, the permission is not granted. As a prerequisite in the BDEF, the notation authorization master ( global ) exists. In this example, instance authorizations are also covered, hence, the notation is authorization master ( global, instance ) in the BDEF.
get_instance_authorizations The method returns information on whether delete operations are allowed on instances. In this example, the deletion is not allowed if data_field2_root has a particular value. As a prerequisite in the BDEF, the notation authorization master ( instance ) exists. In this example, global authorizations are also covered, hence, the notation is authorization master ( global, instance ) in the BDEF .

ABAP_SOURCE_CODE
DEMO CL_DEMO_RAP_EML_GET_PERM_ONLY

ABAP_DESCRIPTION
Access with ABAP using EML
The above source code uses EML to access the RAP business object from an ABAP class:
The example covers all variants of only_clause using the short form of the GET PERMISSIONS statement.
As a first step, the database tables that are used in the example are emptied and filled again with demo values as a basis for the example. Request parameters for an entity are then specified. In this case, all fields, operations and one associated entity (the child entity) are enabled. These parameters are used in all GET PERMISSIONS statements. All statements use the same input keys (except those statements where specifying the keys is not allowed) and include response parameters that are not used in the example.
The result of the individual GET PERMISSIONS statements is displayed on the output screen. For that purpose, internal tables are set up that contain the values from the instance table and global structure.
Notes on the result, i. e. the entries in the output tables:
ONLY GLOBAL There are no entries in the instance table, hence, no table is displayed. The global structure includes the global authorization (the value 02, i. e. IF_ABAP_BEHV=>PERM-O-UNAUTHORIZED, for the create and delete operation is displayed) and global feature controls (the value of update either shows 00 for enabled or 01 for disabled). Furthermore, static information is available, too: The key_field (here _key) and the field data_field2_root show the value 01 (i. e. mandatory), the field data_field1_root shows the value 02 (i. e. readonly ) as defined in the BDEF.
ONLY GLOBAL FEATURES There are no entries in the instance table, hence, no table is displayed. The global structure includes the global feature control and static information (see the details of ONLY GLOBAL).
ONLY GLOBAL AUTHORIZATION There are no entries in the instance table, hence, no table is displayed. The global structure includes global authorization. The value 02, i. e. IF_ABAP_BEHV=>PERM-O-UNAUTHORIZED, for the create and delete operation is displayed.
ONLY INSTANCE The instance table includes instance-based authorization and instance-based feature control plus static information. According to the method get_instance_features, the value of assoc is 01 for the instance with key 1 denoting that the create-by-association operation is disabled in the context of this instance. In contrast to that, the operation is allowed for the instance with key 2 (the value is 00). The read-only field data_field1_root shows the value 02, i. e. IF_ABAP_BEHV=>PERM-F-READ_ONLY. data_field3_root and data_field4_root show the values of the result after calling the get_instance_features method. The instance with the key 2 shows the value 02 for delete as a result of calling the method get_instance_authorizations. The global structure includes the static information as outlined in ONLY GLOBAL.
ONLY INSTANCE FEATURES The instance table includes instance-based feature control. It shows the same values for both instance table and global structure as in ONLY INSTANCE except for the instance-based authorization part (i. e. the instance with the key 2 does not include the result of the delete operation here).
ONLY INSTANCE AUTHORIZATION The instance table includes instance-based authorization. The instance with the key 2 shows the value 02 for delete as a result of calling the method get_instance_authorizations. The instance with the key 1 is not included at all in the result. The global structure does not include any relevant values.
ONLY FEATURES The instance table includes instance-based feature control plus static information (see the details of ONLY INSTANCE except for the instance-based authorization part). The global structure includes the global feature control and static information (see the details of ONLY GLOBAL except for the global authorization part).
ONLY AUTHORIZATION The instance table includes instance-based authorization (see the details of ONLY INSTANCE AUTHORIZATION). The global structure includes the global authorization (see the details of ONLY GLOBAL AUTHORIZATION).
ONLY dyn_spec The result is the same as for ONLY AUTHORIZATION. The variant ONLY AUTHORIZATION is specified dynamically using the enumeration value of type T_PERMISSIONS_ONLY of interface IF_ABAP_BEHV.