制作图表有两种方法:
1)调用 GRAPH_MATRIX_2D,根据内表数据做2维图,内表的第一个字段是key
DATA: BEGIN OF gt_itab OCCURS 0,
stu_name TYPE c LENGTH 20,
data1 TYPE f,
data2 TYPE f,
data3 TYPE f,
data4 TYPE f,
data5 TYPE f,
data6 TYPE f,
END OF gt_itab.
DATA: BEGIN OF gt_options OCCURS 0,
option TYPE c LENGTH 20,
END OF gt_options.
DATA: BEGIN OF gt_cols OCCURS 0,
col_name TYPE c LENGTH 15,
END OF gt_cols.
START-OF-SELECTION.
PERFORM sub_fill_data.
PERFORM sub_write_chart.
*&---------------------------------------------------------------------*
*& Form SUB_FILL_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM sub_fill_data .
gt_itab-stu_name = 'ZhangSan'.
gt_itab-data1 = '70.5'.
* gt_itab-data2 = '86.5'.
* gt_itab-data3 = '60'.
* gt_itab-data4 = '68'.
* gt_itab-data5 = '92.5'.
* gt_itab-data6 = '83'.
APPEND gt_itab.
gt_itab-stu_name = 'LiSi'.
gt_itab-data1 = '45.5'.
* gt_itab-data2 = '53'.
* gt_itab-data3 = '58'.
* gt_itab-data4 = '60.5'.
* gt_itab-data5 = '60'.
* gt_itab-data6 = '65'.
APPEND gt_itab.
gt_itab-stu_name = 'WangWu'.
gt_itab-data1 = '76.5'.
* gt_itab-data2 = '78.5'.
* gt_itab-data3 = '83.5'.
* gt_itab-data4 = '72'.
* gt_itab-data5 = '68'.
* gt_itab-data6 = '74'.
APPEND gt_itab.
gt_itab-stu_name = 'ZhaoLiu'.
gt_itab-data1 = '70'.
* gt_itab-data2 = '80'.
* gt_itab-data3 = '75'.
* gt_itab-data4 = '69'.
* gt_itab-data5 = '65'.
* gt_itab-data6 = '78'.
APPEND gt_itab.
gt_itab-stu_name = 'SunQi'.
gt_itab-data1 = '92'.
* gt_itab-data2 = '95'.
* gt_itab-data3 = '91'.
* gt_itab-data4 = '98'.
* gt_itab-data5 = '98.5'.
* gt_itab-data6 = '99.5'.
APPEND gt_itab.
gt_itab-stu_name = 'ZhouBa'.
gt_itab-data1 = '75'.
* gt_itab-data2 = '77'.
* gt_itab-data3 = '80'.
* gt_itab-data4 = '83'.
* gt_itab-data5 = '75'.
* gt_itab-data6 = '86'.
APPEND gt_itab.
gt_itab-stu_name = 'LiuJiu'.
gt_itab-data1 = '30'.
* gt_itab-data2 = '25.5'.
* gt_itab-data3 = '22.5'.
* gt_itab-data4 = '28'.
* gt_itab-data5 = '35'.
* gt_itab-data6 = '30'.
APPEND gt_itab.
gt_options-option = 'P2TYPE = LN'.
APPEND gt_options.
ENDFORM. " SUB_FILL_DATA
*&---------------------------------------------------------------------*
*& Form SUB_WRITE_CHART
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM sub_write_chart .
* CALL FUNCTION 'GRAPH_MATRIX_3D'
* EXPORTING
* col1 = 'JANUARY'
* col2 = 'FEBRUARY'
* col3 = 'MARCH'
* col4 = 'APRIL'
* col5 = 'MAY'
* col6 = 'June'
* titl = 'Students exam results chart'
* TABLES
* data = gt_itab[]
* opts = gt_options
* EXCEPTIONS
* OTHERS = 1.
CALL FUNCTION 'GRAPH_MATRIX_2D'
TABLES
data = gt_itab[]
opts = gt_options
tcol = gt_cols[]
EXCEPTIONS
COL_INVALID = 1
OPT_INVALID = 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.
ENDFORM. " SUB_WRITE_CHART
2)调用GRAPH_MATRIX_3D 做3维图,最多6个column
DATA: BEGIN OF gt_itab OCCURS 0,
stu_name TYPE c LENGTH 20,
data1 TYPE f,
data2 TYPE f,
data3 TYPE f,
data4 TYPE f,
data5 TYPE f,
data6 TYPE f,
END OF gt_itab.
DATA: BEGIN OF gt_options OCCURS 0,
option TYPE c LENGTH 20,
END OF gt_options.
DATA: BEGIN OF gt_cols OCCURS 0,
col_name TYPE c LENGTH 15,
END OF gt_cols.
START-OF-SELECTION.
PERFORM sub_fill_data.
PERFORM sub_write_chart.
*&---------------------------------------------------------------------*
*& Form SUB_FILL_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM sub_fill_data .
gt_itab-stu_name = 'ZhangSan'.
gt_itab-data1 = '70.5'.
gt_itab-data2 = '86.5'.
gt_itab-data3 = '60'.
gt_itab-data4 = '68'.
gt_itab-data5 = '92.5'.
gt_itab-data6 = '83'.
APPEND gt_itab.
gt_itab-stu_name = 'LiSi'.
gt_itab-data1 = '45.5'.
gt_itab-data2 = '53'.
gt_itab-data3 = '58'.
gt_itab-data4 = '60.5'.
gt_itab-data5 = '60'.
gt_itab-data6 = '65'.
APPEND gt_itab.
gt_itab-stu_name = 'WangWu'.
gt_itab-data1 = '76.5'.
gt_itab-data2 = '78.5'.
gt_itab-data3 = '83.5'.
gt_itab-data4 = '72'.
gt_itab-data5 = '68'.
gt_itab-data6 = '74'.
APPEND gt_itab.
gt_itab-stu_name = 'ZhaoLiu'.
gt_itab-data1 = '70'.
gt_itab-data2 = '80'.
gt_itab-data3 = '75'.
gt_itab-data4 = '69'.
gt_itab-data5 = '65'.
gt_itab-data6 = '78'.
APPEND gt_itab.
gt_itab-stu_name = 'SunQi'.
gt_itab-data1 = '92'.
gt_itab-data2 = '95'.
gt_itab-data3 = '91'.
gt_itab-data4 = '98'.
gt_itab-data5 = '98.5'.
gt_itab-data6 = '99.5'.
APPEND gt_itab.
gt_itab-stu_name = 'ZhouBa'.
gt_itab-data1 = '75'.
gt_itab-data2 = '77'.
gt_itab-data3 = '80'.
gt_itab-data4 = '83'.
gt_itab-data5 = '75'.
gt_itab-data6 = '86'.
APPEND gt_itab.
gt_itab-stu_name = 'LiuJiu'.
gt_itab-data1 = '30'.
gt_itab-data2 = '25.5'.
gt_itab-data3 = '22.5'.
gt_itab-data4 = '28'.
gt_itab-data5 = '35'.
gt_itab-data6 = '30'.
APPEND gt_itab.
gt_options-option = 'P2TYPE = LN'.
APPEND gt_options.
ENDFORM. " SUB_FILL_DATA
*&---------------------------------------------------------------------*
*& Form SUB_WRITE_CHART
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM sub_write_chart .
CALL FUNCTION 'GRAPH_MATRIX_3D'
EXPORTING
col1 = 'JANUARY'
col2 = 'FEBRUARY'
col3 = 'MARCH'
col4 = 'APRIL'
col5 = 'MAY'
col6 = 'June'
titl = 'Students exam results chart'
TABLES
data = gt_itab[]
opts = gt_options
EXCEPTIONS
OTHERS = 1.
* CALL FUNCTION 'GRAPH_MATRIX_2D'
* TABLES
* data = gt_itab[]
* opts = gt_options
* tcol = gt_cols[]
* EXCEPTIONS
* COL_INVALID = 1
* OPT_INVALID = 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.
ENDFORM. " SUB_WRITE_CHART
根据内表数据做图表
原创wx638ee25dac6f7 博主文章分类:21 ABAP深入探索 ©著作权
©著作权归作者所有:来自51CTO博客作者wx638ee25dac6f7的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
java根据表名称获取所有字段
java根据表名称获取所有字段
字段 java sql -
idea 一直解析maven依赖
Maven引言: 本文主要分享了Maven的相关知识,包括:Maven的安装、配置、仓库的种类、使用IDEA关联Maven、在IDEA中创建Maven项目的步骤(导入依赖的方法)、 创建Web项目的流程; 文章目录Maven1. Maven简介2. Mave
idea 一直解析maven依赖 maven java Web tomcat