在屏幕上创建两个文本元素空件、一个推出按钮控件、一个定制控制按钮
代码所示:
*&---------------------------------------------------------------------* *& Report YTEST028 *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT ytest028. DATA: ok_code TYPE sy-ucomm, save_ok TYPE sy-ucomm. DATA WA_SPFLI TYPE TABLE OF SPFLI ."WITH HEADER LINE. SELECT * INTO TABLE WA_SPFLI FROM SPFLI. DATA:WA_CONTAINER TYPE SCRFNAME VALUE 'ALVDATA', ALV_GRID TYPE REF TO CL_GUI_ALV_GRID, WA_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER. CALL SCREEN 300. *&---------------------------------------------------------------------* *& Module STATUS_0300 OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE status_0300 OUTPUT. SET PF-STATUS 'STATUS1'. * SET TITLEBAR 'xxx'. *如果窗口还没有创建ALV对象则它 IF WA_CUSTOM_CONTAINER IS INITIAL. CREATE OBJECT WA_CUSTOM_CONTAINER EXPORTING CONTAINER_NAME = WA_CONTAINER. CREATE OBJECT ALV_GRID EXPORTING I_PARENT = WA_CUSTOM_CONTAINER. CALL METHOD ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY EXPORTING I_STRUCTURE_NAME = 'SPFLI' CHANGING IT_OUTTAB = WA_SPFLI. ENDIF. ENDMODULE. " STATUS_0300 OUTPUT *&---------------------------------------------------------------------* *& Module EXIT INPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE exit INPUT. save_ok = ok_code. CLEAR ok_code. CASE save_ok. WHEN 'EXIT'. LEAVE PROGRAM. ENDCASE. ENDMODULE. " EXIT INPUT *&---------------------------------------------------------------------* *& Module USER_COMMAND_0300 INPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* module USER_COMMAND_0300 input. endmodule. " USER_COMMAND_0300 INPUT
运行结果: