Application Development and Automation 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: 
Read only

Check(Tick) the Checkbox in CL_GUI_LIST_TREE programaically

Former Member
0 Likes
2,807

Hi Experts,

I have developed a List Tree using CL_GUI_LIST_TREE wherein checkboxes are assigned to each node(Parent and Child). I am able to identify the changes done to any checkbox on screen using CHECKBOX_CHANGE event of this class. But I am stuck at one additional functionality described below

1. Depeding on the checkbox selected I want to Check or Uncheck(Tick or Untick) the checkboxes dynamically

    For e.g. If Parent Node is Selected(Checked) by user, all Children nodes' checkboxes should get selected(Checked) and viceversa.

2. As a workaround I managed to handle this functionality(considering all children if parent is selected or ignoring all children if parent is 
   unselected) internally in program and whole logic is working fine. But problem is we want these changes to get reflected on screen too.

I tried to find the solution on SDN but in vain.

Please help me with this because I am breaking my head since 2 days to achieve this.

7 REPLIES 7
Read only

custodio_deoliveira
Active Contributor
0 Likes
2,643

Hi ABAP Beginner (I believe it's not you real name, right?),

I haven't done much (or any) ALV lately, but have you tried calling the method   SET_SCREEN_UPDATE( ABAP_TRUE ) to reflect the changes in the screen?

Not sure it's gonna work, but may be worth a try (if not tried yet).

Cheers,

Custodio

Read only

0 Likes
2,643

ABAP Beginner or justfun (see profile URL) can't be real names.

Read only

0 Likes
2,643

Thanks Custodio for the suggestion. I couldn't understand how to use this method and how will it help me in updating the specific Children's checkboxes dynamically. Can you please elaborate.

P.S: Updated my profile with real name.

Read only

0 Likes
2,643

Thanks Manish for acknowleding that.
I never received any valid answers to any of my query till date from your side, but given the gossip yours comes first always Though I first made profile by name Justfun, you seem to be here only for fun. No hard feelings. Updated my profile, hope wont be a problem for you anymore.

Read only

0 Likes
2,643

Hi Custodio,

I had some progress on this. Found a method ITEM_SET_CHOSEN which can be used to select/deselect the checkbox for given Item of Tree as follows.

CALL METHOD tree->item_set_chosen

  EXPORTING node_key = node_key

item_name = item_name

chosen = chosen

  EXCEPTIONS failed  = 1

node_not_found  = 2

item_not_found  = 3

cntl_system_error = 4

chosen_not_supported = 5.

But there is a new problem I am facing. Once this method is called, I am getting shortdump during PBO of my screen. Though I called SET_SCREEN_UPDATE, it's not working. Any idea on this?

Read only

0 Likes
2,643

It worked for me when method update_nodes_and_items was called after calling item_set_chosen.

Both these calls were done during event handling of double click event (NOT in PBO).

So here's what was done.

  1. Copy standard program SAPTLIST_TREE_CONTROL_DEMO
  2. Change class of item node with key New3 and New4, item_name '1' to item_class_checkbox.
  3. Call methods item_set_chosen and update_nodes_items on event trigger (i chose double click)

Default of program was:

After double clicking SAPTROX1 comment, checkbox was selected.

After double clicking SAPTRIXTROX comment, checkbox was selected.

The changed code snippets are:

* Items of node with key 'New3'

      CLEAR item.

      item-node_key = c_nodekey-new3.

      item-item_name = '1'.

      item-class = cl_gui_list_tree=>item_class_checkbox.

*      item-editable = 'X'.

      item-length = 11.

      item-usebgcolor = 'X'. "

      item-text = 'SAPTROX1'.

      APPEND item TO item_table.

...

* Items of node with key 'New4'

      CLEAR item.

      item-node_key = c_nodekey-new4.

      item-item_name = '1'.

      item-class = cl_gui_list_tree=>item_class_checkbox.

      item-length = 11.

      item-usebgcolor = 'X'. "

      item-text = 'SAPTRIXTROX'.

      APPEND item TO item_table.

...

METHOD  handle_item_double_click.

" this method handles the item double click event of the tree

" control instance

" show the key of the node and the name of the item

" of the double clicked item in a dynpro field

g_event = 'ITEM_DOUBLE_CLICK'.

g_node_key = node_key.

g_item_name = item_name.

CALL METHOD g_tree->item_set_chosen

  EXPORTING

    node_key             = node_key

    item_name            = '1'

    chosen               = 'X'

  EXCEPTIONS

    failed               = 1

    node_not_found       = 2

    item_not_found       = 3

    cntl_system_error    = 4

    chosen_not_supported = 5

    OTHERS               = 6.

CALL METHOD g_tree->update_nodes_and_items

  EXPORTING

    item_table_structure_name      = 'MTREEITM'

  EXCEPTIONS

    failed                         = 1

    cntl_system_error              = 2

    error_in_tables                = 3

    dp_error                       = 4

    table_structure_name_not_found = 5

    OTHERS                         = 6.

ENDMETHOD.                    "HANDLE_ITEM_DOUBLE_CLICK

Message was edited by: Manish Kumar

Read only

0 Likes
2,643

Thanks Manish for detailed solution. Will surely test this sometime later.

I somehow managed to solve my issue few weeks back by redesigning the tree with specific Children/Parent chosen whenever User selects specific node. I know this might not be smart solution given the performance issue, but because my tree was very small and also traversed rarely, it won't be a problem.