cancel
Showing results for 
Search instead for 
Did you mean: 

Check mandatory for Select Option

somnath
Active Participant
0 Kudos

Dear -

Looking at the title seems very common and already discussed several times in the forum earlier but actually I am placing my question/need which may be little different in this case.

I am trying to validate mandatory parameter / select option fields in my demo component. I am aware of the  cl_wd_dynamic_tool=>check_mandatory_attr_on_view approach but it is not working as I am looking for.

Reason , here I need to provide the view controller reference of the view for select option and not the original component where I have used the select option.I have also checked the forum and somewhere it is being mentioned to get the field content and check if that is initial and raise error.

This will not be very useful reason in my case I have created dynamic select option / parameter fields and made all mandatory (around 20 parameters / select option fields can get generated dynamically in my case). Therefore I need to stop triggering any further action if any of the dynamic field is empty / initial.

In other word I am trying to get the IF_WD_VIEW_CONTROLLER reference for the select option. I tried type narrow / wide casting but that also didn't work.

So please share if any better / smarter approach you know which I can learn.

- Thanks , Somnath

Accepted Solutions (1)

Accepted Solutions (1)

former_member184578
Active Contributor
0 Kudos

Hi,

The method cl_wd_dynamic_tool=>check_mandatory_attr_on_view( ) would not work as you will be passing the view controller reference.

You could use the method check_all_selection_fields( ) of the if_wd_select_options interface.

Data : lv_error type i.

wd_this->M_HANDLER->check_all_selection_fields( IMPORTING 

             e_num_error_msgs = lv_error ).

*" M_HANDLER is the attr of type if_wd_select_options.



Or you can check this blog for a work around: http://scn.sap.com/community/web-dynpro-abap/blog/2012/03/19/highlighting-select-options-in-red-in-w...



hope this helps,



Regards,

Kiran

somnath
Active Participant
0 Kudos

Thanks Kiran , appreciated!

I was checking with check_selection_screen assuming I have both select option as well parameter field (being a dynamic screen I am developing).  I observed there is a method called check_all_parameter_fields, so to avoid calling both selection as well parameter field explicitly I thought better to go by check_selection_screen and resulting no value in my message parameter.

I should have tried with the option check_all_selection_fields !

Anyways , thanks for sharing your thoughts along with the Nice blog.

- Thanks , Somnath

Answers (0)