on 04-26-2011 4:48 PM
Hello Friends,
I am creating a custom Web Dynpro ABAP Application for FI module in ECC 6.0
I need to make a set of fields uneditable/grayed out based on a value in a dropdown list. If the user chooses the other value (out of the 2 values provided) in the dropdown list, the set of fields need to made editable.
I created a context attribute of type WDY_BOOLEAN and bound this attribute to the "readOnly" property of the aforementioned fields. When defining context binding, I chose the option "Bind Directly to the Selected Attribute".
I have written the following code in the OnSelect event handler method for the dropdown:
I read the value in the dropdown which is stored in the variable "lv_payment_instrument". Based on this value, I am changing the value of the context attribute:
if lv_payment_instrument = 'X'.
DATA lo_nd_check_fields1 TYPE REF TO if_wd_context_node.
DATA lo_el_check_fields1 TYPE REF TO if_wd_context_element.
DATA ls_check_fields1 TYPE wd_this->Element_check_fields.
DATA lv_editable1 TYPE wd_this->Element_check_fields-editable.
navigate from <CONTEXT> to <CHECK_FIELDS> via lead selection
lo_nd_check_fields1 = wd_context->get_child_node( name = wd_this->wdctx_check_fields ).
@TODO handle non existant child
IF lo_nd_check_fields IS INITIAL.
ENDIF.
get element via lead selection
lo_el_check_fields1 = lo_nd_check_fields1->get_element( ).
@TODO handle not set lead selection
IF lo_el_check_fields1 IS INITIAL.
ENDIF.
@TODO fill attribute
lv_editable = 1.
set single attribute
lo_el_check_fields1->set_attribute(
name = `EDITABLE`
value = 'ABAP_FALSE' ).
elseif lv_payment_instrument = 'Q'.
DATA lo_nd_check_fields TYPE REF TO if_wd_context_node.
DATA lo_el_check_fields TYPE REF TO if_wd_context_element.
DATA ls_check_fields TYPE wd_this->Element_check_fields.
DATA lv_editable TYPE wd_this->Element_check_fields-editable.
*navigate from <CONTEXT> to <CHECK_FIELDS> via lead selection
lo_nd_check_fields = wd_context->get_child_node( name = wd_this->wdctx_check_fields ).
*@TODO handle non existant child
IF lo_nd_check_fields IS INITIAL.
ENDIF.
*get element via lead selection
lo_el_check_fields = lo_nd_check_fields->get_element( ).
*@TODO handle not set lead selection
IF lo_el_check_fields IS INITIAL.
ENDIF.
*@TODO fill attribute
lv_editable = 1.
*set single attribute
lo_el_check_fields->set_attribute(
name = `EDITABLE`
value = 'ABAP_TRUE' ).
endif.
When the user chooses either of the 2 values in the dropdown, the set of fields are made uneditable. I am unable to make them editable again.
I would greatly appreciate your inputs/thoughts on how to rectify this error.
Regards,
Arun.
Hello Arun,
The problem seems to be with the value which you are setting for the context attribute 'EDITABLE'.
You specified the value ABAP_TRUE and ABAP_FALSE with quotes. Try setting the value as shown below
lo_el_check_fields1->set_attribute(
name = `EDITABLE`
value = ABAP_FALSE). "use 'X' and ' ' if you want instead of ABAP_TRUE and ABAP_FALSE
One thing i suggest you is that you are declaring and reading the context element inside if else blocks.
Instead of that read the context element before the IF condition and inside IF ELSE blocks set the attribute value.
That way you can reduce few lines of code
Hope this helps!
Best Regards,
Srilatha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you Srilatha and Kris for your help.
I corrected the error by giving ABAP_TRUE and ABAP_FALSE without the quotes.
Arun.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Create one attribute of type WDY_BOOLEAN , i think u already done.
First get selected dropdown value into one variable.
For example :
lo_el_segment1 = WDEVENT->GET_CONTEXT_ELEMENT( 'CONTEXT_ELEMENT' ).
get all declared attributes
lo_el_segment1->get_static_attributes(
IMPORTING
static_attributes = ls_segment1 ).
now ls_segment1 has selected drop down value.
DATA : lv_dropdown type string .
lv_dropdown = ls_segment1-segment.
If lv_dropdown = 'X'.
set single attribute
lo_el_check_fields1->set_attribute(
name = `EDITABLE`
value = ABAP_FALSE ). // No Quotes, ABAP_TRUE or false not works use 1 0r 2 or ' ' 'X' .
elseif lv_dropdown = 'Q'.
set single attribute
lo_el_check_fields1->set_attribute(
name = `EDITABLE`
value = ABAP_FALSE ).
else.
set single attribute
lo_el_check_fields1->set_attribute(
name = `EDITABLE`
value = ABAP_TRUE ).
Hope it solves..
cheers,
Kris.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.