on 10-23-2011 2:08 PM
Hi,
I have an alv table, which has a dropdown-by-key field. When I append a line, the dropdown field is ready to choose an entry. After choosing a value, I would that this field is only in read-only mode. A new appended line should be again entryable.
Does somebody know, if this is possible? If yes, do you have me de coding solution?
Thanks, Sascha
Hi,
You can create an action for the event onSelect, then change the property "Read Only" of this field.
CALL METHOD lo_el_your_element->set_attribute_property
EXPORTING
attribute_name = lv_your_att_name
property = 3 "Read Only
value = 'X'.
First you need to do the binding of the property "Read Only" using "Bind to the Property of the Selected attribute" with the property "Read Only"...
Hope this help you...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Sascha,
I didnt complete understand your requirement. What I understood is that you want to make the Dropdown readonly upon selection of any value. For this do the following
1. Create an boolean atrtibute in the context node that is passed to the ALV
2. from the ALV config model, delete the column pertaining to this boolean attribute
3. bind this boolean attribute as the read only property of the dropdown UI element (CL_SALV_WD_UIE_A_DRDN_BY_KEY->SET_READ_ONLY_FIELDNAME)
4. whenever the value is selected, based on your requirement set this boolean flag to abap_true for making it read only.
BR, Saravanan
Hi Saravanan,
I've tried the follow coding, but the DATA node of ALV not exist by binding dynamicly! What I must do in WDDOINIT and WDDOMODIFY? And how can I bind a attribute property of DATA (ALV)?
1. WDDOINIT (snippet code), dynamicly binded the node:
"ALV-Verwendung
lo_comp_alv = wd_this->wd_cpuse_usage_alv( ).
IF lo_comp_alv->has_active_component( ) IS INITIAL.
lo_comp_alv->create_component( ).
ENDIF.
lo_comp_if_alv = wd_this->wd_cpifc_usage_alv( ).
lo_comp_if_alv->set_data( lo_nd_ctxt ).
2. WDDOMODIFYVIEW:
DATA: lo_nd_ctxt TYPE REF TO if_wd_context_node,
lo_el_ctxt TYPE REF TO if_wd_context_element,
lt_el_ctxt TYPE wdr_context_element_set,
lo_nd_ctxt_data TYPE REF TO if_wd_context_node,
ls_attr_props_data TYPE wdr_context_prop_for_node,
lt_attr_props_data TYPE wdr_context_prop_for_node_tab,
lo_comp_if_alv TYPE REF TO iwci_salv_wd_table,
lo_config_alv TYPE REF TO cl_salv_wd_config_table,
lo_field_alv TYPE REF TO cl_salv_wd_field,
lo_filter_rule_alv TYPE REF TO cl_salv_wd_filter_rule,
ls_vert_pos TYPE wd_this->element_vert_pos,
ls_props TYPE wdr_context_properties,
lv_el_index TYPE i.
"Knoten lesen
lo_nd_ctxt = wd_context->get_child_node( wd_this->wdctx_service ).
lo_nd_ctxt = lo_nd_ctxt->get_child_node( wd_this->wdctx_vert_pos ).
lo_nd_ctxt_data = wd_context->get_child_node( 'DATA' ). "ERROR, because the node is binding in WDDOINIT dynamicly
"ALV-Eigenschaften
lo_comp_if_alv = wd_this->wd_cpifc_usage_alv( ).
lo_config_alv = lo_comp_if_alv->get_model( ).
"Feldwerte abhängiger Felder füllen oder Eigenschaften setzen
lt_el_ctxt = lo_nd_ctxt->get_elements( ).
LOOP AT lt_el_ctxt INTO lo_el_ctxt.
lo_el_ctxt->get_static_attributes( IMPORTING static_attributes = ls_vert_pos ).
"->Eigenschaften setzen
"->->Verteilelement als READ-ONLY nach Eingabe
IF NOT ls_vert_pos-vid IS INITIAL.
CLEAR: ls_attr_props_data, lv_el_index.
lv_el_index = lo_el_ctxt->get_index( ).
ls_attr_props_data-element_index = lv_el_index.
ls_attr_props_data-attribute_name = 'VID'.
ls_attr_props_data-read_only = abap_true.
ls_attr_props_data-visible = abap_true.
ls_attr_props_data-enabled = abap_true.
INSERT ls_attr_props_data INTO TABLE lt_attr_props_data.
lo_nd_ctxt_data->set_attribute_props_for_node( lt_attr_props_data ).
ENDIF.
ENDLOOP.
Thanks for your help!
Best regards
Sascha
Hi Saravanan
I've tested your note, but the output in alv of this field is not in readonly mode.
1. Create an boolean atrtibute in the context node that is passed to the ALV
My field in the node named READONLY_PROP_VID type WDY_BOOLEAN
2. from the ALV config model, delete the column pertaining to this boolean attribute
WDDOINIT:
lo_config_alv->if_salv_wd_column_settings~delete_column( id = 'READONLY_PROP_VID' ).
3. bind this boolean attribute as the read only property of the dropdown UI element (CL_SALV_WD_UIE_A_DRDN_BY_KEY->SET_READ_ONLY_FIELDNAME)
WDDOINIT:
CREATE OBJECT lo_input_field_alv
EXPORTING
value_fieldname = 'VID'.
lo_input_field_alv->set_read_only_fieldname( value = 'READONLY_PROP_VID' ).
4. whenever the value is selected, based on your requirement set this boolean flag to abap_true for making it read only.
WDDOMODIFY:
LOOP AT lt_el_ctxt INTO lo_el_ctxt.
lo_el_ctxt->get_static_attributes( IMPORTING static_attributes = ls_vert_pos ).
"->Readonly von Verteilelement setzen
IF NOT ls_vert_pos-vid IS INITIAL.
ls_vert_pos-readonly_prop_vid = abap_true.
ENDIF.
"->Neue Werte setzen
lo_el_ctxt->set_static_attributes( static_attributes = ls_vert_pos ).
ENDLOOP.
Do you see, where is the problem?
Best regards,
Sascha
Hi, I've forgot to set the cell editor:
lo_column_alv->set_cell_editor( lo_inp_alv ).
For example the method, that I've created:
Parameters:
IO_CONFIG_ALV Importing 1 0 CL_SALV_WD_CONFIG_TABLE
IV_FIELDNAME Importing 0 0 STRING
IV_FIELDTYPE Importing 0 0 STRING
IV_READONLY_PROP_FIELDNAME Importing 0 1 STRING
METHOD set_alv_fld_prop.
DATA: lo_column_alv TYPE REF TO cl_salv_wd_column,
lo_inp_alv TYPE REF TO cl_salv_wd_uie_input_field,
lo_ddk_alv TYPE REF TO cl_salv_wd_uie_dropdown_by_key.
lo_column_alv = io_config_alv->if_salv_wd_column_settings~get_column( id = iv_fieldname ).
CASE iv_fieldtype.
WHEN 'INP'. "Inputfeld
CREATE OBJECT lo_inp_alv
EXPORTING
value_fieldname = iv_fieldname.
lo_column_alv->set_cell_editor( lo_inp_alv ).
IF NOT iv_readonly_prop_fieldname IS INITIAL.
lo_inp_alv->set_read_only_fieldname( value = iv_readonly_prop_fieldname ).
ENDIF.
WHEN 'DDK'. "Dropdown by Key
CREATE OBJECT lo_ddk_alv
EXPORTING
selected_key_fieldname = iv_fieldname.
lo_column_alv->set_cell_editor( lo_ddk_alv ).
IF NOT iv_readonly_prop_fieldname IS INITIAL.
lo_ddk_alv->set_read_only_fieldname( value = iv_readonly_prop_fieldname ).
ENDIF.
ENDCASE.
ENDMETHOD.
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.