on 03-04-2009 10:01 AM
Dear users,
I'm facing a problem with the check mandatory fields.
I found other topics about this, but none offers a solution.
My field inp_name has the state property bound to a context attribute (DETAILS.SCREEN.CONFIG.IS_MAND_CREATE)
If this attribute holds value 00 (normal), than the field is diplayed on the screen as not required (visually represented with no red asterisk (*) )
If this attribute holds value 01 (Mandatory), than the field is diplayed on the screen as required (visually represented by a red asterisk (*) next to the label)
so far so good
the problems start when running the cl_wd_dynamic_tool=>check_mandatory_attr_on_view( ).
This returns my field name as required, regardless of the state value.
I checked in debugging, and the required state is set to the path of my context node. It seems as if the method no longer ponders on what the value of the state attrribute is, but simply says: "It's not initial, so it's required"
I checked the OSS notes for this problem but couldn't find anything in there. Now I've seen other topics describing this exact problem. The answers there however describe exactly what my code does (in other words, yes I'm doing everything right...) but they seem to work for the people providing those answers, although they don't work for me.
So:
Are there any notes,
enhancement packs
workarounds
little hacks
whatever to solve this rather annoying problem?
i'm working on SAP ECC 6.0 kernel release 700, support package level 178
Thanks in advance.
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.
Hello Tom,
Currently i am facing same problem in my SAP SRM 7.0 standard component.
I have written below code to remove Red mark * infront of Inputfield, but Inputfield is bound with Context attribute, while i am trying to save other data, still it is asking me enter the required value.
data:lo_input1 type ref to cl_wd_input_field.
lo_input1 ?= VIEW->get_element( 'NAME_FIRST' ).
lo_input1->set_state( '00' ).
I am trying to delete state = required property from below component and view
Component Name : /SAPSRM/WDC_MOFC_PERSON
View : V_PERSON
Can you help me on this?
Thanks
Sandeep.
hi,
for your ui element there will be a propery called required .for this bind an attribute say req type wdy_boolean.
then in your coding based on your values set this property to true or false .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Prashant,
Thanks for your input, but I need to use the check_mandatory_ON_VIEW. This is because of the architecture of the components and the FPM.
Also, the field MUST be visible, whether it is required or not, so that workaround won't work either.
The exact problem in the code is here: (this is extract of a LCL_implementation of the cl_wd_dynamic_tools:
see my remark in green
(and i should be posting this to OSS notes)
if has_state_property = abap_true.
if is_multiple = abap_true.
l_mandatory_element-context_element_index = 0.
else.
l_mandatory_element-context_element_index = -1.
endif.
l_mandatory_element-view_element = view_element_to_check.
l_mandatory_element-binding_path = l_view_el_rt_access->bound_property(
property_name = 'STATE' ).
if l_mandatory_element-binding_path is initial.
l_view_el_rt_access->get_p13n_property(
exporting property_name = 'STATE'
importing value = l_state ).
if l_state = c_mandatory_bool
or l_state = c_mandatory_enum.
insert l_mandatory_element into table mandatory_elements.
endif.
else.
Instead of bluntly inserting here, the mapping path must be checked to see if it is effectively required
insert l_mandatory_element into table mandatory_elements.
endif.
endif.
Edited by: Tom Van Doorslaer on Mar 4, 2009 11:46 AM
Edited by: Tom Van Doorslaer on Mar 4, 2009 11:50 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
check out the code :
Code to make the fields in the view as Mandatory :
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 ).
For all the UI Elements which you want to be mandatory , make the state property of that element as Required.
This works fine for me.
I hope it helps you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Tom,
My understanding of the entire issue is; So far you provide the exact values to be validated as MANDATORY, thru the structure, to the cl_wd_dynamic_tool=>CHECK_MANDATORY_ATTRIBUTES method , VALIDATION of mandatory fields left EMPTY will work!!.
And if context value BINDED to the state Property is inplace, before the method cl_wd_dynamic_tool=>CHECK_MANDATORY_ATTRIBUTES is called user will see the (*) next to the mandaory fields.
Below is the code snippet of mine cl_wd_dynamic_tool=>CHECK_MANDATORY_ATTRIBUTES implementation.
method check_address.
*Parameters
*IR_ELEMENT Importing IF_WD_CONTEXT_ELEMENT
*RV_BOOL Returning BOOLEAN
data: lt_attr type zst_ui_attribute_list,
ls_attr type zst_ui_attribute,
lv_flag type wdy_boolean.
* ATTRIBUTE_NAME
* ELEMENT_EMPTY_OK
ls_attr-attribute_name = 'SHIP_NAME1'.
ls_attr-element_empty_ok = abap_false.
append ls_attr to lt_attr.
ls_attr-attribute_name = 'STR_SUPPL1'.
ls_attr-element_empty_ok = abap_false.
append ls_attr to lt_attr.
ls_attr-attribute_name = 'CITY1'.
ls_attr-element_empty_ok = abap_false.
append ls_attr to lt_attr.
ls_attr-attribute_name = 'POST_CODE1'.
ls_attr-element_empty_ok = abap_false.
append ls_attr to lt_attr .
ls_attr-attribute_name = 'TEL_NUMBER'.
ls_attr-element_empty_ok = abap_false.
append ls_attr to lt_attr .
rv_bool = wd_this->check_mandatory_attributes(
attribute_list = lt_attr " Zst_Ui_Attribute_List
ir_element = ir_element "wd_this->m_elem_shpaddr " Ref to if_Wd_Context_Element
).
endmethod.
Greetings
Prashant
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Tom,
Try to pass values like this.
Checking
IF ls_contract_info-proposal = abap_true.
lv_optional = cl_wd_input_field=>e_state-normal.
lv_hidden = cl_wd_uielement=>e_visible-none.
ELSE.
lv_hidden = cl_wd_uielement=>e_visible-visible.
lv_optional = cl_wd_input_field=>e_state-required.
ENDIF.
Hopes this will helps you,because i am doin the same thing as you mention here and its working properly for me .
Regard
Manoj Kumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
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.