logo

Are you need IT Support Engineer? Free Consultant

RAP Recommendations – SAP Community

  • By sujay
  • 23/05/2026
  • 18 Views

Sometimes, filling out forms is quite cumbersome. Like when you need to select the country you live in from a dropdown and scroll through all the countries, while you know that the application could have just preselected the country. Going further, would it not be great to write a description of where you are traveling and have recommendations for the city automatically generated, such as accommodations or restaurants?

To achieve this, RAP recommendations are available with SAP BTP ABAP environment 2602 and SAP S/4HANA Cloud 2602. RAP recommendations are an input assistance that proposes field values for input fields in a RAP application on an SAP Fiori UI. The proposed field values are based on the user input and the interaction history.

Motivation

Before the introduction of RAP recommendations, business users had to manually enter input into input fields or select values from a value help. The problem with that is:

  • Data entries may differ slightly from user to user.
  • Thinking about each entry is not efficient.
  • Finding the right terms is challenging.

By providing RAP recommendations, these difficulties are improved:

  • Data entries are consistent.
  • Business users' efficiency is increased by consistency and the proposed values.
  • The most likely value is predicted from the data context.

RAP recommendations enrich value helps with context-aware suggestions. Currently, there are two approaches to implement RAP recommendations: generative AI and deterministic rules.

Implementation

Before implementing RAP recommendations in your application, we need to look at the prerequisites and steps.

Prerequisite

RAP recommendations are built on top of a value help. Therefore, you need to have a value help implemented for the same field where you want to implement the RAP recommendation.

Steps

  1. Define RAP recommendations in the behavior definition.
  2. Implement RAP recommendations in the behavior pool of your RAP business object (using generative AI or deterministic rules).
  3. Define RAP recommendations in the projection behavior definition.

To understand RAP recommendations in detail, you can download the ABAP Flight Reference Scenario (GitHub) for RAP recommendations on GitHub. There, RAP recommendations are used in a travel example: After typing a description, generative AI suggests a destination, and then another RAP recommendation is triggered, suggesting accommodations using deterministic rules. Below is this example in a shorter form.

Example

This example shows the implementation of RAP recommendations using generative AI and deterministic rules. As mentioned above, you can download this example on GitHub. The following screenshot shows the RAP application requesting travel information.

RAP Recommendations

In the example, the business user selected Bulgaria as the destination. Right after the selection, three (fictive) accommodation recommendations for Sofia appear, and the business user can select the most fitting entry. Now, we will get through the implementation details step by step.

Behavior Definition

Define the field for which you want to provide RAP recommendations:

field ( recommendations ) Destination, Accommodation;

Here, the two fields Destination and Accommodation are specified to show the recommended values on the UI.

Define the function that runs the behavior:

recommendation function GetRecommendedValuesFunction;

Hint: Only one function can be specified for the recommended values.

Define side effects to specify which field change triggers the recommendation function:

side effects
  {
    recommendation function GetRecommendedValuesFunction
      executed on field Description, field Destination;
  }

The input for the recommended values is based on the two fields Description and Destination.

Behavior Pool

Define how the recommended values are returned:

METHOD GetRecommendedValuesFunction.
    READ ENTITIES OF /dmo/r_traveltp_rec IN LOCAL MODE
       ENTITY Travel
       FIELDS ( Description Destination ) WITH CORRESPONDING #( keys )
       RESULT DATA(business_user_travel)
       FAILED failed.

    "...

    LOOP AT business_user_travel ASSIGNING FIELD-SYMBOL().
      "...

      INSERT VALUE #(  %tky = -%tky
                       %param-travel = VALUE #( destination = CORRESPONDING #( destination_rec_values )
                                                accommodation = CORRESPONDING #( accommodation_rec_values ) ) ) INTO TABLE result.
    ENDLOOP.
ENDMETHOD.

The fields Description and Destination of the Travel entity are read and returned in the business_user_travel internal table. Inside the LOOP statement, the transactional key %tky and the result parameter %param for the component travel are filled.

You can find a description of the complete example in Example: Implementing RAP Recommendations (SAP Help Portal).

Deterministic Rules

For the deterministic rules approach, you can, for example, simply implement a query with a condition against your business user data. For example:

SELECT DISTINCT acc_name
          FROM /dmo/acc_rec_h AS accommodation
          INNER JOIN _user_travel AS destination
          ON accommodation~acc_country = destination~Destination
        INTO TABLE @result.

In this query, the Destination value is compared with the generated acc_country value.

Generative AI

To use the generative AI approach, you need to set up a scenario using the ABAP AI SDK (SAP Help Portal). In your Intelligent Scenario Lifecycle Management (ISLM) scenario, you can define prompt settings that are used to call the LLM Completion API. When the call is successful, the LLM's answer is returned. For example:

METHOD get_completion_ai.
    DATA(completion_api_instance) = get_completion_api_instance( ).

    IF completion_api_instance IS BOUND.
      TRY.
          DATA(completion_api_result) = completion_api_instance->execute_for_string( prompt_setting ).
        CATCH cx_aic_completion_api.
          RETURN result.
      ENDTRY.

      result = completion_api_result->get_completion( ).
    ENDIF.
  ENDMETHOD.


  METHOD get_completion_api_instance.
    TRY.
        result = cl_aic_islm_compl_api_factory=>get( )->create_instance( 'MyIntelligentScen' ).
      CATCH cx_aic_api_factory.
        RETURN result.
    ENDTRY.
  ENDMETHOD.

You can find a description of the complete example in Example: Implementing Generative AI Features for RAP Recommendations (SAP Help Portal).

Recommended Values

The recommended values expect a certain set of parameters:

INSERT VALUE #( value = 
                score = 100 - counter
                suggested = COND #( WHEN counter = 1
                                    THEN abap_true
                                    ELSE abap_false ) ) INTO TABLE result.

value is a mandatory parameter and contains the recommended value. score and suggested are optional parameters. Using score, you can order the recommended values in the value help. Using suggested, you can enter a recommended value directly into the input field.

Projection Behavior Definition

To reuse RAP recommendations in the projection behavior definition, you need to add the following:

use recommendations;
use side effects;

Resources

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *