Skip to end of metadata
Go to start of metadata

Frequently  we need to make some of the fields in layout of a view are mandatory.To do this every element has a property state(Normal item  and Required ) to make the field is optional or mandatory.Although we select the option Required of state of field  property  to make the element mandatory.It will not trigger the error message even the field is not filled with any value when you are continuing with the 'Submit'  button of the form .

To trigger the error message when the user is leaving the blank value in the mandatory field and continuing with the form.Write the logic given below in the 'OnAction' event of event handler method to raise the error message that 'Fill in all required entry fields' .


* Data declaration


lo_view_controller type ref to if_wd_view_controller,

lo_dyn type ref to cl_wd_dynamic_tool.

* Create Object

create object lo_dyn.

data lt_messages type lo_dyn->t_check_result_message_tab.

* Get view controller reference

lo_view_controller = wd_this->wd_get_api( ).

* Call Method to verify the element has the value or not

call method cl_wd_dynamic_tool=>check_mandatory_attr_on_view


view_controller = lo_view_controller

display_messages = ABAP_TRUE


messages = lt_messages .