使用Docking Container展示alv
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
目的:
有时我们需要把container 放在任意角落,并可调整大小,例如,alv和选择屏幕都放在相同的屏幕上,为了实现这样的目的我们就需要用docking container
介绍:
我们都知道SAP Container是个control,包含一些控件,例如,SAP Tree Control, SAP Picture Control, SAP Text edit Control, SAP Splitter Control等等,他集中地逻辑管理这些控件,并提供一个物理空间用于展示他们。
所有的控件都依赖于一个container,因为这些container都是他们控制,你能嵌套他们,下面列举了5种SAP Containers:
1、SAP Custom Container
The SAP Custom Container allows you to display controls in an area defined on a normal screen
using the Screen Painter.
Class: CL_GUI_CUSTOM_CONTAINER
2、SAP Dialog Box Container
The SAP Dialog Box container allows you to display controls in an amodal dialog box or
fullscreen.
Class: CL_GUI_DIALOGBOX_CONTAINER
3、SAP Docking Container
The SAP Docking Container allows you to attach a control to any of the four edges of a screen as
a resizable screen area. You can also detach it so that it becomes an independent amodal
dialog box.
Class: CL_GUI_DOCKING_CONTAINER
4、SAP Splitter Container
The SAP Splitter Container allows you to display more than one control in a given area by
dividing it into cells.
Class: CL_GUI_SPLITTER_CONTAINER
5、SAP Easy Splitter Container
The SAP Easy Splitter Container allows you to divide an area into two cells with a control in each. The cells are separated by a moveable splitter bar.
Class: CL_GUI_EASY_SPLITTER_CONTAINER
程序代码:
1.TABLES: mara.
2.*---------------------------------------------------------------------*
3.* W O R K A R E A S *
4.*---------------------------------------------------------------------*
5.DATA:
6.* Material Data
7. BEGIN OF wa_mara,
8. matnr TYPE mara-matnr, " Material No.
9. mtart TYPE mara-mtart, " Material Type
10. bismt TYPE mara-bismt, " Old material No.
11. matkl TYPE mara-matkl, " Material group
12. meins TYPE mara-meins, " Base Unit of Measure
13. brgew TYPE mara-brgew, " Gross Weight
14. ntgew TYPE mara-ntgew, " Net Weight
15. gewei TYPE mara-gewei, " Weight Unit
16. END OF wa_mara,
17.* Field Catalog
18.wa_fieldcat TYPE lvc_s_fcat.
19.*---------------------------------------------------------------------*
20.* I N T E R N A L T A B L E S *
21.*---------------------------------------------------------------------*
22.DATA:
23.* For Material Data
24. t_mara LIKE STANDARD TABLE OF wa_mara,
25.* For Field Catalog
26. t_fieldcat TYPE lvc_t_fcat.
27.
28.*---------------------------------------------------------------------*
29.* W O R K V A R I A B L E S *
30.*---------------------------------------------------------------------*
31.DATA:
32.* User Command
33. ok_code TYPE sy-ucomm,
34.* Reference Variable for Docking Container
35. r_dock_container TYPE REF TO cl_gui_docking_container,
36.* Reference Variable for alv grid
37. r_grid TYPE REF TO cl_gui_alv_grid.
38.*---------------------------------------------------------------------*
39.* S T A R T O F S E L E C T I O N *
40.*---------------------------------------------------------------------*
41.START-OF-SELECTION.
42.* To Display the Data
43. PERFORM display_output.
44.*&--------------------------------------------------------------------*
45.*& Form display_output *
46.*&--------------------------------------------------------------------*
47.* To Call the screen & display the output *
48.*---------------------------------------------------------------------*
49.* There are no interface parameters to be passed to this subroutine.*
50.*---------------------------------------------------------------------*
51.FORM display_output .
52.* To fill the Field Catalog
53. PERFORM fill_fieldcat USING :
54. 'MATNR' 'T_MARA' 'Material No.',
55. 'MTART' 'T_MARA' 'Material Type',
56. 'BISMT' 'T_MARA' 'Old Material No.',
57. 'MATKL' 'T_MARA' 'Material Group',
58. 'MEINS' 'T_MARA' 'Base Unit of Measure',
59. 'BRGEW' 'T_MARA' 'Gross Weight',
60. 'NTGEW' 'T_MARA' 'Net Weight',
61. 'GEWEI' 'T_MARA' 'Weight Unit'.
62. CALL SCREEN 500.
63.ENDFORM. " Display_output
64.*&--------------------------------------------------------------*
65.*& Form FILL_FIELDCAT *
66.*&--------------------------------------------------------------*
67.* To Fill the Field Catalog *
68.*---------------------------------------------------------------*
69.* Three Parameters are passed *
70.* pv_field TYPE any for Field *
71.* pv_tabname TYPE any for Table Name *
72.* pv_coltext TYPE any for Header Text *
73.*---------------------------------------------------------------*
74.FORM fill_fieldcat USING pv_field TYPE any
75. pv_tabname TYPE any
76. pv_coltext TYPE any .
77.
78. wa_fieldcat-fieldname = pv_field.
79. wa_fieldcat-tabname = pv_tabname.
80. wa_fieldcat-coltext = pv_coltext.
81. APPEND wa_fieldcat TO t_fieldcat.
82. CLEAR wa_fieldcat.
83.ENDFORM. " FILL_FIELDCAT
84.*CREATE the screen 0500.
85.*flow logic for screen 500.
86.*&---------------------------------------------------------------------*
87.*& Module STATUS_0500 OUTPUT *
88.*&---------------------------------------------------------------------*
89.* To Set GUI Status & Title *
90.*----------------------------------------------------------------------*
91.MODULE status_0500 OUTPUT.
92. SET PF-STATUS 'STATUS'.
93. SET TITLEBAR 'TITLE'.
94.ENDMODULE. " STATUS_0500 OUTPUT
95.*&---------------------------------------------------------------------*
96.*& Module CREATE_OBJECTS OUTPUT *
97.*&---------------------------------------------------------------------*
98.* To Call the Docking Container & Display Method *
99.*----------------------------------------------------------------------* 100.M ODULE create_objects OUTPUT.
101.* Create a Docking container and dock the control at right side of screen 102. CHECK r_dock_container IS INITIAL.
103. CREATE OBJECT r_dock_container
104. EXPORTING
105. side = cl_gui_docking_container=>dock_at_right 106. extension = 780
107. caption = 'Materials'
108. EXCEPTIONS
109. cntl_error = 1
110. cntl_system_error = 2
111. create_error = 3
112. lifetime_error = 4
113. lifetime_dynpro_dynpro_link = 5
114. OTHERS = 6.
115. IF sy-subrc <> 0.
116. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno 117. WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. 118. ENDIF. " IF sy-subrc <> 0. 119.* To Create the Grid Instance
120. CREATE OBJECT r_grid
121. EXPORTING
122. i_parent = r_dock_container
123. EXCEPTIONS
124. error_cntl_create = 1
125. error_cntl_init = 2
126. error_cntl_link = 3
127. error_dp_create = 4
128. OTHERS = 5.
129. IF sy-subrc <> 0.
130. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno 131. WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. 132. ENDIF. " IF sy-subrc <> 0. 133.* Formatted Output Table is Sent to Control
134. CALL METHOD r_grid->set_table_for_first_display
135. CHANGING
136. it_outtab = t_mara
137. it_fieldcatalog = t_fieldcat
138.* it_sort =
139.* it_filter =
140. EXCEPTIONS
141. invalid_parameter_combination = 1
142. program_error = 2
143. too_many_lines = 3
144. OTHERS = 4
145. .
146. IF sy-subrc <> 0.
147. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
148. WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
149. ENDIF. " IF sy-subrc <> 0.
150.E NDMODULE. " CREATE_OBJECTS OUTPUT
151.*&---------------------------------------------------------------------* 152.*& Module USER_COMMAND_0500 INPUT * 153.*&---------------------------------------------------------------------* 154.* To Fetch the Material Data & Refresh Table after get User Command* 155.*----------------------------------------------------------------------* 156.M ODULE user_command_0500 INPUT.
157. CASE ok_code.
158. WHEN 'EXECUTE'.
159. SELECT matnr " material no.
160. mtart " material type
161. bismt " old material no.
162. matkl " material group
163. meins " base unit of measure
164. brgew " gross weight
165. ntgew " net weight
166. gewei " weight unit
167. FROM mara
168. INTO TABLE t_mara
169. WHERE mtart = mara-mtart.
170. IF sy-subrc <> 0.
171. ENDIF. " IF sy-subrc EQ 0.
172. CALL METHOD r_grid->refresh_table_display.
173. WHEN 'BACK' OR 'CANCEL' OR 'EXIT'.
174. LEAVE TO SCREEN 0.
175. ENDCASE. " CASE ok_code.
176.E NDMODULE. " USER_COMMAND_0500 INPUT
复制代码
ps:
1、定义按钮
2、设计屏幕
程序执行效果:。