on 01-22-2009 3:47 AM
Hi All,
Would like to know what are the ways to check the mandatory fields in the View are being filled, when those field state property are being bind to a context attribute.
I tried using 'cl_wd_dynamic_tool=>check_mandatory_attr_on_view' but no matter the attribute that bind the element is set to required or normal the method will take all the fields that are binded as mandatory.
So for fields that state are binded, how do i check for mandatory fields?
Thanks and Regards,
Long
Hi Wl ong,
Have you binded STATE property of every input field with a context attribute? If yes, then don't do that because if the value of that attribute changes it'll change the state property of each and every input field. So if you want to make an input field mandatory, simply set its STATE property as "Reqired" but don't bind it with an attribute. If you want to change its state property as run time then bind STATE property of every input field with different attribute , so that change in any attribute's value doesn't afftect others. Now simply use this 'cl_wd_dynamic_tool=>check_mandatory_attr_on_view' method. It will give error msg for mandatory fields only.
I hope it helps.
Regards
Arjun
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Arjun,
I did not bind all the fields to a attribute. I've bind them one field to one attribute. but even if i had set them all on runtime to '00' which is normal state. it still check them as an mandatory field.
Or have i set it some how wrong? I use, setattribute( name = '<attributename>' value = 00 ).
Regards,
Long
Hi,
See this is few lines of code i have written right now and it is working fine for me....
method onactionenter .
data state type wdui_state.
data lo_el_context type ref to if_wd_context_element.
data ls_context type wd_this->element_context.
data lv_ip type wd_this->element_context-ip.
* get element via lead selection
lo_el_context = wd_context->get_element( ).
* @TODO handle not set lead selection
if lo_el_context is initial.
endif.
* get single attribute
lo_el_context->get_attribute(
exporting
name = `IP`
importing
value = lv_ip ).
state = lv_ip.
data lv_state type wd_this->element_context-state.
* get element via lead selection
lo_el_context = wd_context->get_element( ).
* @TODO handle not set lead selection
if lo_el_context is initial.
endif.
* @TODO fill attribute
* lv_state = 1.
* set single attribute
lo_el_context->set_attribute(
name = `STATE`
value = state ).
endmethod.
Now one thing i want to make it clear state will be mandatory for value 01 and will not be mandatory for 00, you can'nt give any thing else here.... it will show run time exception.........
and in below code i am checking for mandatory...
method ONACTIONACTION .
data:lo_view_controller type ref to if_wd_view_controller,
lv_flag type i,
msg_tab type cl_wd_dynamic_tool=>t_check_result_message_tab.
field-symbols: <lv_fs> type any.
lo_view_controller = wd_this->wd_get_api( ).
cl_wd_dynamic_tool=>check_mandatory_attr_on_view(
exporting
view_controller = lo_view_controller
display_messages = abap_true
importing
messages = msg_tab ).
endmethod.
regards
Pranav
Edited by: Pranav Nagpal on Jan 22, 2009 5:43 AM
see note #0001228965
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Guys,
Well actually the current problem now is that even if on runtime i set the attribute that bind to the ui element state property to '00'.
I left the field empty and when 'cl_wd_dynamic_tool=>check_mandatory_attr_on_view' is called it will still show the error 'Please compete all required fields' when the field is actually not required and doesn't have the red * with it.
Thanks and Regards,
Long
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
For test purpose i created an application, i have following things in my application.....
1. one input field. its state property is linked with an attribute of type WDUI_STATE.
2. onenter event of input field
3. button and its event.
Now when i run the application i enter 01 in input field and i press enter... now in onenter of input field i have written code to get 01 and i am setting this 01 with state property of input field. this makes the input field madatory now i remove data from input field and press button it shows me error please fill all the mandatory field...
now if i give 00 in my input field and pree onenter it makes input field normal and now if i press button it is not showing me any error.......
i have given you code in my above reply for same thing... if you want some thing different tell me what you are exactly doing...
regards
Pranav
Hi Pranav,
I tried the same way but no matter i enter 00 or 01 it will prompt the error message. Or is there any method or way i can check if the state of the field is 00 or 01 on run time. Cause if the normal checking ways can't work for me maybe i have to try checking manually.
Regards,
Long
Hi Long,
I am not able to understand why the code provided by Pranav is not working for you. You can use a manual method also. Create a flag and give it a default value (say 0). .Just read each attribute binded with the input field.If it is initial, raise an error msg and set a flag. Use this line of code
Check Lv_flag eq '0'.
it will stop the prog to execute any further in case of error.
Regards
Arjun
Edited by: Arjun on Jan 22, 2009 11:34 AM
Automatic checking should work... check your attribute type which you have linked with state property it sholud be of type WDUI_STATE
manually you can get the attribute and check if it is 00 or 01 using if condition.... but still after that you have to make those fields mandatory and normal by setting the value in state property.....
regards
Pranav
Hi Arjun,
I am also not sure why it doesn't work for me, because i thought that it should work that work and in the end find out that it giving error no matter it is required or normal.
Cause i can see the red * when it is required and not red * when it is normal. but no matter there is the red * or not it will prompt the error message when there is no value in the inputfield.
Regards,
Long
Hi Pranav,
i did use the the WDUI_STATE as the type for the attribute. As i am able to see the red * showing and not showing so I know that the values are set to the attribute correctly but still it is not working the right way.
Thank you guys very much for all the inputs.
Thanks and Regards,
Long
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I've binded the state property to a context attribute and onload of the program i will read an config table to set the attribute to either 00 - for normal and 01 - for required. But the problem now is no matter i had set the attribute to 00 or 01 i will check it as an mandatory field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
There is a property for the input field with name STATE. It has a list of values ie., Normal item, Required.
If you set the property as required. It is mandatory field.
If you want to bind the attribute of the State property create an attribute of type 'WDUI_STATE'.
This DE has a domain which has fixed values of the above mentioned list of values.
You can set one of them based on the requirement at runtime.
Hope it answers the question.
Regards,
Shashikanth. D
Edited by: Shashikanth Divakaruni on Jan 22, 2009 5:00 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.