This is a test message to test the length of the message box.
Login
|
ABAP RAP Popup Default values
Created by Software-Heroes

RAP - Popup Default values

7036

How can you provide the user with default values in the popup of an action in RAP? In this article we will extend our application.

Advertising


In the last article, we expanded the popup in our application to include mandatory fields that are checked in the UI. In this article, we'll look at defining default values in the popup.

 

Introduction

When a user triggers an action in the Fiori Elements UI, you usually want to have some information from the user. To make life easier for the user, you can also provide default values in many situations so that the user receives suggestions for input and thus works faster. To do this, we will extend our Report Pattern app with another function.

 

Extension

In this section, we will extend our existing action and implement the logic for the values. Finally, we will run a test to validate the result.

 

Behavior definition

To do this, we will extend our current definition of the "LoadExcelContent" action in the behavior definition. We are currently using a simple action with a parameter, which ensures that a popup is displayed when triggered.

action LoadExcelContent parameter ZBS_S_DRPExcelPopup;

 

To do this, we add DEFAULT FUNCTION in curly brackets to define a new function in which we can set the default values.

action LoadExcelContent parameter ZBS_S_DRPExcelPopup { default function GetDefaultsForExcelPopup; }

 

The name of the function must begin with "GetDefaultsFor" or "GetDfltsFor". Here you already get the information

 

Behavior implementation

If you place the cursor on the name of the function, you can use CTRL + 1 to generate the method in the behavior implementation. Let's take a look at the signature of the new method.

 

We receive the keys of the currently selected entries and can return our values via RESULT. There, next to the key, you will find the %PARAM field, where our parameter structure is defined. To do this, we define a small logic that defines a standard for the comment with the current currency. In addition, the test run flag should always be set for the currency EUR.

LOOP AT keys INTO DATA(key).
  INSERT VALUE #( %tky = key-%tky ) INTO TABLE result REFERENCE INTO DATA(new_line).

  new_line->%param-EventComment = |Default event for { key-Currency }|.
  new_line->%param-TestRun      = SWITCH #( key-Currency
                                            WHEN 'EUR'
                                            THEN abap_true
                                            ELSE abap_false ).
ENDLOOP.

 

Projection

Now comes the most important step. So that the function can be called from the frontend, we have to release it in the projection of our RAP object to the outside. In this case, it is not an action, but a function. Accordingly, the implementation looks like this:

use function GetDefaultsForExcelPopup;

 

Test

Now that we have everything prepared, we can carry out the test in our application. To do this, we open the currency EUR and trigger the action. You can see the result here.

 

Complete example

You can find the complete application in our GitHub repository, we have made the changes to this article in the following commit. There you will find all changes and changed objects at a glance.

 

Conclusion

Setting the default values is easy and flexible with the function, but you also have to implement some logic rather than just a simple assignment. The user will now be able to work with your application faster.

 

Source:
SAP Help - Defaulting Input Parameters for Operations
SAP Community - Defaulting action parameters


Included topics:
RAPBTPPopupDefault valuesREX5
Comments (6)



And further ...

Are you satisfied with the content of the article? We post new content in the ABAP area every Tuesday and Friday and irregularly in all other areas. Take a look at our tools and apps, we provide them free of charge.


RAP - Implement Change Documents (native)

Category - ABAP

If you have the appropriate release, you can now implement change documents natively in RAP without much manual implementation. Let's look at the different steps.

04/24/2026

RAP - Auxiliary Class

Category - ABAP

As the implementation grows in the behavior implementation of a RAP object, what options do you still have for clean encapsulation? Let's look at this in detail.

04/17/2026

RAP - Implement change documents (Manual)

Category - ABAP

This article delves into the manual implementation of change documents in our RAP object and examines the various integration steps. The goal is to generate change documents automatically.

04/14/2026

RAP - Draft Query

Category - ABAP

In this article, we'll look at the Draft Query in RAP and how you can use it to control entries and their visibility. We'll also look at a practical example.

04/03/2026

RAP - Importance

Category - ABAP

Let's look at the importance of information within an SAP Fiori application and how we can use it to control visibility in the RAP application.

03/24/2026