二维码

拆分container并实现数据图形化显示

Twilight发表于 2015-01-07 17:39CK_Rocky 最后回复于 2015-11-19 11:56 [复制链接] 1484 1

1、se38新建可执行程序
  1. *type pool declarations for graphical frame work
  2. TYPE-POOLS: gfw.
  3. *OK code declaration
  4. DATA: ok_code TYPE sy-ucomm.
  5. *structure declaration for graph 1 values
  6. TYPES : BEGIN OF ty_grvalwa1.
  7.         INCLUDE STRUCTURE gprval.
  8. TYPES : END OF ty_grvalwa1.
  9. *structure declaration for graph 1 column names
  10. TYPES : BEGIN OF ty_col1_texts.
  11.         INCLUDE STRUCTURE gprtxt.
  12. TYPES : END OF ty_col1_texts.
  13. *data declarations for graph 1
  14. DATA : grval1 TYPE STANDARD TABLE OF ty_grvalwa1,
  15.       grvalwa1 TYPE ty_grvalwa1,
  16.        col1_texts TYPE STANDARD TABLE OF ty_col1_texts,
  17.        col1_wa TYPE ty_col1_texts.
  18. *structure declaration for graph 2 values
  19. TYPES : BEGIN OF ty_grvalwa2.
  20.         INCLUDE STRUCTURE gprval.
  21. TYPES : END OF ty_grvalwa2.
  22. *structure declaration for graph 2 column names
  23. TYPES : BEGIN OF ty_col2_texts.
  24.         INCLUDE STRUCTURE gprtxt.
  25. TYPES : END OF ty_col2_texts.
  26. *data declarations for graph2
  27. DATA : grval2 TYPE STANDARD TABLE OF ty_grvalwa2,
  28.        grvalwa2 TYPE ty_grvalwa2,
  29.        col2_texts TYPE STANDARD TABLE OF ty_col2_texts,
  30.        col2_wa TYPE ty_col2_texts.
  31. *data declarations for containers,splitters,and custom container
  32. DATA :custom_container TYPE REF TO cl_gui_custom_container,
  33.       splitter TYPE REF TO cl_gui_splitter_container,
  34.       cont1 TYPE REF TO cl_gui_container,
  35.       cont2 TYPE REF TO cl_gui_container.
  36. *Initialisation event
  37. INITIALIZATION.
  38. *start of selection event
  39. START-OF-SELECTION.
  40. *Call screen for the container for output
  41.   CALL SCREEN 600.
  42. *PBO module for the output display
  43. *&----------------------------------------------------------------*
  44. *&      Module  PBO_0600  OUTPUT
  45. *&----------------------------------------------------------------*
  46. MODULE pbo_0600 OUTPUT.
  47. *Setting the GUI status for the splitter screen(EXIT button)
  48.   SET PF-STATUS 'SPLITGRAPH'.
  49. *Setting the title for the splitter control
  50.   SET TITLEBAR 'SPLITGRAPH'.
  51. *Creating custom container
  52.   CREATE OBJECT custom_container
  53.     EXPORTING
  54.       container_name = 'CONTAINER'.
  55. *creating the splitter control
  56.   CREATE OBJECT splitter
  57.     EXPORTING
  58.       parent  = custom_container
  59.       rows    = 1
  60.       columns = 2
  61.       align   = 15.
  62. *calling the container method of the splitter class
  63. *for the first graphic
  64.   CALL METHOD splitter->get_container
  65.     EXPORTING
  66.       row       = 1
  67.       column    = 1
  68.     RECEIVING
  69.       container = cont1.
  70. *calling the container method of the splitter class
  71. *for the second graphic
  72.   CALL METHOD splitter->get_container
  73.     EXPORTING
  74.       row       = 1
  75.       column    = 2
  76.     RECEIVING
  77.       container = cont2.
  78. *Graphic 1 display
  79.   REFRESH : grval1,col1_texts.
  80.   grvalwa1-rowtxt = 'Rice'.
  81.   grvalwa1-val1 = 1100.
  82.   grvalwa1-val2 = 4500.
  83.   APPEND grvalwa1 TO grval1.
  84.   grvalwa1-rowtxt = 'Coffee'.
  85.   grvalwa1-val1 = 2000.
  86.   grvalwa1-val2 = 6000.
  87.   APPEND grvalwa1 TO grval1.
  88.   grvalwa1-rowtxt = 'Tea'.
  89.   grvalwa1-val1 = 3500.
  90.   grvalwa1-val2 = 7000.
  91.   APPEND grvalwa1 TO grval1.
  92.   grvalwa1-rowtxt = 'Cereals'.
  93.   grvalwa1-val1 = 6000.
  94.   grvalwa1-val2 = 7000.
  95.   APPEND grvalwa1 TO grval1.
  96.   col1_wa-coltxt = '2005'.
  97.   APPEND col1_wa TO col1_texts.
  98.   col1_wa-coltxt = '2006'.
  99.   APPEND col1_wa TO col1_texts.
  100. *Function module to display graph (Graph 1)
  101.   CALL FUNCTION 'GFW_PRES_SHOW_MULT'
  102.     EXPORTING
  103.       parent            = cont1
  104.       presentation_type = gfw_prestype_lines
  105.       show              = gfw_false
  106.     TABLES
  107.       values            = grval1
  108.       column_texts      = col1_texts
  109.     EXCEPTIONS
  110.       error_occurred    = 1.
  111. *Graphic 2 display
  112.   REFRESH : grval2,col2_texts.
  113.   grvalwa2-rowtxt = 'Wheat'.
  114.   grvalwa2-val1 = 3000.
  115.   grvalwa2-val2 = 5500.
  116.   APPEND grvalwa2 TO grval2.
  117.   grvalwa2-rowtxt = 'Corn'.
  118.   grvalwa2-val1 = 2700.
  119.   grvalwa2-val2 = 8000.
  120.   APPEND grvalwa2 TO grval2.
  121.   grvalwa2-rowtxt = 'Maize'.
  122.   grvalwa2-val1 = 3250.
  123.   grvalwa2-val2 = 5000.
  124.   APPEND grvalwa2 TO grval2.
  125.   grvalwa2-rowtxt = 'Barley'.
  126.   grvalwa2-val1 = 6500.
  127.   grvalwa2-val2 = 9000.
  128.   APPEND grvalwa2 TO grval2.
  129.   col2_wa-coltxt = '2005'.
  130.   APPEND col2_wa TO col2_texts.
  131.   col2_wa-coltxt = '2006'.
  132.   APPEND col2_wa TO col2_texts.
  133. *Function module to display Graph 2
  134.   CALL FUNCTION 'GFW_PRES_SHOW_MULT'
  135.     EXPORTING
  136.       parent            = cont2
  137.       presentation_type = gfw_prestype_lines
  138.       show              = gfw_true
  139.     TABLES
  140.       values            = grval2
  141.       column_texts      = col2_texts
  142.     EXCEPTIONS
  143.       error_occurred    = 1.
  144. ENDMODULE.                 " PBO_0600  OUTPUT
  145. *PAI module : Based on user input,action is performed
  146. *EXIT called to leave program when user clicks it
  147. *&----------------------------------------------------------------*
  148. *&      Module  PAI_0600  INPUT
  149. *&----------------------------------------------------------------*
  150. MODULE pai_0600 INPUT.
  151.   ok_code = sy-ucomm.
  152.   IF ok_code EQ 'EXIT'.
  153.     LEAVE PROGRAM.
  154.   ENDIF.
  155. ENDMODULE.                 " PAI_0600  INPUT
复制代码

2、新建标准屏幕600
格式->绘制container显示区域,并命名为‘CONTAINER’。
程序流:
  1. PROCESS BEFORE OUTPUT.
  2. * MODULE STATUS_0600.
  3.   MODULE pbo_0600.

  4. PROCESS AFTER INPUT.
  5.   MODULE pai_0600.
  6. * MODULE USER_COMMAND_0600.
复制代码

3、程序执行效果:
Graphs.jpg
PS:ABAP图表DEMO事例T-CODE: GRAL(SAP 图形的演示报告)
系统图形程序DEMO程序名:
  • GFW_DEMO_PRES
  • GFW_DEMO_PRES1
  • DEMO_GFW_PRES_SHOW
  • DEMO_GFW_PRES_SHOW_MULT
  • GFW_DEMO_HIER1
  • GFW_DEMO_HIER2
  • GFW_DEMO_HIER3
回复

使用道具 举报

CK_Rocky
谢谢分享,nice
回复 支持 反对

使用道具 举报

快速回帖

本版积分规则
您需要登录后才可以回帖 登录 | 注册有礼

快速回复 返回顶部 返回列表