cancel
Showing results for 
Search instead for 
Did you mean: 

Displaying messages for input fields

Former Member
0 Kudos

Suppose there are some mandatory input fields in the view, and If user doesnt enter particular one or more fields then it should display some message for user to enter that field otherwise validation should not proceed for first view.

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Yes. There is a helper class to perform the required check and issue the appropriate messages.

CL_WD_DYNAMIC_TOOL=>CHECK_MANDATORY_ATTRIBUTES or CL_WD_DYNAMIC_TOOL=>CHECK_MANDATORY_ATTR_ON_VIEW

You can read about it here:

http://help.sap.com/saphelp_nw70ehp1/helpdata/en/d7/ef8841e3af1609e10000000a155106/frameset.htm

Former Member
0 Kudos

Hi Thomas,

Thanx this link was useful to me.But I want to display message for for each input field whiever is not entered. Like carrid is mandatory ,connid in mandatory,etc where do I write such logic for each input field?

I used this method cl_wd_dynamic_tool=>check_mandatory_attr_on_view.

Former Member
0 Kudos

Hi JohnRight,

Pleace below code inside wddomodifyview.


  DATA : l_view_controller TYPE REF TO if_wd_view_controller,
         lv_messages TYPE cl_wd_dynamic_tool=>t_check_result_message_tab.

  l_view_controller = wd_this->wd_get_api( )  .

  CALL METHOD cl_wd_dynamic_tool=>check_mandatory_attr_on_view
    EXPORTING
      view_controller  = l_view_controller
      display_messages = abap_true
    IMPORTING
      messages         = lv_messages.

Local varibale lv_messages will contains all the attribute names which are mandatory but not filled by user. Yo can loop all the records in lv_messages.


Loop at lv_messages.
        Print errors using WD message manager and Report T100 messages - 
        LV_MESSAGES[<LoopIndex>]-ATTRIBUTE_NAME
endloop.

Thanks,

Prashant

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

u can write logic like this.

LOOP AT it_message_tab INTO wa_message_tab.

CASE wa_message_tab-attribute_name .

WHEN 'CARRID'.

l_message-context_element = wa_message_tab-context_element.

l_message-attribute_name = wa_message_tab-attribute_name.

l_message-t100_message-msgty = 'E'.

l_message-t100_message-msgid = ''.

l_message-t100_message-msgno = '046'.

IF l_message_manager IS BOUND.

l_message_manager->report_attribute_t100_message(

msg = l_message-t100_message

element = wa_message_tab-context_element

attribute_name = wa_message_tab-attribute_name ).

endloop.