RAP: Automatic change request creation through RAP using APIs in the context of MDG

Scenario: In MDG we will create a Change Request by navigating to various screens, to decrease the navigations in the context of MDG, and to make one screen UI which will be built under the RAP application.

Now, What does the RAP application perform?

In the RAP application, we will select the Change Request Type There are some fields in which the user will fill in the data in the RAP application and click on the create button then the CR gets created and the Workflow gets generated.

Prequesities

Tools: Eclipse, SAP Logon

Basic Knowledge: Classes, CDS, APIs, Workflow

Steps to create the RAP application:

Step 1: We need to create a class in SAP logon.

Step 2: Create a database table in Eclipse.

Step 3: Now create a CDS view ( Interface view, Consumption view or Projection view ).

Step 4: Create a Behavior definition for the Interface view.

Step 5: Now we need to create a Behavior implementation of that behavior definition.

Step 6: Create a Behavior definition for the Consumption view.

Step 7: Now we need to create a Service definition.

Step 8: Create a Service Binding.

Step 9: Showing the result.

step 1: create a class (ZMDG_CL_CREATE_CREQUEST) in sap logon.
After creating a class create a method(create_change_request).

Next, we have to create a signature of the method.

For creating the change request we are using APIs the code can be get it in the git hub repository.

step 2: Create a database table(zmdg_t_auto_cr) from Eclipse or SAP logon.

To store the data of the change request we are creating the database table.

@EndUserText.label:
The annotation @EndUserText.label in SAP RAP is used to define a translatable label for a CDS view element. This label is used to display the element to end users in their preferred language.
@AbapCatalog.enhancement.category:
The annotation @AbapCatalog.enhancement.category in SAP RAP is used to specify whether a CDS view can be enhanced by customers. The possible values for this annotation are:

  • #NOT_EXTENSIBLE - The CDS view cannot be enhanced. This is the default value.

  • #EXTENSIBLE_CHARACTER - The CDS view can be enhanced with character-like fields.

  • #EXTENSIBLE_CHARACTER_NUMERIC - The CDS view can be enhanced with character-like and numeric fields.

  • #EXTENSIBLE_ANY - The CDS view can be enhanced with any type of field.

@AbapCatalog.tableCategory:
The annotation @AbapCatalog.tableCategory in SAP RAP is used to specify the type of database table that a CDS view is mapped to. The possible values for this annotation are:

  • #TRANSPARENT - The CDS view is mapped to a transparent table.

  • #GLOBAL_TEMPORARY - The CDS view is mapped to a global temporary table.

  • #LOCAL_TEMPORARY - The CDS view is mapped to a local temporary table.

  • #POOLED - The CDS view is mapped to a pooled table.

  • #CLUSTER - The CDS view is mapped to a cluster table.

@AbapCatalog.deliveryClass:
The annotation @AbapCatalog.deliveryClass in SAP RAP is used to specify the delivery class of a database table. The delivery class determines how the table is delivered to customers.

The possible values for the @AbapCatalog.deliveryClass annotations are

  • #A - The table is delivered with all SAP systems.

  • #B - The table is delivered with some SAP systems.

  • #C - The table is not delivered with any SAP systems.

@AbapCatalog.dataMaintenance:
The annotation @AbapCatalog.dataMaintenance in SAP RAP is used to specify how a database table can be maintained. The possible values for this annotation are:

  • #ALLOWED - The table can be maintained using the SAP GUI or other ABAP tools.

  • #RESTRICTED - The table can only be maintained using specific ABAP programs or transactions.

  • #NOT_ALLOWED - The table cannot be maintained at all.

Step 3: Create a CDS view ( Interface view, Consumption view or Projection view ).

step 3.1: Create a CDS view for the interface view.

Interface view:
An interface view in SAP RAP is a special type of CDS view that is used to expose data to external applications. Interface views are typically used to create APIs that can be consumed by other applications, such as mobile apps, web apps, and other SAP systems.

@AccessControl.authorizationCheck :
The annotation @AccessControl.authorizationCheck in SAP RAP is used to specify whether an authorization check should be performed when accessing a CDS view. The possible values for this annotation are:

  • #CHECK - An authorization check will be performed. This is the default value.

  • #NOT_REQUIRED - An authorization check will not be performed.

  • #NOT_ALLOWED - An authorization check will be performed, and if the check fails, the user will not be able to access the CDS view.

Step 3.2: Create a CDS view for consumption view (or) projection view.

Consumption view (or) projection view:
A consumption view or projection view in SAP RAP is a special type of CDS view that is used to create tailored views of data that are optimized for specific use cases.

@UI:
The annotation @UI in SAP RAP is used to define the user interface (UI) elements that are used to display and interact with CDS views.

headerInfo:
The headerInfo annotation in SAP RAP is used to define the header information for a CDS view. The header information is displayed at the top of the UI when the CDS view is displayed.

provider contract transactional_query:
The provider contract transactional_query in SAP RAP specifies that the CDS view is a transactional query. This means that the view can be used to read, insert, update, and delete data in the database.

Transactional queries are typically used to create and maintain business data, such as customer data, order data, and product data. They can also be used to generate reports and analytics.

@UI.facet:
The annotation @UI.facet in SAP RAP is used to define a facet in a CDS view. A facet is a group of related fields that are displayed together in a UI.

@Search.defaultSearchElement:
The annotation @Search.defaultSearchElement in SAP RAP is used to specify a field in a CDS view that will be used as the default search element when the view is searched.

@UI.fieldGroup:
The annotation @UI.fieldGroup in SAP RAP is used to group related fields in a CDS view. Field groups are displayed together in a UI, typically as a section or form.

Step 4: Create a Behavior definition for the Interface view.

Behavior definition:
A behavior definition in SAP RAP is a definition of the actions that can be performed on a CDS view. Behavior definitions are used to control how users can interact with CDS views.

Behaviour implementation:
A behavior implementation in SAP RAP is a class that implements the behavior definition for a CDS view. The behavior implementation is responsible for implementing the actions that are defined in the behavior definition.

Persistent table:
A persistent table in SAP RAP is a database table that is used to store data permanently. Persistent tables are typically used to store data that is used by multiple applications and that needs to be persisted across application sessions.

Draft table:
A draft table in SAP RAP is a special type of persistent table that is used to store draft data. Draft data is data that has not yet been saved as an active version.

Lock master total etag:
The lock master total ETag in SAP RAP is a unique identifier that is used to prevent concurrent access and modifications to draft data. The lock master total ETag is stored in the draft table and is generated by the RAP runtime framework when the draft is created or updated.

Authorization master:
The authorization master in SAP RAP is a special type of annotation that is used to specify the authorization checks that are performed on a CDS view.

Etag master:
The ETag master in SAP RAP is a special type of annotation that is used to identify the business object entity that is responsible for managing the ETag for a CDS view. The ETag is a unique identifier that is used to implement optimistic concurrency control.

field ( numbering: managed, readonly):
The field (numbering: managed, readonly) annotation can be used on any field in a CDS view, regardless of the field type. However, it is generally recommended to use the field (numbering: managed, readonly) annotation on fields that contain primary key values.

Determination:
Determinations can be defined at the entity level or at the field level. Entity-level determinations are executed when a record is created, updated, or deleted. Field-level determinations are executed when a field is modified.

Step 5: Now we can implement behavior implementation for determination**(CREATE_CHANGE_REQUEST)**.

Step 6: Create a Behavior definition for the Consumption view.

Projection:
A projection in a behavior definition in SAP RAP is a way to define a subset of the fields in a CDS view that are exposed to a client application. Projections can be used to improve the performance of client applications by reducing the amount of data that is transferred between the client and the server.

Step 7: Now we need to create a Service definition.

Step 8: Create a Service Binding.

Step 9: Showing the result.

The output will be in preview.

Now we need to create the data.

now we got the change request number for that we need to go to fiori launchpad or nwbc to see that cr number .

We can see the change request number in " My Change Request Monitoring" as shown in above picture.

Now click on the change request number it will go to the below screen.

click on "submit" button to process the workflow.

click on "workflow log"

After completion of all approvers BP Id going to generate.

This is the process going to run,
by the combination of RAP Application, Workflow & SAP MDG.