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

RAP - Messages

15750

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.


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