其他分享
首页 > 其他分享> > 创建list ALV tree[RS_TREE_LIST_DISPLAY]

创建list ALV tree[RS_TREE_LIST_DISPLAY]

作者:互联网

ABAP程序中的ALV显示是很常用的一种数据展示手段,除了常规的alv,有时也会用到ALV tree这种有层次结构的展示方式更好的展现数据,下面介绍一个创建list alv tree的方法:

1)用函数RS_TREE_CONSTRUCT构造alv 树的层次结构,

alv tree的节点类型(node type)分两种:T和P,区别如下:区别就是个文件夹的图标。

2017-03-13_20-44-24

2)调用函数RS_TREE_LIST_DISPLAY显示alv tree

完整代码:

用list alv tree来显示采购订单和采购订单行项目。

 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 REPORT ztest_tree_alv.   *Data declaration for additional node information DATA : gwa_node TYPE snodetext. *Internal table for nodes DATA : git_node LIKE TABLE OF gwa_node. DATA:git_ekko TYPE STANDARD TABLE OF ekko WITH HEADER LINE,      git_ekpo TYPE STANDARD TABLE OF ekpo WITH HEADER LINE.   CLEAR :  gwa_node. REFRESH: git_node.   SELECT *   FROM ekko   INTO TABLE git_ekko UP TO 10 ROWS.   SELECT *   INTO TABLE git_ekpo   FROM ekpo    FOR ALL ENTRIES IN git_ekko WHERE ebeln = git_ekko-ebeln.   gwa_node-type = 'T'.                   "第一个 gwa_node-id   = 'FIRST'. gwa_node-name = '采购'. gwa_node-tlevel = 1.                   "层次一 gwa_node-nlength = '15'. gwa_node-color = '4'. gwa_node-text = '采购订单信息'. gwa_node-tlength ='20'. gwa_node-tcolor = 3. APPEND gwa_node TO git_node. LOOP AT git_ekko.   CLEAR gwa_node.   gwa_node-type = 'P'.   gwa_node-id   = 'HEAD'.   gwa_node-name = '采购订单号'.   gwa_node-tlevel = 2.                  "层次二   gwa_node-nlength = '8'.   gwa_node-color = '1'.   gwa_node-text = git_ekko-ebeln.   gwa_node-tlength ='20'.   gwa_node-tcolor = 4.   APPEND gwa_node TO git_node.   CLEAR gwa_node.   LOOP AT git_ekpo where ebeln = git_ekko-ebeln.     CLEAR gwa_node.     gwa_node-type = 'P'.     gwa_node-id   = 'ITEM'.     gwa_node-name = '行项目'.     gwa_node-tlevel = 3.                  "层次三     gwa_node-nlength = '6'.     gwa_node-color = '1'.     gwa_node-text = git_ekpo-ebelp.     gwa_node-tlength ='5'.     gwa_node-tcolor = 4.     APPEND gwa_node TO git_node.     CLEAR gwa_node.   ENDLOOP. ENDLOOP.   *Fm for constructing the tree CALL FUNCTION 'RS_TREE_CONSTRUCT'   TABLES     nodetab = git_node.   *FM for displaying the tree CALL FUNCTION 'RS_TREE_LIST_DISPLAY'   EXPORTING     callback_program     = sy-repid     check_duplicate_name = '1'     color_of_node        = '4'     color_of_mark        = '3'     color_of_link        = '1'     color_of_match       = '5'     node_length          = 30     text_length          = 75     use_control          = 'L'.

运行结果:

2017-03-13_20-29-10

以上

标签:node,git,gwa,RS,LIST,TREE,tree,alv,ekko
来源: https://www.cnblogs.com/lvdong18847870057/p/12540551.html