cancel
Showing results for 
Search instead for 
Did you mean: 

Error Message

Former Member
0 Kudos

Hello All.

How to generate error message?

If the user enters a wrong value for a field how to generate error message.

Regards,

SampathKumar G.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Thank You all. Got it resolved.

uday_gubbala2
Active Contributor
0 Kudos

Hi Sampath,

To display messages to the user you need to work with the methods of IF_WD_MESSAGE_MANAGER class. You can make use of the Code Wizard for simplifying the process for you.

Just select the, "Generate Message" radio button from within the popup that you get when you start the code generator.Next you need to select any 1 particular method of IF_WD_MESSAGE_MANAGER which you want to use for displaying the messages. Just do an F4 click on the "Method" radiobutton. Some of the methods are now obsolete so just go through the descriptions while selecting a message.

Once you select a method & press on enter. The system would generate the coding for you automatically.

For example when you select the method as REPORT_ERROR_MESSAGE the system generated the coding as shown below:

* get message manager
DATA: l_current_controller TYPE REF TO if_wd_controller,
      l_message_manager    TYPE REF TO if_wd_message_manager.

l_current_controller ?= wd_this->wd_get_api( ).

CALL METHOD l_current_controller->get_message_manager
  RECEIVING
    message_manager = l_message_manager
    .

* report message
CALL METHOD l_message_manager->report_error_message
  EXPORTING
    message_text             = 'My message Text'.
*    PARAMS                   =
*    MSG_USER_DATA            =
*    VIEW                     =
*    SHOW_AS_POPUP            =
*    IS_PERMANENT             =
*    SCOPE_PERMANENT_MSG      =
*    CONTROLLER_PERMANENT_MSG =
*    MSG_INDEX                =
    .

Regards,

Uday

Former Member
0 Kudos

Hi,

Use REPORT_ATTRIBUTE_ERROR_MESSAGE method of interface IF_WD_MESSAGE_MANAGER to report error message. Also refer the standard component: WDR_TEST_MSG_MANAGER_00.

  • get message manager

DATA lo_api_controller TYPE REF TO if_wd_controller.

DATA lo_message_manager TYPE REF TO if_wd_message_manager.

lo_api_controller ?= wd_this->wd_get_api( ).

CALL METHOD lo_api_controller->get_message_manager

RECEIVING

message_manager = lo_message_manager

.

  • report message

CALL METHOD lo_message_manager->report_attribute_error_message

EXPORTING

message_text = ' Error Text'

element = lo_el_context

attribute_name = '<ContextAttribute_name>' " Give attribute name here

it will help you.

or you can try like this also

  • get message manager

DATA lo_api_controller TYPE REF TO if_wd_controller.

DATA lo_message_manager TYPE REF TO if_wd_message_manager.

lo_api_controller ?= wd_this->wd_get_api( ).

CALL METHOD lo_api_controller->get_message_manager

RECEIVING

message_manager = lo_message_manager

.

  • report message

CALL METHOD lo_message_manager->report_error_message

EXPORTING

message_text = 'Error_Text' " Give your error text here

  • params =

  • msg_user_data =

  • is_permanent = ABAP_FALSE

  • scope_permanent_msg = CO_MSG_SCOPE_CONTROLLER

  • view =

  • show_as_popup =

  • controller_permanent_msg =

  • msg_index =

  • cancel_navigation =

  • enable_message_navigation =

  • receiving

  • message_id =

.

You can also refer to this thread:-

[]

Former Member
0 Kudos

Hi,

Please refer to the standard interface, IF_WD_MESSAGE_MANAGER...

REPORT_ERROR_MESSAGE - To display the common error message.

REPORT_ATTRIBUTE_ERROR_MESSAGE - To display attribute specific message with respect to the UI Element.

CALL METHOD

wd_this->lo_message_manager->report_attribute_error_message

EXPORTING

message_text = iv_message

element = iv_element

attribute_name = lv_attribute.

REPORT_ELEMENT_ERROR_MESSAGE - To display error message for a group of UI elements in the view.

data : lt_string_tab type string_tab.

data : lo_el_nd_clear_det_ass type ref to if_wd_context_element.

append <attributename1> to lt_string_tab.

append <attributename2> to lt_string_tab.

....

CALL METHOD

wd_comp_controller->lo_message_manager->report_element_error_message(

message_text = ls_return1-message

element = lo_el_nd_clear_det_ass

attributes = lt_string_tab ).

There are many other error message format methods are there...in this standard interface.

Regards,

Divya.S