03-24-2006 12:08 PM
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.
03-24-2006 2:01 PM
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
03-25-2006 2:44 AM
Hi,
I am using SAP 4.6B, where i think the class concept is not possible. Please tell me how to use without classes.
Waiting for your reply...
thanks
sanjeev
03-25-2006 9:31 AM
Hi Sanjeev,
let me research on this and i ll get back to you.
regards,
Kinshuk
03-25-2006 10:43 AM
Hi Sanjeev,
If we are not using classes then i feel the only way to do that is list tree, but here i dont find a way to insert a <i>check box</i>.
the most that can be done is a <i>input</i> box of desired length.
If you have a look at the procedure of the list tree
DATA: gt_nodes LIKE TABLE OF <b>snodetext</b> WITH KEY id,
gd_nodes LIKE snodetext.
<b>gd_nodes-input </b> = 'X'.
gd_nodes-kind = ' '.
gd_nodes-hotspot = 'X'.
gd_nodes-tlength = 2.
gd_nodes-tcolor = 0.
append gd_nodes to gt_nodes.
CALL FUNCTION 'RS_TREE_CONSTRUCT'
EXPORTING
insert_id = '000000'
relationship = ' '
TABLES
nodetab = gt_nodes
EXCEPTIONS
tree_failure = 1
id_not_found = 2
wrong_relationship = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID 'CNV_MBT' TYPE 'E' NUMBER 016.
ENDIF.
CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
EXPORTING
callback_program = lv_callback_program
EXCEPTIONS
OTHERS = 1.
in the above example check the structure <b>snodetext</b>. you can use it as an alternative to check box but not exactly check box.
Hope you find this answer useful.
regards,
Kinshuk Saxena
PS do reward points if you find the answer useful
03-24-2006 3:06 PM
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