Table Maintenance - Error Handling Explained

In any exit method, DATA, UPDATE or META, you can (and should) implement error handling and show an error message to the user. You can utilize the changing parameter CT_MESSAGES to show messages.

Our Table Maintenance BAdI blog series in overview

  1. Table Maintenance - How to Implement a BAdI (general overview)
  2. Table Maintenance BAdI - Meta Method Explained
  3. Table Maintenance BAdI - Data Method Explained
  4. Table Maintenance BAdI - Update Method Explained
  5. Table Maintenance BAdI - Error Handling Explained

Visual Types

Currently, “modal” and “toast” visual types are available 

  • /nly/cl_table_rest_v3=>co_visu_type_modal to show a popup with ok button

Modal error message

  • /nly/cl_table_rest_v3=>co_visu_type_toast to show a dialog without user interaction

Toast error message

Message Types

Furthermore, you can use the following message types to indicate the severity of the message:

  • /nly/cl_table_rest_v3=>co_msg_type_info (no colour)
  • /nly/cl_table_rest_v3=>co_msg_type_success (green)
  • /nly/cl_table_rest_v3=>co_msg_type_warning (yellow)
  • /nly/cl_table_rest_v3=>co_msg_type_error (red)

CT_MESSAGES Explained

The messages are passed using the CT_MESSAGES table. You can find CT_MESSAGES parameters in the table below.

Property

Type

Description

Possible Values

TYPE

CHAR 30

Message Type

warning - Warning

error - Error

info - Info

success - Success

VISU_TYPE

CHAR 30

Visualisation Type

modal - popup with ok button

toast - modal without user interaction

HDR

STRING

Message Header

 

MSG

STRING

Message

 

ADD_INFO

STRING

Additional information

NextLytics internal use only

 

Code example

You can find an example of the code below

DATA:ls_message TYPE /nly/ts_message.
ls_message = VALUE #( hdr = 'Title'
msg = 'Message'
type = /nly/cl_table_rest_v3=>co_msg_type_error
visu_type = /nly/cl_table_rest_v3=>co_visu_type_modal
) .
APPEND ls_message TO ct_messages.

You can use this approach to add a message to your DATA exit, as shown below. In this example, no data should be shown in November. Data processing will be skipped using the E_SKIP parameter and an error message will be shown to the user.


IF i_step = 1.
IF sy-datum+4(2) = '11'.

e_skip = 'X'.
ct_messages = VALUE #( BASE ct_messages
( type = /nly/cl_table_rest_v3=>co_msg_type_error
visu_type = /nly/cl_table_rest_v3=>co_visu_type_toast
hdr = 'Planning not allowed'
msg = 'Planning round is over, no values will be displayed'
).

ENDIF.
ENDIF.

Planning not allowed

NextTables BAdI Reference