Skip to Content
author's profile photo Former Member
Former Member

How to make the check box as editable

hi folks,

i want to make the check box as editable, i have written below code for checkbox, check box is getting displayed in output but this is not as editable check box, i want to make it as editable checkbox.

TRY.
CALL METHOD CL_SALV_TABLE=>FACTORY(
EXPORTING
* LIST_DISPLAY = IF_SALV_C_BOOL_SAP=>FALSE
R_CONTAINER = G_CUSTOM_CONTAINER
* CONTAINER_NAME = G_CUSTOM_CONTAINER
IMPORTING
R_SALV_TABLE = O_ALV
CHANGING
T_TABLE = it_data )
.
CATCH CX_SALV_MSG .
ENDTRY.

data: lr_events type ref to cl_salv_events_table.
data: gr_events type ref to lcl_handle_events.

lr_events = o_alv->get_event( ).

lr_columns = o_alv->get_columns( ).
lr_columns->set_optimize( gc_true ).
lr_column ?= lr_columns->get_column( 'CHECKBOX' ).
lr_column->set_cell_type( if_salv_c_cell_type=>checkbox ).
lr_column->set_long_text( 'CHECKBOX' ).


create object gr_events.


set handler gr_events->on_double_click for lr_events.
set handler gr_events->on_link_click for lr_events.

O_ALV->DISPLAY( ).

I am trying to use below code but not able to make editable checkbox.

*DATA: "lr_table TYPE REF TO cl_salv_table,
* lr_selections TYPE REF TO cl_salv_selections.
*DATA: lr_columns TYPE REF TO cl_salv_columns_table.
*
* lr_selections = o_alv->get_selections( ).
* lr_selections->set_selection_mode( if_salv_c_selection_mode=>row_column ).

*



Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Aug 31, 2012 at 06:23 AM

    Hiii,

    editable checkbox in salv not possible ...... use cl_gui_alv_grid for this see example bcalv* .

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 31, 2012 at 06:27 AM

    Hi ashish,

    thank you your answer, but here i am using cl_salv_table not cl_gui_alv_grid..

    I want to use the events of cl_salv_table

    please guide on same

    thank you

    Add a comment
    10|10000 characters needed characters exceeded

    • Hii,

      In my example just you need to handle event but its ok you can get help from below code which was provide by - Naimesh Patel

      See example by - Naimesh Patel

      *&---------------------------------------------------------------------*

      *& SALV Table, editable checkbox

      *&

      *&---------------------------------------------------------------------*

      REPORT zsalv_editable_checkbox.

      *

      *----------------------------------------------------------------------*

      * CLASS lcl_report DEFINITION

      *----------------------------------------------------------------------*

      CLASS lcl_report DEFINITION.

      *

      PUBLIC SECTION.

      *

      * Final output table

      TYPES: BEGIN OF ty_vbak,

      vbeln TYPE vbak-vbeln,

      erdat TYPE erdat,

      auart TYPE auart,

      kunnr TYPE kunnr,

      check TYPE flag,

      END OF ty_vbak.

      *

      DATA: t_vbak TYPE STANDARD TABLE OF ty_vbak.

      *

      * ALV reference

      DATA: o_alv TYPE REF TO cl_salv_table.

      *

      METHODS:

      * data selection

      get_data,

      *

      * Generating output

      generate_output.

      *

      *

      ENDCLASS. "lcl_report DEFINITION

      *

      CLASS lcl_event_handler DEFINITION.

      *

      PUBLIC SECTION.

      METHODS:

      on_link_click FOR EVENT link_click OF cl_salv_events_table

      IMPORTING row column.

      *

      ENDCLASS. "lcl_event_handler DEFINITION

      *

      *

      START-OF-SELECTION.

      DATA: lo_report TYPE REF TO lcl_report.

      *

      CREATE OBJECT lo_report.

      *

      lo_report->get_data( ).

      *

      lo_report->generate_output( ).

      *

      *----------------------------------------------------------------------*

      * CLASS lcl_report IMPLEMENTATION

      *----------------------------------------------------------------------*

      CLASS lcl_report IMPLEMENTATION.

      *

      METHOD get_data.

      * data selection

      SELECT vbeln erdat auart kunnr

      INTO TABLE t_vbak

      FROM vbak

      UP TO 20 ROWS.

      *

      ENDMETHOD. "get_data

      *

      *.......................................................................

      METHOD generate_output.

      *

      * exception class

      DATA: lx_msg TYPE REF TO cx_salv_msg.

      TRY.

      cl_salv_table=>factory(

      IMPORTING

      r_salv_table = o_alv

      CHANGING

      t_table = t_vbak ).

      CATCH cx_salv_msg INTO lx_msg.

      ENDTRY.

      *

      *...Get all the Columns

      DATA: lo_cols TYPE REF TO cl_salv_columns.

      lo_cols = o_alv->get_columns( ).

      *

      * set the Column optimization

      lo_cols->set_optimize( 'X' ).

      *

      *...Process individual columns

      DATA: lo_column TYPE REF TO cl_salv_column_list.

      *

      * Change the properties of the Columns KUNNR

      TRY.

      lo_column ?= lo_cols->get_column( 'CHECK' ).

      lo_column->set_cell_type( if_salv_c_cell_type=>checkbox_hotspot ).

      lo_column->set_output_length( 10 ).

      CATCH cx_salv_not_found. "#EC NO_HANDLER

      ENDTRY.

      *

      * Get the event object

      DATA: lo_events TYPE REF TO cl_salv_events_table.

      lo_events = o_alv->get_event( ).

      *

      * Instantiate the event handler object

      DATA: lo_event_handler TYPE REF TO lcl_event_handler.

      CREATE OBJECT lo_event_handler.

      *

      * event handler

      SET HANDLER lo_event_handler->on_link_click FOR lo_events.

      *

      * Displaying the ALV

      * Here we will call the DISPLAY method to get the output on the screen

      o_alv->display( ).

      *

      ENDMETHOD. "generate_output

      *

      ENDCLASS. "lcl_report IMPLEMENTATION

      *

      *----------------------------------------------------------------------*

      * CLASS lcl_event_handler IMPLEMENTATION

      *----------------------------------------------------------------------*

      CLASS lcl_event_handler IMPLEMENTATION.

      *

      METHOD on_link_click.

      *

      * Get the value of the checkbox and set the value accordingly

      * Refersh the table

      FIELD-SYMBOLS: <lfa_data> LIKE LINE OF lo_report->t_vbak.

      READ TABLE lo_report->t_vbak ASSIGNING <lfa_data> INDEX row.

      CHECK sy-subrc IS INITIAL.

      IF <lfa_data>-check IS INITIAL.

      <lfa_data>-check = 'X'.

      ELSE.

      CLEAR <lfa_data>-check.

      ENDIF.

      lo_report->o_alv->refresh( ).

      ENDMETHOD. "on_link_click

      *

      ENDCLASS. "lcl_event_handler IMPLEMENTATION

  • Posted on Aug 31, 2012 at 06:27 AM

    This topic has been discussed many times here. Unlike CL_GUI_ALV_GRID, ALV OM (CL_SALV_TABLE) does not provide "editable" functionality. See the discussion cl_salv_table --needs editable functionality -SAP please provide this

    Regards, Vinod

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.