Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Check Box in Tree View

Former Member
0 Kudos

I have created ALV TREE VIEW using CL_GUI_ALV_TREE.

i have set the check boxes at nodes.

now whenever user checks the checkbox and selects the pushbutton on PF-Status..at that time i want to capture the checkbox in my internal table...

please fine me a solution.

Thanks.

2 REPLIES 2

Former Member
0 Kudos

Following code is to add checkboxes in ALV tree:

FORM add_root_request USING pls_data_ TYPE csg_gs_outtab_p_key__l_is_sub_node_ TYPE c

CHANGING pl_carrid_key._node = nodes->add_node( related_node = p_key

relationship = cl_gui_column_tree=>relat_last_child ).

  • ... §0.2 if information should be displayed at

  • the hierarchy column set the carrid as text for this node

text = p_ls_data-object.

node->set_text( text ).

  • ... §0.3 set the data for the nes node

node->set_data_row( p_ls_data ).

item = node->get_hierarchy_item( ).

item = node->get_item( 'FCHECKBOX' ). "FCHECKBOX is my radio button field in internal table which I am using to populate the ALV

item->set_type( if_salv_c_item_type=>checkbox ).

pl_carrid_key = node->get_key( )._

CATCH cx_salv_msg.

ENDFORM_._Following code is for handling checbox_change event

PERFORM application_action_events.

FORM application_action_events .

data: lr_events type ref to cl_salv_events_tree.

*data gr_events type ref to lcl_handle_events.

lr_events = gr_tree->get_event( ).

create object gr_events.

set handler gr_events->check for lr_events.

  • set handler gr_events->on_link_click for lr_events.

*

  • set handler gr_events->on_before_user_command for lr_events.

*

  • set handler gr_events->on_after_user_command for lr_events.

*

  • set handler gr_events->on_keypress for lr_events.

endform. " application_action_events----

-


CLASS lcl_handle_events DEFINITION.

PUBLIC SECTION.

METHODS:

check FOR EVENT checkbox_change OF cl_salv_events_tree IMPORTING node_key columnname checked. "Here node_key is the row number

ENDCLASS. "lcl_handle_events DEFINITION

*----


*

  • CLASS lcl_handle_events IMPLEMENTATION

*----


*

  • §4.2 implement the events for handling the events of cl_salv_table

*----


*

CLASS lcl_handle_events IMPLEMENTATION_._

METHOD check_._

WRITE 'hello'_._

DATA lwa_modify_check_ TYPE REF TO csg_gs_outtab.

node_key = node_key - 1_._

READ TABLE csg_gt_list INDEX node_key REFERENCE INTO lwa_modify_check._

if columnname = 'FCHECKBOX'_._

IF checked = 'X'_._

  • If the value in internal table is set to X, then it is deselct

lwa_modify_check->fcheckbox =_ ' '_._

ELSE_._

lwa_modify_check->fcheckbox =_ 'X'_._

ENDIF_._

ENDIF_._

if columnname = 'CHECKBOX_READ'_._

IF checked = 'X'_._

  • If the value in internal table is set to X, then it is deselct

lwa_modify_check->checkbox_read =_ ' '_._

ELSE_._

lwa_modify_check->checkbox_read =_ 'X'_._

ENDIF_._

ENDIF_._

*MODIFY TABLE csg_gt_list from l_wa_modify_check.

flag_test = flag_test + 1_._

ENDMETHOD_._ "check

ENDCLASS_._ "lcl_handle_events IMPLEMENTATION

Please give me reward points

Former Member
0 Kudos

Define class to handle user interaction other than via toolbar buttons. Insert at end of DATA declaration section but before any ABAP processing.

CLASS lcl_tree_event_receiver DEFINITION.

  PUBLIC SECTION.

    METHODS handle_node_ctmenu_request
      FOR EVENT node_context_menu_request OF cl_gui_alv_tree
        IMPORTING node_key
                  menu.
    METHODS handle_node_ctmenu_selected
      FOR EVENT node_context_menu_selected OF cl_gui_alv_tree
        IMPORTING node_key
                  fcode.
    METHODS handle_item_ctmenu_request
      FOR EVENT item_context_menu_request OF cl_gui_alv_tree
        IMPORTING node_key
                  fieldname
                  menu.
    METHODS handle_item_ctmenu_selected
      FOR EVENT item_context_menu_selected OF cl_gui_alv_tree
        IMPORTING node_key
                  fieldname
                  fcode.

    METHODS handle_item_double_click
      FOR EVENT item_double_click OF cl_gui_alv_tree
      IMPORTING node_key
                fieldname.

    METHODS handle_button_click
      FOR EVENT button_click OF cl_gui_alv_tree
      IMPORTING node_key
                fieldname.

    METHODS handle_link_click
      FOR EVENT link_click OF cl_gui_alv_tree
      IMPORTING node_key
                fieldname.

    METHODS handle_header_click
      FOR EVENT header_click OF cl_gui_alv_tree
      IMPORTING fieldname.

ENDCLASS.

*---------------------------------------------------------------------*
*       CLASS lcl_tree_event_receiver IMPLEMENTATION
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
CLASS lcl_tree_event_receiver IMPLEMENTATION.

  METHOD handle_node_ctmenu_request.
*   append own functions
    CALL METHOD menu->add_function
                EXPORTING fcode   = 'USER1'
                          text    = 'Usercmd 1'.            "#EC NOTEXT
    CALL METHOD menu->add_function
                EXPORTING fcode   = 'USER2'
                          text    = 'Usercmd 2'.            "#EC NOTEXT
    CALL METHOD menu->add_function
                EXPORTING fcode   = 'USER3'
                          text    = 'Usercmd 3'.            "#EC NOTEXT
  ENDMETHOD.

  METHOD handle_node_ctmenu_selected.
    CASE fcode.
      WHEN 'USER1' OR 'USER2' OR 'USER3'.
        MESSAGE i000(0h) WITH 'Node-Context-Menu on Node ' node_key
                              'fcode : ' fcode.             "#EC NOTEXT
    ENDCASE.
  ENDMETHOD.

  METHOD handle_item_ctmenu_request .
*   append own functions
    CALL METHOD menu->add_function
                EXPORTING fcode   = 'USER1'
                          text    = 'Usercmd 1'.
    CALL METHOD menu->add_function
                EXPORTING fcode   = 'USER2'
                          text    = 'Usercmd 2'.
    CALL METHOD menu->add_function
                EXPORTING fcode   = 'USER3'
                          text    = 'Usercmd 3'.
  ENDMETHOD.

  METHOD handle_item_ctmenu_selected.
    CASE fcode.
      WHEN 'USER1' OR 'USER2' OR 'USER3'.
        MESSAGE i000(0h) WITH 'Item-Context-Menu on Node ' node_key
                              'Fieldname : ' fieldname.     "#EC NOTEXT
    ENDCASE.
  ENDMETHOD.

  METHOD handle_item_double_click.
* Processing for when user double clicks on ALVtree
  ENDMETHOD.

  METHOD handle_button_click.
* Processing when user clicks button   
  ENDMETHOD.

  METHOD handle_link_click.
* ??  
  ENDMETHOD.

  METHOD handle_header_click.
* Processing for when user clicks on ALVtree column headers 
  ENDMETHOD.

ENDCLASS.

Reward points if it is usefull ,.....

Girish