cancel
Showing results for 
Search instead for 
Did you mean: 

Mandatory Fields in WD4A

Former Member
0 Kudos
56

hi all,,

I have added 1 custom field in ESS standard create travel request form. it is in WD4A and i have to make that field mandatory . i have specified the state property of this UI as 'Required', The UI is DropDownByKey. but still it is allowing to navigate in the next view even if i have not selected any value and in this fields (i.e the fields is blank). How to stop this navigation????.

also other standard mandatory fields of this view come up with red Color (*) before field but my custom fields is not.. So is there any way to achieve this??

Accepted Solutions (1)

Accepted Solutions (1)

hyun-soo_kim
Explorer
0 Kudos

Hi..

Use the method 'check_mandatory_attr_on_view' in the class 'cl_wd_dynamic_tool'.

Soo.

Answers (4)

Answers (4)

Former Member
0 Kudos

solved

uday_gubbala2
Active Contributor
0 Kudos

Hi Michell,

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

Hi...

Go through this link...

[;

Hope it helps....

Regards,

Rohit

Former Member
0 Kudos

Hi,

Changing the UI element to mandatory doesn't mean that it would really be mandatory. The mandatory flag just adds the red mark next to the UI element. If you want to achieve "mandatory functionality" you need to add some code to your WD component. For example, when you navigate to next view, you need to check if the input field is initial, and if it is, produce an error message.

Regards,

Pa