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

RAP - Messages

12834

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 - CDS Pattern

Category - ABAP

How does the CDS pattern actually work, and what does CDS-only have to do with it? In this article, we'll look at the architecture and use of the pattern.

11/28/2025

Recycling Heroes - Contact App

Category - ABAP

In this tutorial, we'll model a RAP application from the database, through the model and UI, to deployment and provisioning in the system. This should teach you the full development cycle for modern ABAP Cloud applications.

11/25/2025

RAP - EML Variants

Category - ABAP

If you use EML to interact with the ABAP RESTful Application Programming Model, several variants are currently available. Let's take a closer look at them.

09/16/2025

RAP - Generator (from Scratch)

Category - ABAP

Does your development with RAP sometimes feel very slow? Generators do the work for you, building the actual stack and eliminating repetitive work.

08/05/2025

RAP - Action (Processing options)

Category - ABAP

How do you actually enable multi-select in RAP and control the various processing options? Here we'll look at the different options in the framework.

08/01/2025