cancel
Showing results for 
Search instead for 
Did you mean: 

ALV TREE-Checkbox

Former Member
0 Kudos

Hello folks,

After having built the tree, I am trying to set the checkbox to 'X' (i.e. marked) via the ABAP-program (not from screen), unfortunately to no avail.

The used technique is the checkbox-functionality, which is controlled by structure LVC_S_LACI and not by the field catalogue.

For example:

data: ls_layout_item type lvc_s_laci,

  • fill checkbox data

clear ls_layout_item.

ls_layout_item-fieldname = 'CHECKBOX'.

ls_layout_item-class = cl_gui_column_tree=>item_class_checkbox.

ls_layout_item-editable = 'X'.

ls_layout_item-u_class = 'X'.

ls_layout_item-u_editable = 'X'.

append ls_layout_item to lt_layout_item.

  • add node with checkbox

call method p_tree->add_node

exporting

i_relat_node_key = l_connid_key

i_relationship = cl_gui_column_tree=>relat_last_child

is_outtab_line = ls_outtab

i_node_text = l_node_text

is_node_layout = l_layout_leaf

it_item_layout = lt_layout_item.

When adding a node I can set the checkbox to marked by setting field 'CHOSEN' of structure 'LVC_S_LACI' to 'X'. But I have not yet succeeded to set the checkbox of an existing node to 'X'.

  • First try:

I set the checkbox to X and called method 'UPDATE_NODE' . As a result I got an X right to the checkbox, which inself remained unmarked.

  • Second try:

I filled the interface table ' IT_ITEM_LAYOUT' with data, set field 'CHOOSEN' to 'X' and called method 'CHANGE_ITEM'. But this does not work either.

I would be very happy if someone could help me in this matter.

Fouad Sebbane

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hello... did you solve this? "change_item" should work... it works here!

Sample code:

data: ls_laci TYPE lvc_s_laci,

lv_child TYPE lvc_nkey.

" ... get node key into lv_child

ls_laci-fieldname = cl_alv_tree_base=>c_hierarchy_column_name.

ls_laci-chosen = l_x. " " 'X'=checked, ' '=unchecked

ls_laci-u_chosen = 'X'.

CALL METHOD me->change_item

EXPORTING i_node_key = lv_child

i_fieldname = cl_alv_tree_base=>c_hierarchy_column_name

i_data = ''

i_u_data = ''

is_item_layout = ls_laci.

former_member183804
Active Contributor
0 Kudos

You may need to set the layout on tree items to hidden. In a recent thread there is a full blown sample:

Best Regards

Klaus

former_member122654
Participant
0 Kudos

Hi,

the field 'CHECKBOX' is used in the internal Output table of the tree.

I tried already that what you proposed and it did not work.

Thanks,

Fouad

athavanraja
Active Contributor
0 Kudos

Did you try the method

data: treevar type ref to CL_GUI_COLUMN_TREE .

treevar->ITEM_SET_CHOSEN

exporting

NODE_KEY = <node key>

ITEM_NAME = <item name>

CHOSEN = 'X'

Regards

Raja

former_member122654
Participant
0 Kudos

Hallo Raja,

i tried as follow:

I used the class cl_gui_alv_grid. In this class there is the protected varialbe object 'mr_column_tree'.

I created a new class 'lcl_grid' and added the method 'set_checkbox_chosen'.

Example:

class lcl_tree definition inheriting from cl_gui_alv_tree.

public section.

.....

method set_checkbox_chosen

importing

i_node_key type tv_nodekey

i_item_name type tv_itemname

i_chosen type as4flag.

.....

endclass.

class lcl_tree implementation.

method set_checkbox.

call method me->mr_column_tree->item_set_chosen

exporting

node_key = i_node_key

item_name = i_item_name

chosen = i_chosen

exceptions

Failed = 1

node_not_found = 2

item_not_found = 3

cntl_system_error = 4

chosen_not_supported = 5

others = 6.

endmethod.

After calling the method 'set_checkbox', i called the method 'frontend_update'.

A message popup (Gui Control) with the following Information appears:

Column not found

LastError node key: 5

LastError item name: CHECKBOX

the node_key 5 however exists!

Thanks,

Fouad

Former Member
0 Kudos

Hi Karsten/Fouad,


* fill checkbox data
clear ls_layout_item.
<b>ls_layout_item-fieldname = 'CHECKBOX'.</b>
ls_layout_item-class = cl_gui_column_tree=>item_class_checkbox.
ls_layout_item-editable = 'X'.
ls_layout_item-u_class = 'X'.
ls_layout_item-u_editable = 'X'.
append ls_layout_item to lt_layout_item.

In which internal table , do you have this field 'CHECKBOX' ?

Try putting an 'X' in the field 'CHECKBOX' of the internal table, that you are using.

Let us know, if it works.

Regards,

Subramanian V.