Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Tutorial Enhancement- ALV Events with Checkbox Column

Hi,

I am working on this ALV events tutorial [https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/bd28494a-0801-0010-45a3-fc359d82d3e8 ].I have completed it and works fine.Now I am trying to enhance it.

Where I provide a check box column and if users checks it PRICE column should become editable.

For this

1-I have created attribute READ_ONLY of type BOOLEAN under same context node.

2-Created Checkbox for that attribute READ_ONLY & output has checkbox column now.

I tried creating ONCLICK -event handler -event-ON_CELL_ACTION and wrote following code .

when I debug it is not even comming into this method.

METHOD onclick .



  DATA:lt_columns TYPE salv_wd_t_column_ref,
       ls_columns TYPE salv_wd_s_column_ref.

  DATA: l_column_settings TYPE REF TO if_salv_wd_column_settings.


  lt_columns = l_column_settings->get_columns( )  .


  LOOP AT lt_columns INTO ls_columns    .
    CASE ls_columns-id.

      WHEN 'PRICE'.
* Create Editable cell
        DATA: l_input_field TYPE REF TO cl_salv_wd_uie_input_field.

        CREATE OBJECT l_input_field
          EXPORTING
            value_fieldname = ls_columns-id.
        ls_columns-r_column->set_cell_editor( l_input_field ) .

        " binding the attribute to the read only property
        l_input_field->set_read_only_fieldname( 'READ_ONLY' ).

    ENDCASE.
  ENDLOOP.



ENDMETHOD.

What am I doing wrong.

I even tried it with ON_DATA_CHECK & ON_CLICK.

Rgds

Vara

Edited by: Vara K on Jun 24, 2009 7:05 PM

Former Member
replied
*** This eventhandler method gets triggered for any changes that the user might make to
*** the ALV  so we first need to check if the changes have been made to the column CHECK or
*** something else 
  LOOP AT r_param->t_modified_cells INTO wa_modified_data.
    CASE wa_modified_data-attribute.
      WHEN 'CHECK'.
        lv_index = wa_modified_data-index.
        READ TABLE lt_sflight INTO wa_sflight INDEX lv_index.
*** We need to check if the checkbox is checked/unchecked by the user
        ASSIGN wa_modified_data-r_value->* TO <fs>.
*** If it is checked then we need to make the 2 date columns as editable
        IF <fs> = 'X'.
          wa_sflight-date_enabled = ''.
*** If it is unchecked then we need to make the 2 date columns as non-editable
        ELSE.
          wa_sflight-date_enabled = 'X'.
        ENDIF.

        MODIFY lt_sflight FROM wa_sflight INDEX lv_index TRANSPORTING date_enabled.
      WHEN 'D1'.
        lv_index = wa_modified_data-index.
        READ TABLE lt_sflight INTO wa_sflight INDEX lv_index.

        ASSIGN wa_modified_data-r_value->* TO <fs>.
        wa_sflight-d2 = <fs> + 7.
        lv_date1 = <fs>.
        wa_sflight-d2 = lv_date1 + 7.
        MODIFY lt_sflight FROM wa_sflight INDEX lv_index TRANSPORTING d2.

    ENDCASE.
  ENDLOOP.

*** Bind the context node with the new modified internal table
  wd_node->bind_table( new_items = lt_sflight ).

  CLEAR lt_sflight.

  CALL METHOD wd_node->get_static_attributes_table
    EXPORTING
      from  = 1
      to    = 2147483647
    IMPORTING
      table = lt_sflight.
0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question