Hi friends,
I had a requirement of creating menu with checkbox.
simlar to pfcg->create new activity group -> (Copy menu) From SAP Menu ->
a menu list with checkbox is generated.
A
- B
- b1
- b2
- C
- D
This is a simple menu but i want a checkbox before B, C & D and b1 and b2.
So that I can select the nodes and do the necessary operations based on that.
please help me out.
Hello Sanjeev,
i can give you few pointers for solving your problem.
firstly you can use <b>cl_column_tree_model</b>to create the tree.
now the tree creation flow goes like this
1.Create a screen with a control area. CCAREA_TREE
2.Create an instance of the class which we are using for the tree control
data : gref_tree TYPE REF TO cl_column_tree_model,
gref_docking_container TYPE REF TO cl_gui_custom_container,
xt_treemcitac TYPE treemcitac,
ls_treemcitac LIKE LINE OF xt_treemcitac.
3.Create tree model for the instance of the class.
create object gref_tree
exporting
node_selection_mode = cl_column_tree_model=>node_sel_mode_single
HIDE_SELECTION =
EXCEPTIONS
ILLEGAL_NODE_SELECTION_MODE = 1
others = 2
.
4. Now we require to create containers for the tree model
create object gref_docking_container
exporting
PARENT =
container_name = 'CCAREA_TREE'
STYLE =
LIFETIME = lifetime_default
REPID =
DYNNR =
NO_AUTODEF_PROGID_DYNNR =
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5
others = 6
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
5. Create the view control for the tree model.
CALL METHOD gref_tree->create_tree_control
EXPORTING
LIFETIME =
parent = gref_docking_container
SHELLSTYLE =
IMPORTING
CONTROL =
EXCEPTIONS
LIFETIME_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
FAILED = 4
TREE_CONTROL_ALREADY_CREATED = 5
others = 6
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
6. Define the nodes of the tree
ls_treemcitac-node_key = key.
ls_treemcitac-item_name = 'COL1'.
ls_treemcitac-text = 'test1'.
ls_treemcitac-class = <b>cl_column_tree_model=>ITEM_CLASS_CHECKBOX</b> .
*"item_class_link.
APPEND ls_treemcitac TO xt_treemcitac.
7. finally add nodes to the tree
CALL METHOD gref_tree->add_items
EXPORTING
item_table = gt_treemcitac
EXCEPTIONS
NODE_NOT_FOUND = 1
ERROR_IN_ITEM_TABLE = 2
others = 3
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
To sum it up.. you need to check the attributes for <b>cl_column_tree_model</b>.
I ll be glad to answer your further queries.
Regards,
Kinshuk Saxena
Hi Sanjev,
Please take a look at this SAP demo programs.
<b>SAPCOLUMN_TREE_CONTROL_DEMO
SAPTLIST_TREE_CONTROL_DEMO
SAPSIMPLE_TREE_CONTROL_DEMO</b>
Hope this will help.
Regards,
Ferry Lianto
Add a comment