on 01-21-2015 8:10 AM
Hi Experts,
I'm not able to make one input field mandatory dynamically. I have written the code in the "WDDOMODIFYVIEW" method of the view. My code is written below:-
DATA lo_nd_origin_sub_mandt TYPE REF TO if_wd_context_node.
DATA lo_el_origin_sub_mandt TYPE REF TO if_wd_context_element.
lo_nd_origin_sub_mandt = wd_context->get_child_node( name = wd_this->wdctx_origin_sub_mandt ).
* get element via lead selection
lo_el_origin_sub_mandt = lo_nd_origin_sub_mandt->get_element( ).
* set single attribute
lo_el_origin_sub_mandt->set_attribute(
name = 'ORIGIN_SUB_MANDATORY'
value = 'required' ).
But field is not getting mandatory. Please help me out
Hi,Follow the steps below.
1)Create one attribute of type WDUI_STATE in your context.
2) Now bind this attribute to the property value namely state as shown below.
3) Now set the attribute property as per you requirement as 00 ( Normal Item) or 01( Required).
i.e
lo_el_<element>->set_attribute( name = `<attribute_name` value = '00' ). " For Normal
or
lo_el_<element>->set_attribute( name = `<attribute_name` value = '01' ). " For Required.
Hope this helps you.
Thanks
KH
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi -
Here are my observation and suggestion:
1. I assume you have bound the context with the state property for the input element.
2. What data type you used to create that attribute? I suggest to use the WDUI_STATE and bind this attribute with the state property for the field which you want to display as mandatory during run time.
3. In WDDOMODIFY method , I suggest you the below code to be placed judiciously:
data lo_el_node type ref to if_wd_context_element.
lo_el_node = wd_context->get_child_node( wd_this->wdctx_node )->get_element().
** I have taken a node with two attributes
1, for binding the input field - value property (Say MATNR)
2. for binding the input field - state property ( Say REQUIRED )
****
so ..>>> ls_node-required = cl_wd_abstract_dropdown=>e_state-required.
***now bind this property with the element.
lo_el_node->set_attribute(
exporting value = ls_node-required
name = 'REQUIRED'
).
I hope this would solve your issue.
- Thanks , Somnath
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Swarup,
What you can do is,
You can set the property of the input field as (state = required).
Now in the method WDOBEFOREACTION, check for the mandatory fields.
Use the method CHECK_MANDATORY_ATTR_ON_VIEW of the class CL_WD_DYNAMIC_TOOL to check the mandatory fields.
Raise an error message ‘Fill all required entry fields’, if the mandatory fields are not entered.
Please rewards points if helpful.
Regards,
AkkI
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Swarup,
For changing the element properties dynamically without the need of creating an extra attribute, we can make use the set_attribute_property of the element, so that same attribute can be made use of.
DATA lo_nd_origin_sub_mandt TYPE REF TO if_wd_context_node.
DATA lo_el_origin_sub_mandt TYPE REF TO if_wd_context_element.
lo_nd_origin_sub_mandt = wd_context->get_child_node( name = wd_this->wdctx_origin_sub_mandt ).
* get element via lead selection
lo_el_origin_sub_mandt = lo_nd_origin_sub_mandt->get_element( ).
call method lo_el_origin_sub_mandt-->set_attribute_property
exporting
attribute_name = 'ORIGIN_SUB_MANDATORY'
property = 2
value = 'X'.
After you make the changes don't forget to bind this attribute(ORIGIN_SUB_MANDATORY) to the state property of the UI in the view.
Regards,
Harsha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can't use "Required" here. It has to be one of the following:
00 - Normal Item
01 - Mandtory field
* set single attribute
lo_el_origin_sub_mandt->set_attribute(
name = 'ORIGIN_SUB_MANDATORY'
value = '01' ).
thanks,
VS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Please make the type of the attribute as char1. Then in the code do the following.
* set single attribute
lo_el_origin_sub_mandt->set_attribute(
name = 'ORIGIN_SUB_MANDATORY'
value = 'X' ).
Regards,
Subhabrata
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
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.