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

7834

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 - Sales App Learnings

Category - ABAP

The tutorial for the Sales App has come to an end, and this time a wide range of topics and areas were covered. In this article, we'll review what we learned and highlight some key points.

09/08/2026

052: 10 Minutes from Start to Launchpad

Category - YouTube

In this episode, we'll look at how we can create a RAP application within 10 minutes, generate and deploy it, and finally launch it in the Launchpad.

09/07/2026

RAP - Navigation (App to App)

Category - ABAP

How can you navigate to another application within your Fiori application without the user having to manually switch apps? Let's take a look at navigation between Fiori apps.

09/01/2026

ABAP in Practice - Creating a Setup App

Category - ABAP

No more SAP GUI? How do we then create a static setup app while still remaining flexible on the ABAP side for further implementation? Here's a practical example.

08/28/2026

RAP - Singleton Pattern

Category - ABAP

The Singleton pattern in rap has been around for a while, but how exactly does it work and how can you use it for other purposes? Let's take a closer look at the details in this article.

08/25/2026