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

RAP - Messages

14543

Let's take a look at the different possibilities of messages in the environment of Fiori Elements and how they work together.

Advertising


In the last article we implemented a static action and showed you how to get the parameters. In this article, we'll expand on the action to show you how notifications behave and how you can further influence it.

 

Introduction

If actions are carried out, they are not always successful because perhaps data for the new entity is still missing or not all entries have been made in the popup. In such cases, messages must be passed on to the user. But here it depends on what you want to tell the user and what context such messages take. The behavior is already defined accordingly in the Fiori Guidelines.

 

Typs

Let's take a look at the different types of messages we can generate through the framework. The first step is to take a look at the possibilities. Let's take a closer look at the "IF_ABAP_BEHV_MESSAGE" interface:

interface IF_ABAP_BEHV_MESSAGE public.
  interfaces IF_MESSAGE.
  interfaces IF_T100_DYN_MSG.
  interfaces IF_T100_MESSAGE.

  types:
    t_char01 type c length 1.
    
  types:
    begin of enum t_severity structure severity base type t_char01, "sychar01,
         none value is initial,
         error       value 'E',
         warning     value 'W',
         information value 'I',
         success     value 'S',
       end of enum t_severity structure severity.

  data M_SEVERITY type T_SEVERITY.
endinterface.

 

As you can see, the different types of messages are defined as ENUM, i.e. this ENUM is required to be passed to the message interface in order to generate the corresponding messages. Now let's take a look at the corresponding individual messages and behavior.

 

Success

The success message only appears as a toast in the lower area of the screen and disappears again automatically. It is created using the constant "if_abap_behv_message=>severity-success". A success message does not have to be confirmed separately in order not to interrupt the user's workflow if there are no problems.

 

Information

The information message is generated using the constant "if_abap_behv_message=>severity-information" and is normally displayed as a toast like the success message. In special cases, the message is displayed as a separate popup, but should also not disturb the flow of the user.

 

Warning

The warning is intended to point out possible problems, so it makes the user more alert and is shown in a popup, which has to be confirmed separately. In this case, the constant is "if_abap_behv_message=>severity-warning". The warning can be acknowledged or canceled.

 

Error

The error message draws the most attention because something went wrong during processing. The constant for this is "if_abap_behv_message=>severity-error". The error can only be aborted.

 

Combination

When it comes to complex processing, such messages are not alone, but usually an entire log is issued. Now let's generate two success messages for the output:

reported-partner = VALUE #(
  ( %msg = new_message_with_text( severity = if_abap_behv_message=>severity-success text = 'Dummy message' ) )
  ( %msg = new_message_with_text( severity = if_abap_behv_message=>severity-information text = 'Dummy message' ) )
).

 

The success messages are now output in a popup. Here you should think about whether you need both messages or reduce them to one message so as not to interrupt the flow of the user. However, if information such as document numbers is to be given to the outside, then this is fine.

 

Now let's try a more complex example and print all kinds of messages.

reported-partner = VALUE #(
  ( %msg = new_message_with_text( severity = if_abap_behv_message=>severity-success text = 'Dummy message' ) )
  ( %msg = new_message_with_text( severity = if_abap_behv_message=>severity-error text = 'Dummy message' ) )
  ( %msg = new_message_with_text( severity = if_abap_behv_message=>severity-warning text = 'Dummy message' ) )
  ( %msg = new_message_with_text( severity = if_abap_behv_message=>severity-information text = 'Dummy message' ) )
).

 

The message popup now behaves as follows, and not quite as expected:

 

The positive messages have been filtered and only warnings and errors can be seen. The user can thus focus fully on the error messages in order to work on correcting the error.

 

Validations

The messages generated so far come from an action, if we look back a few articles, we had already implemented messages for validations. The messages there are displayed differently in the UI:

 

Example

For the examples shown above, we have extended the "withPopup" method accordingly in order to generate the appropriate output via the MessageType parameter. Here is the implemented method again:

METHOD withPopup.
  TRY.
      DATA(ls_key) = keys[ 1 ].
    CATCH cx_sy_itab_line_not_found.
      RETURN.
  ENDTRY.

  CASE ls_key-%param-MessageType.
    WHEN 1.
      INSERT VALUE #(
        %msg = new_message_with_text( severity = if_abap_behv_message=>severity-success text = 'Dummy message' )
      ) INTO TABLE reported-partner.
    WHEN 2.
      INSERT VALUE #(
        %msg = new_message_with_text( severity = if_abap_behv_message=>severity-information text = 'Dummy message' )
      ) INTO TABLE reported-partner.
    WHEN 3.
      INSERT VALUE #(
        %msg = new_message_with_text( severity = if_abap_behv_message=>severity-warning text = 'Dummy message' )
      ) INTO TABLE reported-partner.
    WHEN 4.
      INSERT VALUE #(
        %msg = new_message_with_text( severity = if_abap_behv_message=>severity-error text = 'Dummy message' )
      ) INTO TABLE reported-partner.
    WHEN 5.
      INSERT VALUE #(
        %msg = new_message_with_text( severity = if_abap_behv_message=>severity-none text = 'Dummy message' )
      ) INTO TABLE reported-partner.
    WHEN 6.
      reported-partner = VALUE #(
        ( %msg = new_message_with_text( severity = if_abap_behv_message=>severity-success text = 'Dummy message' ) )
        ( %msg = new_message_with_text( severity = if_abap_behv_message=>severity-information text = 'Dummy message' ) )
      ).
    WHEN 7.
      reported-partner = VALUE #(
        ( %msg = new_message_with_text( severity = if_abap_behv_message=>severity-success text = 'Dummy message' ) )
        ( %msg = new_message_with_text( severity = if_abap_behv_message=>severity-error text = 'Dummy message' ) )
        ( %msg = new_message_with_text( severity = if_abap_behv_message=>severity-warning text = 'Dummy message' ) )
        ( %msg = new_message_with_text( severity = if_abap_behv_message=>severity-information text = 'Dummy message' ) )
      ).
  ENDCASE.
ENDMETHOD.

 

Conclusion

Messages can be prepared differently for the user, but they always show the same pattern and should work accordingly depending on the context. As in the classic UI, how messages are generated is very simple.


Included topics:
RAPBTPMessagesREX1
Comments (0)



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.


ADT - RAP Extension Assistent [MIA]

Category - ABAP

You want to extend a RAP object and don't know exactly where to start? Perhaps the Extension Assistant can help you and guide you through the process step by step.

03/06/2026

ADT - RAP Analyzer [MIA]

Category - ABAP

Getting to grips with and understanding existing RAP objects can not always be easy, especially when dealing with complex objects. Questions such as which pattern is used and which objects are important usually need to be worked out.

02/24/2026

RAP - Position of Buttons

Category - ABAP

In this article, we'll look at the different button positions. Where can we place the various actions in RAP, and how do we use them?

02/17/2026

RAP - Analytical Table

Category - ABAP

Let's take a look at the last missing piece of the puzzle in RAP to replace the ALV and how we can set up the Analytical Table with minimal effort.

02/13/2026

RAP - Mixed Content

Category - ABAP

How do we actually get different content into the same column in the List Report? Let's look at a practical example using our Sales App.

02/10/2026