【ABAP Graph】图表显示开发案例
生活随笔
收集整理的這篇文章主要介紹了
【ABAP Graph】图表显示开发案例
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
REPORT ZTEST_GRAPH.
*** 因?yàn)槭琼樞驁?zhí)行的,要優(yōu)先包含進(jìn)來
INCLUDE GFW_DC_PRES.
TYPES:GFW_TEXT TYPE TEXT40.
DATA: BEGIN OF GT_TOP2 OCCURS 0,TOTAL LIKE COEP-MEGBTR,COMPL LIKE COEP-MEGBTR,DIFFE LIKE COEP-MEGBTR,END OF GT_TOP2.
DATA: G_COMP TYPE I,G_TOTA TYPE I.
DATA:OK_CODE TYPE SY-UCOMM,FIRSTCALL TYPE I,CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,DC_INST TYPE REF TO LCL_DC_PRES,DC_MANAGE TYPE REF TO IF_DC_MANAGEMENT,MY_ID_AT_DC TYPE I,RETVAL TYPE SYMSGNO,GP_INST TYPE REF TO CL_GUI_GP_PRES,GRPIDS TYPE GFW_GRPID_LIST.
DATA GO_CONT_C TYPE REF TO CL_GUI_CONTAINER.
CONSTANTS CO_GFW_PROG_OBJID_1 TYPE GFW_TEXT VALUE '1'.
CONSTANTS CO_GFW_PROG_OBJID_2 TYPE GFW_TEXT VALUE '2'.
CONSTANTS CO_GFW_PROG_OBJID_3 TYPE GFW_TEXT VALUE '3'.*&---------------------------------------------------------------------*
*& START-OF-SELECTION.
*&---------------------------------------------------------------------*
START-OF-SELECTION.CLEAR:GT_TOP2,G_TOTA, G_COMP.CALL SCREEN 9000.
*&---------------------------------------------------------------------*
*& Form MAKE_TOP2_PROC
*&---------------------------------------------------------------------*
FORM MAKE_TOP2_PROC .
*** 總數(shù)G_TOTA = 375.
*** 已完成G_COMP = 250.GT_TOP2-TOTAL = G_TOTA.GT_TOP2-COMPL = G_COMP.GT_TOP2-DIFFE = GT_TOP2-TOTAL - GT_TOP2-COMPL.COLLECT GT_TOP2.*** 圖表輸出PERFORM CALL_GRAPH_PROC2.
ENDFORM. " MAKE_TOP2_PROC*&---------------------------------------------------------------------*
*& Form CALL_GRAPH_PROC2
*&---------------------------------------------------------------------*
FORM CALL_GRAPH_PROC2 .RETVAL = CL_GFW=>OK.
* create, initialize and fill data containerCREATE OBJECT DC_INST.DC_MANAGE = DC_INST.CALL METHOD DC_MANAGE->INITIMPORTINGID = MY_ID_AT_DCRETVAL = RETVAL.IF RETVAL <> CL_GFW=>OK.CALL METHOD CL_GFW=>SHOW_MSGEXPORTINGMSGNO = RETVAL.CLEAR DC_INST.CLEAR DC_MANAGE.ELSE.PERFORM FILL_DC CHANGING RETVAL.IF RETVAL <> CL_GFW=>OK.CALL METHOD CL_GFW=>SHOW_MSGEXPORTINGMSGNO = RETVAL.ELSE.
** create a container on the dynpro
* CREATE OBJECT CUSTOM_CONTAINER
* EXPORTING
* CONTAINER_NAME = 'CONTAINER'.
* create, initialize and activate graphic proxyIF GP_INST IS NOT INITIAL.CALL METHOD GP_INST->IF_GRAPHIC_PROXY~FREEIMPORTINGRETVAL = RETVAL.ENDIF.CREATE OBJECT GP_INST.CALL METHOD GP_INST->IF_GRAPHIC_PROXY~INITEXPORTINGPARENT = GO_CONT_CDC = DC_INSTPROD_ID = CL_GUI_GP_PRES=>CO_PROD_CHARTFORCE_PROD = GFW_TRUEIMPORTINGRETVAL = RETVAL.IF RETVAL = CL_GFW=>OK.
* set dc attributesCALL METHOD GP_INST->SET_DC_NAMESEXPORTINGOBJ_ID = 'OBJID'DIM1 = 'X_VAL'DIM2 = 'Y_VAL'GRP_ID = 'GRPID'TEXT = 'TEXT' " for labels of a pointOBJREF_ID = 'CU_REFOBJ' " for customizing of a pointIMPORTINGRETVAL = RETVAL.ENDIF.* set customizing objectsIF RETVAL = CL_GFW=>OK."顏色填充PERFORM SET_CUSTOMIZING.ENDIF.IF RETVAL = CL_GFW=>OK.CALL METHOD GP_INST->IF_GRAPHIC_PROXY~ACTIVATEIMPORTINGRETVAL = RETVAL.ENDIF.IF RETVAL <> CL_GFW=>OK.CALL METHOD CL_GFW=>SHOW_MSGEXPORTINGMSGNO = RETVAL.ENDIF.ENDIF.FIRSTCALL = 1.ENDIF.
* **** distribute changes (to all subscribed graphic proxies)IF NOT DC_MANAGE IS INITIAL.CALL METHOD DC_MANAGE->DISTRIBUTE_CHANGESIMPORTINGRETVAL = RETVAL.IF RETVAL <> CL_GFW=>OK.CALL METHOD CL_GFW=>SHOW_MSGEXPORTINGMSGNO = RETVAL.ENDIF.ENDIF.ENDFORM. " CALL_GRAPH_PROC2*&---------------------------------------------------------------------*
*& Form FILL_DC
*&---------------------------------------------------------------------*
* ?? ??? ??
FORM FILL_DC CHANGING VALUE(RETVAL) TYPE SYMSGNO.DATA: OBJ TYPE GFWDCPRES,L_TXT TYPE CHAR6.
* fill dc with initial dataIF DC_MANAGE IS INITIAL.RETVAL = CL_GFW=>E_GP_DCHANDLE.EXIT.ENDIF.RETVAL = CL_GFW=>OK.
* insert first group (corresponding customizing class: cl_cu_values)OBJ-OBJID = CO_GFW_PROG_OBJID_1.OBJ-GRPID = TEXT-001.
* OBJ-X_VAL = CO_GFW_PROG_CATEGORY1.OBJ-Y_VAL = G_TOTA.L_TXT = G_TOTA.CONDENSE L_TXT.OBJ-TEXT = L_TXT. " label of this pointCALL METHOD DC_INST->SET_OBJ_VALUESEXPORTINGID = MY_ID_AT_DCOBJ = OBJIMPORTINGRETVAL = RETVAL.IF RETVAL <> CL_GFW=>OK.EXIT.ENDIF.OBJ-OBJID = CO_GFW_PROG_OBJID_2.OBJ-GRPID = TEXT-002.
* OBJ-X_VAL = CO_GFW_PROG_CATEGORY1.OBJ-Y_VAL = G_COMP.L_TXT = G_COMP.CONDENSE L_TXT.OBJ-TEXT = L_TXT. " label of this pointOBJ-CU_REFOBJ = SPACE. " connection to cl_cu_pointCALL METHOD DC_INST->SET_OBJ_VALUESEXPORTINGID = MY_ID_AT_DCOBJ = OBJIMPORTINGRETVAL = RETVAL.IF RETVAL <> CL_GFW=>OK.EXIT.ENDIF.OBJ-OBJID = CO_GFW_PROG_OBJID_3.OBJ-GRPID = TEXT-003.
* OBJ-X_VAL = CO_GFW_PROG_CATEGORY1.OBJ-Y_VAL = G_TOTA - G_COMP.L_TXT = G_TOTA - G_COMP.CONDENSE L_TXT.OBJ-TEXT = L_TXT. " label of this pointOBJ-CU_REFOBJ = SPACE. " connection to cl_cu_pointCALL METHOD DC_INST->SET_OBJ_VALUESEXPORTINGID = MY_ID_AT_DCOBJ = OBJIMPORTINGRETVAL = RETVAL.IF RETVAL <> CL_GFW=>OK.EXIT.ENDIF.ENDFORM. " FILL_DC*&---------------------------------------------------------------------*
*& Form SET_CUSTOMIZING
*&---------------------------------------------------------------------*
FORM SET_CUSTOMIZING .DATA: BUNDLE_DISPLAY TYPE REF TO CL_CU_DISPLAY_CONTEXT,BUNDLE_VALUES1 TYPE REF TO CL_CU_VALUES,BUNDLE_POINT1 TYPE REF TO CL_CU_POINT,BUNDLE_SHEET TYPE REF TO CL_CU_DATA_SHEET.* prepare display context for valuesCREATE OBJECT BUNDLE_DISPLAYEXPORTINGINSTANCE_ID = 'dummy'.
* set color of data seriesCALL METHOD BUNDLE_DISPLAY->IF_CUSTOMIZING~SETEXPORTINGATTR_ID = CL_CU_DISPLAY_CONTEXT=>CO_BG_CLR_PLT_IDVALUE = 4. " 黃色
* values (group 1)CREATE OBJECT BUNDLE_VALUES1EXPORTINGINSTANCE_ID = 'GFWLABEL'.
* copy display context into valuesCALL METHOD BUNDLE_VALUES1->IF_CUSTOMIZING~SETEXPORTINGATTR_ID = CL_CU_VALUES=>CO_CURVE_CONTEXTVALUE = BUNDLE_DISPLAY.
* copy display context into valuesCALL METHOD BUNDLE_VALUES1->IF_CUSTOMIZING~SETEXPORTINGATTR_ID = CL_CU_VALUES=>CO_LABEL_AUTOVALUE = GFW_FALSE.
* VALUE = GFW_TRUE.
* tell the proxy where to use the bundleCALL METHOD GP_INST->IF_GRAPHIC_PROXY~ADD_CU_BUNDLEEXPORTINGPORT = IF_GRAPHIC_PROXY=>CO_PORT_CHARTKEY = TEXT-001BUNDLE = BUNDLE_VALUES1IMPORTINGRETVAL = RETVAL.* prepare display context for valuesCREATE OBJECT BUNDLE_DISPLAYEXPORTINGINSTANCE_ID = 'dummy1'.
* set color of data seriesCALL METHOD BUNDLE_DISPLAY->IF_CUSTOMIZING~SETEXPORTINGATTR_ID = CL_CU_DISPLAY_CONTEXT=>CO_BG_CLR_PLT_IDVALUE = 5. " 綠色
* values (group 1)CREATE OBJECT BUNDLE_VALUES1EXPORTINGINSTANCE_ID = 'GFWLABEL1'.
* copy display context into valuesCALL METHOD BUNDLE_VALUES1->IF_CUSTOMIZING~SETEXPORTINGATTR_ID = CL_CU_VALUES=>CO_CURVE_CONTEXTVALUE = BUNDLE_DISPLAY.
* copy display context into valuesCALL METHOD BUNDLE_VALUES1->IF_CUSTOMIZING~SETEXPORTINGATTR_ID = CL_CU_VALUES=>CO_LABEL_AUTOVALUE = GFW_FALSE.
* VALUE = GFW_TRUE.
* tell the proxy where to use the bundleCALL METHOD GP_INST->IF_GRAPHIC_PROXY~ADD_CU_BUNDLEEXPORTINGPORT = IF_GRAPHIC_PROXY=>CO_PORT_CHARTKEY = TEXT-002BUNDLE = BUNDLE_VALUES1IMPORTINGRETVAL = RETVAL.* prepare display context for valuesCREATE OBJECT BUNDLE_DISPLAYEXPORTINGINSTANCE_ID = 'dummy2'.
* set color of data seriesCALL METHOD BUNDLE_DISPLAY->IF_CUSTOMIZING~SETEXPORTINGATTR_ID = CL_CU_DISPLAY_CONTEXT=>CO_BG_CLR_PLT_IDVALUE = 7. " 紅色
* values (group 1)CREATE OBJECT BUNDLE_VALUES1EXPORTINGINSTANCE_ID = 'GFWLABEL2'.
* copy display context into valuesCALL METHOD BUNDLE_VALUES1->IF_CUSTOMIZING~SETEXPORTINGATTR_ID = CL_CU_VALUES=>CO_CURVE_CONTEXTVALUE = BUNDLE_DISPLAY.
* copy display context into valuesCALL METHOD BUNDLE_VALUES1->IF_CUSTOMIZING~SETEXPORTINGATTR_ID = CL_CU_VALUES=>CO_LABEL_AUTOVALUE = GFW_FALSE.
* VALUE = GFW_TRUE.
* tell the proxy where to use the bundleCALL METHOD GP_INST->IF_GRAPHIC_PROXY~ADD_CU_BUNDLEEXPORTINGPORT = IF_GRAPHIC_PROXY=>CO_PORT_CHARTKEY = TEXT-003BUNDLE = BUNDLE_VALUES1IMPORTINGRETVAL = RETVAL.** prepare display context for point
* CREATE OBJECT BUNDLE_DISPLAY
* EXPORTING
* INSTANCE_ID = 'dummy'.
*
** set color of this point
* CALL METHOD BUNDLE_DISPLAY->IF_CUSTOMIZING~SET
* EXPORTING
* ATTR_ID = CL_CU_DISPLAY_CONTEXT=>CO_BG_CLR_PLT_ID
* VALUE = 5. " green
*
* CREATE OBJECT BUNDLE_POINT1
* EXPORTING
* INSTANCE_ID = 'GFWLABEL'.
*
** copy display context into point
* CALL METHOD BUNDLE_POINT1->IF_CUSTOMIZING~SET
* EXPORTING
* ATTR_ID = CL_CU_POINT=>CO_DISPLAY_CONTEXT
* VALUE = BUNDLE_DISPLAY.
*
** show text from DC
* CALL METHOD BUNDLE_POINT1->IF_CUSTOMIZING~SET
* EXPORTING
* ATTR_ID = CL_CU_POINT=>CO_AUTO
* VALUE = GFW_FALSE.
*
** tell the proxy where to use the bundle
* CALL METHOD GP_INST->IF_GRAPHIC_PROXY~ADD_CU_BUNDLE
* EXPORTING
* PORT = IF_GRAPHIC_PROXY=>CO_PORT_CHART
* KEY = CO_GFW_PROG_OBJID_2
* BUNDLE = BUNDLE_POINT1
* IMPORTING
* RETVAL = RETVAL.* prepare display context for drawing areaCREATE OBJECT BUNDLE_DISPLAYEXPORTINGINSTANCE_ID = 'dummy'.
* disable data sheetCALL METHOD BUNDLE_DISPLAY->IF_CUSTOMIZING~SETEXPORTINGATTR_ID = CL_CU_DISPLAY_CONTEXT=>CO_VISIBILITYVALUE = GFW_FALSE.
* data sheetCREATE OBJECT BUNDLE_SHEETEXPORTINGINSTANCE_ID = 'GFWLABEL'.
* copy display context into data sheetCALL METHOD BUNDLE_SHEET->IF_CUSTOMIZING~SETEXPORTINGATTR_ID = CL_CU_DATA_SHEET=>CO_DISPLAY_CONTEXTVALUE = BUNDLE_DISPLAY.
* tell the proxy where to use the bundleCALL METHOD GP_INST->IF_GRAPHIC_PROXY~ADD_CU_BUNDLEEXPORTINGPORT = IF_GRAPHIC_PROXY=>CO_PORT_CHARTBUNDLE = BUNDLE_SHEETIMPORTINGRETVAL = RETVAL.ENDFORM. " SET_CUSTOMIZING
*&---------------------------------------------------------------------*
*& Module STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_9000 OUTPUT.SET PF-STATUS '9000'.SET TITLEBAR 'TITLE'.PERFORM MAKE_TOP2_PROC.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9000 INPUT.CASE OK_CODE.WHEN 'BACK' OR 'CANCEL' OR 'EXIT'.LEAVE TO SCREEN 0.ENDCASE.
ENDMODULE.
?
總結(jié)
以上是生活随笔為你收集整理的【ABAP Graph】图表显示开发案例的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【Python】Flask 框架安装虚拟
- 下一篇: 【SAP】相关性类型简介