RAP Interview Questions

What are the main components of SAP RAP?

CDS Views: Define data models and exposure layers.

Behavior Definition & Implementation: Define and implement business logic (CRUD operations, validations, etc.).

Service Definition & Binding: Define and expose services for consumption.

Metadata Extensions: Enhance the UI annotations for Fiori elements.

Write an EML statement to read from an entity?

  READ ENTITIES OF /DMO/R_Travel_D IN LOCAL MODE
      ENTITY Travel
        FIELDS (  BeginDate EndDate TravelID )
        WITH CORRESPONDING #( keys )
      RESULT DATA(travels)
      FAILED DATA(failed)
      REPORTED DATA(reported).

// The addition IN LOCAL MODE ensures that a BO is accessed directly without checking access control, authorization control or feature control or prechecks. 

What is Instance Feature Control in RAP?

An instance feature in ABAP RAP is a dynamic control that determines the state of an UI element (like a button or field) for a specific record (instance) based on its data. A common example is a “Set to Booked” button in a travel application that is only enabled for a travel instance if its status is not already “Booked”. To implement this, you declare the action with features:instance in the behavior definition and then implement the get_instance_features method in the behavior implementation class to return the feature’s state for each specific instance.

// Behaviour Definition Example
ACTION ( features : instance ) SetStatusToBooked result [1] $self;

// Behaviour Implementation Example

// get_instance_features definition
METHOD get_instance_features FOR INSTANCE FEATURES IMPORTING keys REQUEST requested_features FOR travel RESULT result.


// get_instance_features implementation
METHOD get_instance_features
  " Logic to determine feature state based on instance data goes here
  " Example: Enable the button only if the status is not 'Booked'
  READ ENTITIES OF zi_travel IN LOCAL MODE
    ENTITY Travel
    FIELDS ( Status )
    WITH CORRESPONDING #( keys )
    RESULT DATA(travels).

  LOOP AT travels ASSIGNING FIELD-SYMBOL(<ls_travel>).
    DATA(lv_is_booked) = <ls_travel>-Status = 'Booked'.
    IF lv_is_booked = abap_true.
      result[ 1 ]-%setstatus_to_booked-%active = abap_false. " Button disabled
    ELSE.
      result[ 1 ]-%setstatus_to_booked-%active = abap_true.  " Button enabled
    ENDIF.
  ENDLOOP.
ENDMETHOD.

What is Value Help with Additional Binding?

We use an additional binding to define more than one binding condition between the source view and the value help provider. The value help is then automatically filtered by the additional binding. It proposes only entries that match the additional binding. This additional binding can either be another element or a parameter. These need to be present in the source view and in the value help provider view. When an entry is selected in the value help provider, the values of both binding elements are transferred to the input fields of the source CDS view.


The value help provider view contains the connection ID and the carrier ID, for which a mapping condition is defined.
define view /DMO/I_Connection_VH as select from /dmo/connection 
{
key carrier_id, 
key connection_id, 
airport_from_id, 
airport_to_id, 
departure_time, 
arrival_time, 
distance, 
distance_unit
}


define view /DMO/I_Booking_VH as select from /dmo/booking 
{… 
    @Consumption.valueHelpDefinition: [{ entity: {name: '/DMO/I_Connection_VH' , element: 'connection_id' },
                   additionalBinding: [{ localElement: 'CarrierID', element: 'carrier_id', usage: #Filter }]
                }]
connection_id as ConnectionID, 
… }

What is the use of Strict Mode in the Behaviour definition?

managed implementation in class cl_bp_r_budgetdocumenttp unique;
strict ( 2 );
with draft;

BDEF strict mode applies additional syntax checks to RAP behavior definitions. It ensures, for example, that no outdated syntax is used, implicitly available operations are declared explicitly, and the RAP BO in question complies to best practices. BDEF strict mode is provided by the RAP framework, no implementation in an ABAP behavior pool is required. Currently, the following versions of strict mode are available:

Strict mode version 1, specified using strict
Strict mode version 2, specified using strict(2)
Strict mode version 2 covers all rules from strict mode version 1, plus some additional checks.

How to define an API class in RAP?

Class Zcl_student_api_class definition
PUBLIC
FINAL
CREATE PUBLIC.

PUBLIC SECTION.
// create constructor
CLASS METHODS: get_instance 
         RETURING VALUES (ro_instance)
         TYPE REF TO Zcl_student_api_class .

PROTECTED SECTION.
PRIVATE SECTION.
 CLASS DATA mo_instace TYPE REF TO Zcl_student_api_class .
Class Zcl_student_api_class IMPLEMENTATION.

METHOD get_instance .
mo_instance  = ro_instance = COND #( WHEN mo_instance is BOUND
                                     THEN mo_instance 
                                     ELSE new #( )).

END METHOD.

ENDCLASS.


What is early Numbering in an Unmanaged scenario?

Early numbering is implemented by adding the keyword EARLY NUMBERING in the entity.
Automatcilly assign a key to Bussiness Object Entity inatance during Create , create by Association.
Keys are genrated in interaction phase of RAP.

// Create method gets genrated if EARLY NUMBERING key word is used in BDEF.
METHODS earlynumbering_create FOR NUMBERING 
        IMPORTING ENTITIES for CREATE students.

//  Create By Assocoation is genrated if Assocoation is there
METHODS earlynumbering_cba_results FOR NUMBERING 
        IMPORTING ENTITIES for CREATE students/_Results.

What is Late Numbering?

  • The RAP runtime engine assigns values to the primary key fields.
  • In the ABAP behaviour pool, the RAP saver method adjust_numbers must be implemented to assign a final primary key value for each entity instance.
  • The key value for an instance is assigned just before the instance is saved on the database. Thus, a gapless assignment of unique keys is ensured.
  • Late numbering is available for managed and unmanaged implementation scenarios with and without draft. ref blog

When does dose validation trigger in Managed and Unmanaged Scenarios in RAP?

Managed Scenario – In Managed Scenario, the final check of all involved BOs is done via validations. Validations are called during CHECK_BEFORE_SAVE method. But check_before_save method is not visible in the Managed Scenario.

Unmanaged Scenario – In Unmanaged Scenario, the final check for all involved BOs is done in CHECK_BEFORE_SAVE method. A validation is automatically invoked by the RAP framework if the trigger condition of the Validation is fulfilled( CREATE, UPDATE, DELETE ). Validations have two parameters – FAILED and REPORTED. Validation is implemented in both Managed and Unmanaged, but in Unmanaged, it can be implemented only if it has DRAFT capability in RAP BO.

In the DRAFT scenario, we have a special action ‘PREPARE’ which calls Determination and Validation. Syntax to write in BDEF is – Draft Determine Action PREPARE.

When does dose Determination trigger in Managed and Unmanaged Scenarios in RAP?

Determination can be created in two types: on Save and on Modify
on Save – On Save determination will trigger at the time of save. When we need to calculate/update the value of any field and show the updated value on the frontend after the actual save.
on Modify – On Modify, determination will trigger before save. When we need to calculate/update the value of any field and show the updated value on the frontend before the actual save.

DETERMINATION Trigger Condition
Create , Update, Delete, Field(Change of Mentioned Field)

Draft determine action Prepare { }- whenever we create Determination or validation using ‘on SAVE’ method, we need to call it inside Method’ Draft determine action Prepare { }’ . other wise it will not trigger.

When we write determination on modify, we don’t need to trigger it inside ‘Draft determine action Prepare{ } ‘.
There is one issue with determining on Modify . The value of the edited field is not updated as soon as we press Enter on UI. To update this value, we need to write SIDE EFFECT.

eg – side effect {field Course affects field Courseduration; }

What is the significance of CHECK_BEFORE_SAVE?

Managed Scenario – Validations are called during the CHECK_BEFORE_SAVE method. Unmanaged Scenario – Validations are called during the CHECK_BEFORE_SAVE method with FAILED and REPORTED parameters. The CHECK_BEFORE_SAVE method is called during the SAVE sequence. If the method returns error in FAILED parameter, SAVE sequence is terminated and CLEANUP_FINALIZE method is called.

What is Draft Determine Action PREPARE?

Execute the Determination and Validation in the behaviour definition.
The PREPARE action enables validating only Draft data(before it becomes active data).
PREPARE Action ensures data consistency before going to the SAVE method.
In the Unmanaged Scenario, Determination and Validations are called only inside the PREPARE action.

What are the different implementation types in RAP?

There are three implementation types:

Unmanaged (Brownfield): Developer handles all database operations manually; useful for legacy data models.

Managed (Greenfield): RAP handles most CRUD operations automatically.

Managed with Custom Logic: RAP handles CRUD, but you can inject custom logic at specific points.

What is the difference between Managed and Unmanaged scenarios in RAP?

Managed: SAP framework handles CRUD operations. You provide custom logic where needed.

Unmanaged: Developer handles all logic, including CRUD. Suitable for reusing legacy code or existing tables.

What are behavior definitions and behavior implementations in RAP?

Behavior Definition (behavior definition): Describes what operations are allowed (create, update, delete, etc.), validations, actions, etc.

Behavior Implementation (class ... implementing ...): Contains the actual ABAP code that executes the logic defined.

What is a late numbering scenario in RAP?

Late numbering is used when the primary key of an entity (e.g., GUID) is generated after the data is saved to the database (usually by the backend system or database trigger). RAP supports this by deferring the key assignment until the transactional commit.

How is transactional consistency maintained in RAP?

SAP RAP uses a Unit of Work (UoW) concept to collect all changes (insert/update/delete) and commit them together. If any operation fails, the entire transaction is rolled back, ensuring consistency.

What is the purpose of the service definition and service binding in RAP?

Service Definition: Specifies which data models and behaviors are exposed as a service.

Service Binding: Defines how the service is exposed (e.g., OData V2/V4, UI, etc.) and connects the service to a communication protocol.

What are the Side effects of RAP?

Side effects are used to reload data, permissions, or messages or trigger determine actions based on data changes in UI scenarios with draft-enabled BOs. Since draft-enabled scenarios use a stateless communication pattern, the UI doesn’t trigger a reload of all BO-related properties for every user input. If only certain fields are changed by the end user in edit mode, that is on the draft BO instance, the user can’t expect data consistency of displayed data on the UI at all times. In other words, when a UI user changes data of a draft instance, there is not necessarily a READ request for all fields that are displayed. Without side effects, this may lead to inconsistencies in the displayed data on the draft instance, for example, when data is calculated based on other fields.

Side effects solve this problem. They define the interdependency between fields and other BO characteristics to trigger a reload of affected properties. In particular, side effects are efficient since there is no full reload of all BO properties, but only of those that are affected by particular user input.

What are some useful ADT shortcut keys?

Ctrl + Shift + A -> Open development object
Ctrl + 7 -> Comments/Uncomments selected lines
Alt + Shift + R – Rename
Alt + Shift + M – Extract Method
Ctrl + D -> deletes the current line. No selection required
Alt + Up/Down -> moves the current line up or down. No selection required
Alt + Left/Right Move forward or backward through the navigation history
Ctrl + 1 -> quick fix suggestions
Ctrl + 2 -> in file Quick fix Keyword/Code completion
 

Keyword/Code completion Shortcuts


Tab
To select the initial suggestion of the  Keyword or code completion suggestion
Ctrl + Space
To get more suggestions from the Keyword or code completion suggestion(includes suggestions from the Static Code Templates)
Shift + Enter
To insert the full signature of the code completion suggestion
Useful for Function Modules, Class Methods.
Enter
To insert only the name of the selected item from the code completion suggestion
 

Reference SAP ADT Shortcut Keys

What are Action types in RAP?

Actions can be categorized in two main types :
Non-factory actions:  We use this when, custom logic needs to be implemented and used to change the state of the instance.

Factory Action: Factory actions are used to create RAP BO entity instances.

  1. Instance-Bound Actions: An instance-bound factory action used to copy one or more BO instances and create new instances based on the copied data.

2. Static Actions: Static factory actions can be used to create instances with default values.

3. Factory Actions does not have any return parameter.

What is Save_Modified, RAP Saver Method?

It is only available for managed scenarios that include an additional or unmanaged save implementation. In this case, the RAP saver method
save cannot be used.

What is CDS Abstract Entity in RAP?

In the Context of RAP, Abstract Entities are used as parameters of RAP actions, RAP functions, and RAP business events. eg- to create pop up in RAP. Abstract entities are non-SQL CDS entities. It is not created as a database object, hence client handling is not defined. A CDS abstract entity can be used as a global structured type in an ABAP programme.

@EndUserText.label: 'leased mass update'
define abstract entity zd_som_leased_mass
{
  @EndUserText.label: 'Duration'
  @ObjectModel.mandatory: true
  Duration    : zsom_duration;
  @EndUserText.label: 'Price'
  @ObjectModel.mandatory: true
  Price       : zsom_output_value;
}

What are ABAP units?

Identify dependent-on components (DOC) in your production code (i.e. your class/method) that need to be tested, and prepare the code for testing. Examples of DOCs: In your production code, a method is called that is outside of your code. Or, for example, whenever there is an interaction with the database. This means that there are dependencies that need to be taken into account for a unit test. These dependencies should be isolated and replaced by a test double. Create/Implement test doubles. You can create test doubles manually. For example, you hardcode the test data to be used when the test is executed. You can also use ABAP frameworks that provide a standardized approach to creating test doubles. Ideally, the testability of your code has been prepared by providing interfaces to the DOC. Interfaces facilitate the testability because you can simply implement the interface methods. Inject the test doubles to ensure that the test data is used during the test run. Create test classes and methods

Reference ABAP UINIT

Run unit tests

Reference SAP ADT Shortcut Keys

Scroll to Top