cancel
Showing results for 
Search instead for 
Did you mean: 

Making input field mandatory

Former Member
0 Kudos

hi

myself devendra , i am beginner to wdabap,i just want to know that how we can make the input field, in view, mandatory.

what r the steps for that?

hope i 'll get some replies....

thanks

Accepted Solutions (0)

Answers (3)

Answers (3)

uday_gubbala2
Active Contributor
0 Kudos

Hi Devendra,

Please try to search in the forum before you post any question. This issue has been discussed many times even earlier. You would have found your solution faster had you directly searched int he forum instead of waiting for any responses to your question.

Anyways 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,

U can also make the input field mandatory or

not at runtime using the property state

00 - Normal Item

01 - Mandtory field

CALL METHOD lo_el_nd_<nodename>->set_attribute

EXPORTING

name = <binded attribute name>

value = 00 " Normal Item

01"Mandatory Item

Thanks,

Divya.S

shaik_sajid
Active Contributor
0 Kudos

hi

in the view, for the input field, u can find the ui properties on the right side....over there, there is a property called STATE. So set it for making mandatory.

Regards

Sajid

Former Member
0 Kudos

Hi,

Select your inputfield uielement and set the State property to required . Now you will see a (*) symbol next to your inputfield label.

now place the following code in the WDDOBEFOREACTION Method

DATA: l_view_controller TYPE REF TO if_wd_view_controller        .

* Check all the mandatory attributes
  l_view_controller = wd_this->wd_get_api( )  .
  cl_wd_dynamic_tool=>check_mandatory_attr_on_view(
         EXPORTING  view_controller  = l_view_controller
                    display_messages = abap_true
                        )  .

Regards,

Radhika.

Former Member
0 Kudos

Good Thread! This was exactly what i was searching for.

Radhika Vadher's reply (the first reply) absolutely solved the problem for me!

I found a lot of so-called "solution" via google with lots of lines, that all had one in common - they didn't work for me. But Radhika Vadher's solution is as good as simple and works fine!

Great work and thanks a lot.

I would give you points if i could

Best regards

Philipp