二维码

[ooalv] 使用OOPs编程实现一个屏幕展现多个alv

Twilight发表于 2014-09-03 15:57zzxbat007 最后回复于 2017-02-09 11:02 [复制链接] 3176 7

1、SE51:Create  screen 9010
2、画一个Custom container,命名:‘CCONTAINER’
3、逻辑流
  1. PROCESS BEFORE OUTPUT.
  2.   MODULE status_9010.
  3. *
  4. PROCESS AFTER INPUT.
  5.   MODULE user_command_9010.
  6.   MODULE exit.
复制代码

4、程序代码:
  1. *Declaration
  2. DATA: Splitter_1     TYPE REF TO cl_gui_splitter_container,
  3.              Splitter_2     TYPE REF TO cl_gui_splitter_container,
  4.              Container     TYPE REF TO cl_gui_custom_container,
  5.              Container_1 TYPE REF TO cl_gui_container,
  6.              Container_2 TYPE REF TO cl_gui_container,
  7.              Container_3 TYPE REF TO cl_gui_container,
  8.              Grid1            TYPE REF TO cl_gui_ALV_grid,
  9.              Grid2            TYPE REF TO cl_gui_alv_grid,
  10.              Grid3            TYPE REF TO cl_gui_alv_grid.
  11. DATA: Gt_sflight_1 TYPE TABLE OF sflight,
  12.              Gt_sflight_2 TYPE TABLE OF sflight,
  13.              Gt_sflight_3 TYPE TABLE OF sflight,
  14.              G_container TYPE scrfname VALUE 'CCONTAINER'.
  15. DATA: ok_code TYPE sy-ucomm.
  16. * fetching data from table for different internal tables
  17. SELECT * FROM sflight INTO TABLE gt_sflight_1. "Itab 1
  18. SELECT * FROM sflight INTO TABLE gt_sflight_2 UP TO 3 ROWS. "Itab 2
  19. SELECT * FROM sflight INTO TABLE gt_sflight_3 UP TO 2 ROWS. "Itab 3
  20. CALL SCREEN 9010.
  21. *&---------------------------------------------------------------------*
  22. *& Module STATUS_9010 OUTPUT                                    *
  23. *&---------------------------------------------------------------------*
  24. MODULE status_9010 OUTPUT.
  25. SET PF-STATUS 'TEST'.
  26. *creating object reference for container
  27. CREATE OBJECT container
  28. EXPORTING
  29.    container_name = 'CCONTAINER'. "Pass name of container created in Screen no 9010
  30. *splitting the main container into 1 row & 2 coloum
  31. CREATE OBJECT splitter_1
  32. EXPORTING
  33.    Parent     = container
  34.    Rows      = 1
  35.    Columns = 2.
  36. *getting the reference for the splited container (row 1 & col 1 container)
  37. CALL METHOD splitter_1->get_container
  38. EXPORTING
  39.    Row      = 1
  40.    Column = 1
  41. RECEIVING
  42.    Container = container_1.
  43. *getting the reference for the splited container (row 1 & col 2 container)
  44. CALL METHOD splitter_1->get_container
  45. EXPORTING
  46.    Row      = 1
  47.    Column = 2
  48. RECEIVING
  49.    Container = container_2.
  50. *splitting the 2nd coloum container in to 2 rows & 1 coloum
  51. CREATE OBJECT splitter_2
  52. EXPORTING
  53.    Parent     = container_2
  54.    Rows      = 2
  55.    Columns = 1.
  56. *getting the reference for the splited container2 (row 1 & col 2 container)
  57. CALL METHOD splitter_2->get_container
  58. EXPORTING
  59.    Row      = 1
  60.    Column = 1
  61. RECEIVING
  62.    Container = container_2.
  63. *getting the reference for the splited container2 (row 2 & col 1 container)
  64. CALL METHOD splitter_2->get_container
  65. EXPORTING
  66.    Row      = 2
  67.    Column = 1
  68. RECEIVING
  69.    Container = container_3.
  70. *populating first internal table to the container
  71. CREATE OBJECT container
  72. EXPORTING
  73.    container_name = g_container.
  74. CREATE OBJECT grid1
  75. EXPORTING
  76.    i_parent = container_1.
  77. CALL METHOD grid1->set_table_for_first_display
  78. EXPORTING
  79.    i_structure_name = 'SFLIGHT'
  80. CHANGING
  81.     it_outtab = gt_sflight_1.
  82. *populating second internal table
  83. CREATE OBJECT container
  84. EXPORTING
  85.    container_name = g_container.
  86. CREATE OBJECT grid2
  87. EXPORTING
  88.    i_parent = container_2.
  89. CALL METHOD grid2->set_table_for_first_display
  90. EXPORTING
  91.    i_structure_name = 'SFLIGHT'
  92. CHANGING
  93.    it_outtab = gt_sflight_2.
  94. *populating third internal table
  95. CREATE OBJECT container
  96. EXPORTING
  97.    container_name = g_container.
  98. CREATE OBJECT grid3
  99. EXPORTING
  100.     i_parent = container_3.
  101. CALL METHOD grid3->set_table_for_first_display
  102. EXPORTING
  103.    i_structure_name = 'SFLIGHT'
  104. CHANGING
  105.    it_outtab = gt_sflight_3.
  106. ENDMODULE. "STATUS_9010 OUTPUT
  107. *&---------------------------------------------------------------------*
  108. *& Module EXIT INPUT                                                        *
  109. *&---------------------------------------------------------------------*
  110. MODULE exit INPUT.
  111. *free the container memory when exit
  112. CALL METHOD container->free.
  113. LEAVE PROGRAM.
  114. ENDMODULE.  "EXIT INPUT
  115. *&---------------------------------------------------------------------*
  116. *& Module USER_COMMAND_9010 INPUT                      *
  117. *&---------------------------------------------------------------------*
  118. MODULE user_command_9010 INPUT.
  119. CALL METHOD cl_gui_cfw=>dispatch.
  120. CASE ok_code.
  121.    WHEN 'BACK'.
  122.         LEAVE SCREEN.
  123.    WHEN 'CANCEL'.
  124.         LEAVE PROGRAM.
  125.    WHEN 'EXIT'.
  126.        LEAVE SCREEN.
  127. ENDCASE.
  128. ENDMODULE.  "USER_COMMAND_9010 INPUT
复制代码

程序执行效果:
more than one Internal Table in ALV.png
PS:这里先将屏幕分成左右两块,再将右侧分成上下两块;
     需要创建新屏幕,不能使用报表默认1000屏幕
SAP系统中提供了一个DEMO:RSDEMO_SPLITTER_CONTROL
回复

使用道具 举报

qshiou
楼主太厉害了, 出本书吧
回复 支持 反对

使用道具 举报

Twilight
qshiou 发表于 2015-7-1 11:52
楼主太厉害了, 出本书吧

过奖了,我也是小白,通过写帖子在不断的整理知识点,提高自己,惠及他人共同成长,欢迎常来
回复 支持 反对

使用道具 举报

qshiou
大神,有时间的时候能不能发下关于fm 中事件发生机理的帖子,  对事件触发的原理不太懂,非常感谢
回复 支持 反对

使用道具 举报

CK_Rocky
LZ好棒,很少用分屏的,以后有机会可以试试,O(∩_∩)O~
回复 支持 反对

使用道具 举报

愤怒的阿木木
支持楼主,支持SAP顾问圈,以后经常来!
回复 支持 反对

使用道具 举报

hes

楼主NB了,谢谢分享!!!!
回复

使用道具 举报

zzxbat007
楼主NB了,谢谢分享!!!!
SAP Business One 凭借单一系统 优化你的整个业务  www.iwilley.com
回复

使用道具 举报

快速回帖

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

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