on 08-13-2012 4:59 AM
Hi Guys,
I have a requirement to make a field mandatory depends on the value of some other field.
is it possible to make it mandatory dynamically.
Thanks
Sam
Hi Sam,
I have done this in a component using this approach:
If you want to prevent the user from navigating away from a view with a required field, you need to issue an error message, say in WDDOBEFOREACTION, for an action that is defined with action type = standard (as opposed to validation-independent). A standard action will prevent the user from leaving a view with an error message.
Cheers,
Amy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sam Vel
In the View controller create on atrribute STATE with type STRING. For that Input field for which u need mandatory in the Properties For the State bind the Attribute STATE.
And based on condition make field as dynamic
DATA lo_el_context TYPE REF TO if_wd_context_element.
* get element via lead selection
lo_el_context = wd_context->get_element( ).
if <Condition> IS TRUE.
* set single attribute
lo_el_context->set_attribute(
name = `STATE`
value = 'required' ).
else.
* set single attribute
lo_el_context->set_attribute(
name = `STATE`
value = 'Normal Item' ).
endif.
OR Else
you can set the index of drop down( State property is Drop down only no) So depending on your situation you can set the drop down value
01 for Normal
02 for Required Item
Thanks
Abhishek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Sam,
you can try this, Create attribute in the context node and bind the state property of the input field with attribute and depending on the value of some other field put value as required in the created attribute
But you need to set this value depending on some event and in the event handler method you can write the code of setting the value
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sam,
1. After binding the state property of the input field with attribute of type WDUI_STATE, You have to use code for checking is mandatory fields are initial or not for that you can use "check_mandatory_attr_on_view" method of class cl_wd_dynamic_tool.
You can write it in PROCESS_EVENT method of component controller.
It will also stop the navigation problem.
2. If you want to stop navigation of FPM main step that you can control separately, Using Enable Check box of main step at FPM configuration page (Do it for all main steps).
Ref thread : http://scn.sap.com/thread/3216442
Hi,
System will check this method only if any FPM event is been raised, if u want explicitly call this method use following code
data lo_fpm type ref to if_fpm.
lo_fpm = cl_fpm_factory=>get_instance( ).
lo_fpm->raise_event_by_id( if_fpm_constants=>gc_event-leave_initial_screen ).
Here the bold part is the event id which you can change accordingly.
User | Count |
---|---|
81 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.