on 04-08-2014 11:03 AM
I am trying to edit a single cell on lead selection. here the steps i did to achive this.
1. I added a Attribute READ_ONLY inside my node of type WDY_BOOLEAN.
2. i am conditionally making this Attribute - READ_ONLY = 'X'.
3. i am binding my node with new values.
4. for ALV here is the code i have added.
DATA :lo_cmp_usage TYPE REF TO if_wd_component_usage,
lr_column TYPE REF TO cl_salv_wd_column,
lr_table_settings TYPE REF TO if_salv_wd_table_settings,
lt_columns TYPE salv_wd_t_column_ref,
ls_columns TYPE salv_wd_s_column_ref,
lr_input_field TYPE REF TO cl_salv_wd_uie_input_field,
lo_interfacecontroller TYPE REF TO iwci_salv_wd_table ,
lv_value TYPE REF TO cl_salv_wd_config_table.
*Taking reference of the Component Usage
lo_cmp_usage = wd_this->wd_cpuse_cu_alv( ).
IF lo_cmp_usage->has_active_component( ) IS INITIAL.
lo_cmp_usage->create_component( ).
ENDIF.
lo_interfacecontroller = wd_this->wd_cpifc_cu_alv( ).
lv_value = lo_interfacecontroller->get_model( ).
CALL METHOD lv_value->if_salv_wd_column_settings~get_columns
RECEIVING
value = lt_columns.
LOOP AT lt_columns INTO ls_columns.
lr_column = ls_columns-r_column.
CASE ls_columns-id.
WHEN 'USR_ACT_RT'.
CREATE OBJECT lr_input_field
EXPORTING
value_fieldname = ls_columns-id.
lr_column->set_cell_editor( value = lr_input_field ).
lr_input_field->set_read_only_fieldname( value = 'READ_ONLY' ).
ENDCASE.
ENDLOOP.
lr_table_settings ?= lv_value.
lr_table_settings->set_read_only( abap_false ).
lv_value->if_salv_wd_column_settings~delete_column( id = 'READ_ONLY' ).
but instead of changing the particular cell where i have marked READ_ONLY = 'X' it is changing whole column 'USR_ACT_RT' data as editable .
If anybody can please help ASAP
Hi Shehzad,
i dont see anything wrong in your ALV code.
The internal table which you are binding with the node, The attribute READ_ONLY should be set conditionally and binded with the node.
You can probably set an external debugger on method bind_table( itab) and check the value itab whether its conditionally set or unset.
Regards,
Tashi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
An Example code for SFLIGHT Node.
DATA lo_nd_sflight TYPE REF TO if_wd_context_node.
DATA lo_el_sflight TYPE REF TO if_wd_context_element.
DATA ls_sflight TYPE wd_this->element_sflight.
DATA lt_sflight TYPE wd_this->elements_sflight.
FIELD-SYMBOLS: <fs_sflight> TYPE wd_this->element_sflight.
SELECT * up to 10 rows from SFLIGHTS
INTO corresponding fields of TABLE lt_sflight.
LOOP at lt_sflight
ASSIGNING <fs_sflight>.
IF <fs_sflight>-price > 200
<fs_sflight>-read_only = 'X'.
ELSE
<fs_sflight>-read_only = space.
ENDLOOP.
* navigate from <CONTEXT> to <SFLIGHT> via lead selection
lo_nd_sflight = wd_context->get_child_node( name = wd_this->wdctx_sflight ).
lo_nd_sflight->bind_table( lt_sflight ).
Hi Tashi,
Thanks for your reply,i have did the same way u are doing here for setting the READ_ONLY Attribute conditionally.
here is my code for setting the read only attribute .
IF NOT lo_nd_nd_cost_rate IS INITIAL.
lo_nd_nd_cost_rate->get_static_attributes_table( IMPORTING table = lt_nd_cost_rate ).
ENDIF.
IF NOT lo_el_nd_cost_rate IS INITIAL.
* get all declared attributes
lo_el_nd_cost_rate->get_static_attributes(
IMPORTING
static_attributes = ls_nd_cost_rate_sel ).
ENDIF.
lv_datum = sy-datum.
lv_month = lv_datum+4(2).
** @TODO handle non existant child
LOOP AT lt_nd_cost_rate INTO ls_nd_cost_rate WHERE quarter = ls_nd_cost_rate_sel-quarter.
IF ls_nd_cost_rate-quarter = 'Q1'.
IF ( lv_month EQ '01' OR lv_month EQ '02' OR lv_month EQ '03' ).
ls_nd_cost_rate-read_only = 'X'.
ELSE.
ls_nd_cost_rate-read_only = ''.
* report message
CALL METHOD lo_message_manager->report_warning
EXPORTING
message_text = lv_text.
ENDIF.
ELSEIF ls_nd_cost_rate-quarter = 'Q2'.
IF ( lv_month EQ '04' OR lv_month EQ '05' OR lv_month EQ '06' ).
ls_nd_cost_rate-read_only = 'X'.
ELSE.
ls_nd_cost_rate-read_only = ''.
* report message
CALL METHOD lo_message_manager->report_warning
EXPORTING
message_text = lv_text.
ENDIF.
ELSEIF ls_nd_cost_rate-quarter = 'Q3'.
IF ( lv_month EQ '07' OR lv_month EQ '08' OR lv_month EQ '09' ).
ls_nd_cost_rate-read_only = 'X'.
ELSE.
ls_nd_cost_rate-read_only = ''.
* report message
CALL METHOD lo_message_manager->report_warning
EXPORTING
message_text = lv_text.
ENDIF.
ELSEIF ls_nd_cost_rate-quarter = 'Q4'.
IF ( lv_month EQ '10' OR lv_month EQ '11' OR lv_month EQ '12' ).
ls_nd_cost_rate-read_only = 'X'.
ELSE.
ls_nd_cost_rate-read_only = ''.
* report message
CALL METHOD lo_message_manager->report_warning
EXPORTING
message_text = lv_text.
ENDIF.
ENDIF.
MODIFY lt_nd_cost_rate FROM ls_nd_cost_rate INDEX sy-tabix TRANSPORTING read_only .
CLEAR ls_nd_cost_rate.
ENDLOOP.
lo_nd_nd_cost_rate->bind_table( lt_nd_cost_rate ).
please see in the below sceen shot the last two cells are editable in the User Actual Rate Column whlie the selected rows cell is not editable. Please revert if u have any input for same.
Bind the readonly attribute to the readonly property of the context node for each column.
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.