cancel
Showing results for 
Search instead for 
Did you mean: 

how to show information msg to user when the mandatory field is not fielded

Former Member
0 Kudos

Hi all,

Is anyone know how to show the information message to the users in the screen when the mandatory field is not entered by user in the screen?

For example, when a field Title is not entered, we need to show information message/error message : "Please fill in the mandatory field."

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

uday_gubbala2
Active Contributor
0 Kudos

Hi,

You need to call the static method check_mandatory_attr_on_view of class cl_wd_dynamic_tool. This would then automatically verify if all the mandatory fields have been filled or not. It would then populate the error messages into an internal table and display them in the view. Also the mandatory fields which haven't been filled would be highlighted with a red border. You need to put the below coding into the action up on which you want to trigger the data chesks.

data: lt_msg TYPE cl_wd_dynamic_tool=>t_check_result_message_tab,
          lo_view_controller TYPE REF TO if_wd_view_controller,
          lo_message_manager type ref to if_wd_message_manager.
 
  lo_view_controller ?= wd_this->wd_get_api( ).
  lo_message_manager = lo_view_controller->get_message_manager( ).
 
  cl_wd_dynamic_tool=>check_mandatory_attr_on_view(
    EXPORTING
      view_controller = lo_view_controller
      display_messages = abap_true
    IMPORTING
      messages = lt_msg ).

Regards,

Uday

Former Member
0 Kudos

thanks very much guys! very helpful and answer solved!

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

there are several forum entries handling this problem. So maybe you will find additional information there...

I'm using the following coding in my event:


  data: lt_msg TYPE cl_wd_dynamic_tool=>t_check_result_message_tab.
  data: lo_view_controller TYPE REF TO if_wd_view_controller.

  lo_current_controller ?= wd_this->wd_get_api( ).
  lo_message_manager = lo_current_controller->get_message_manager( ).
  lo_view_controller = wd_this->wd_get_api( ).

  cl_wd_dynamic_tool=>check_mandatory_attr_on_view(
    EXPORTING
      view_controller = lo_view_controller
      display_messages = abap_true
    IMPORTING
      messages = lt_msg ).

And I set the field as mandatory in the attributes (state = required)

Regards,

Andreas