最近因为R&D中心的需求,用cl_gui_list_tree做了一个功能模块。
INCLUDE YTLIST_TREE_CONTROL_DEMOF01.
FORM build_node_and_item_table
USING
node_table TYPE treev_ntab
item_table TYPE item_table_type.
DATA: node TYPE treev_node,
init TYPE c,
item TYPE mtreeitm.
DATA:BEGIN OF gv_node OCCURS 0,
node TYPE int4,
END OF gv_node.
DATA:gt_detail LIKE zpp_die_technics OCCURS 0 WITH HEADER LINE.
node-node_key = c_nodekey-root.
CLEAR node-relatkey. " Special case: A root node has no parent
CLEAR node-relatship. " node.
node-hidden = ' '. " The node is visible,
node-disabled = ' '. " selectable,
node-isfolder = 'X'. " a folder.
CLEAR node-n_image. " Folder-/ Leaf-Symbol in state "closed":
CLEAR node-exp_image. " Folder-/ Leaf-Symbol in state "open":
CLEAR node-expander. " see below.
APPEND node TO node_table.
CLEAR item.
item-node_key = c_nodekey-root.
item-item_name = '1'. " Item with name '1'
item-class = cl_gui_list_tree=>item_class_text. " Text Item
item-alignment = cl_gui_list_tree=>align_auto.
item-font = cl_gui_list_tree=>item_font_prop.
item-text = '产品结构树'.
APPEND item TO item_table.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE gt_detail
FROM zpp_die_technics
WHERE nodty = '3'.
DATA: in TYPE i.
DATA:tnode LIKE zpp_die_technics-parno.
SORT gt_detail BY parre chire.
tnode = c_nodekey-root.
LOOP AT gt_detail.
READ TABLE gv_node WITH KEY node = gt_detail-parre.
IF sy-subrc = 4.
IF gt_detail-parre = 2.
CLEAR node.
node-node_key = gt_detail-parno.
node-relatkey = tnode.
node-relatship = cl_gui_list_tree=>relat_last_child.
node-isfolder = 'X'.
APPEND node TO node_table.
CLEAR item.
item-node_key = gt_detail-parno.
item-item_name = sy-tabix."gt_detail-chino.
item-class = cl_gui_list_tree=>item_class_text.
item-alignment = cl_gui_list_tree=>align_auto.
item-font = cl_gui_list_tree=>item_font_prop.
item-text = '第二节点'."gt_detail-parno.
APPEND item TO item_table.
gv_node-node = gt_detail-parre.
APPEND gv_node.
READ TABLE gv_node WITH KEY node = gt_detail-chire.
IF sy-subrc = 4.
CLEAR node.
node-node_key = gt_detail-chino.
node-relatkey = gt_detail-parno.
node-relatship = cl_gui_list_tree=>relat_last_child.
node-isfolder = 'X'.
APPEND node TO node_table.
CLEAR item.
item-node_key = gt_detail-chino.
item-item_name = sy-tabix."gt_detail-chino.
item-class = cl_gui_list_tree=>item_class_text.
item-alignment = cl_gui_list_tree=>align_auto.
item-font = cl_gui_list_tree=>item_font_prop.
item-text = gt_detail-nodre.
APPEND item TO item_table.
gv_node-node = gt_detail-chire.
APPEND gv_node.
ENDIF.
ENDIF.
ELSE.
READ TABLE gv_node WITH KEY node = gt_detail-chire.
IF sy-subrc = 4.
CLEAR node.
node-node_key = gt_detail-chino.
node-relatkey = gt_detail-parno.
node-relatship = cl_gui_list_tree=>relat_last_child.
node-isfolder = 'X'.
APPEND node TO node_table.
CLEAR item.
item-node_key = gt_detail-chino.
item-item_name = sy-tabix."gt_detail-chino.
item-class = cl_gui_list_tree=>item_class_text.
item-alignment = cl_gui_list_tree=>align_auto.
item-font = cl_gui_list_tree=>item_font_prop.
item-text = gt_detail-nodre.
APPEND item TO item_table.
gv_node-node = gt_detail-chire.
APPEND gv_node.
ENDIF.
ENDIF.
ENDLOOP.
REFRESH gt_detail.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE gt_detail
FROM zpp_die_technics
WHERE nodty = '4'.
LOOP AT gt_detail.
READ TABLE gv_node WITH KEY node = gt_detail-parre.
IF sy-subrc = 0.
CLEAR node.
node-node_key = gt_detail-chino.
node-relatkey = gt_detail-parno.
node-relatship = cl_gui_list_tree=>relat_last_child.
APPEND node TO node_table.
CLEAR item.
item-node_key = gt_detail-chino.
item-item_name = sy-tabix."gt_detail-chino.
item-class = cl_gui_list_tree=>item_class_text.
item-alignment = cl_gui_list_tree=>align_auto.
item-font = cl_gui_list_tree=>item_font_prop.
item-text = gt_detail-nodre.
APPEND item TO item_table.
ENDIF.
ENDLOOP.
ENDFORM. " build_node_and_item_table
MANDT |
1 |
VARCHAR |
9 |
|
X |
'000' |
CHINO |
2 |
VARCHAR |
54 |
|
X |
' ' |
PARNO |
3 |
VARCHAR |
54 |
|
X |
' ' |
NODRE |
4 |
VARCHAR |
54 |
|
X |
' ' |
NODTY |
5 |
VARCHAR |
3 |
|
X |
'0' |
PARRE |
6 |
VARCHAR |
12 |
|
X |
'0000' |
CHIRE |
7 |
VARCHAR |
12 |
|
X |
'0000' |
NODNU |
8 |
INTEGER |
4 |
|
X |
0 |
NODAD |
9 |
VARCHAR |
750 |
|
X |
' ' |
ALUMS |
10 |
VARCHAR |
54 |
|
X |
' ' |
|
阅读(1127) | 评论(0) | 转发(0) |