Sunteți pe pagina 1din 3

Selection Screen and ALV Grid Report on One Screen

In this blog I am going to show you how you can put both selection screen and ALV Grid on same screen so that user can see both their input and report together.

Concept is based in fact that you can put selection-screen on a module pool subscreen area. For more information read blog SELECT-OPTION in module pool. Based on this idea define a screen with subscreen on the top where a selection screen can be loaded, below that define a customer container where a ALV Grid can be displayed. In user-command of screen reterive and process data and refresh that in ALV Grid. Ok, lets start with programming. 1. Create a report. 2. Define screen 100 with subscreen area SUB200 on top and a custom container with name CUSTOM below it. 3. Put below code in screen Flow logic tab

PROCESS BEFORE OUTPUT. MODULE status_0100. CALL SUBSCREEN sub200 INCLUDING sy-repid '0300' . PROCESS AFTER INPUT. CALL SUBSCREEN sub200. MODULE user_command_0100.
4. Define GUI status ZPF01 with function code BACK, CANC, EXIT and OK.

5. Create a GUI Tile ZTITLE01. Then copy-paste following code in report.

REPORT zpwreport. TABLES : mara . DATA : i_mara TYPE TABLE OF mara , ob_custom TYPE REF TO cl_gui_custom_container ,

ob_grid

TYPE REF TO cl_gui_alv_grid

SELECTION-SCREEN BEGIN OF SCREEN 300 AS SUBSCREEN . SELECT-OPTIONS : s_matnr FOR mara-matnr. SELECTION-SCREEN END OF SCREEN 300. START-OF-SELECTION . CALL SCREEN 100 . *&---------------------------------------------------------------------* *& Module status_0100 OUTPUT *&---------------------------------------------------------------------* MODULE status_0100 OUTPUT. SET PF-STATUS 'ZPF01' . SET TITLEBAR 'ZTITLE01' . PERFORM create_grid . ENDMODULE. " status_0100 OUTPUT *&---------------------------------------------------------------------* *& Module user_command_0100 INPUT *&---------------------------------------------------------------------* MODULE user_command_0100 INPUT. CASE sy-ucomm. WHEN 'BACK' OR 'CANC' OR 'EXIT'. LEAVE TO SCREEN 0 . WHEN 'OK'. SELECT * INTO TABLE i_mara FROM mara WHERE matnr IN s_matnr . WHEN OTHERS. ENDCASE. ENDMODULE. " user_command_0100 INPUT *&---------------------------------------------------------------------* *& Form create_grid *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* FORM create_grid . IF ob_custom IS INITIAL . CREATE OBJECT ob_custom EXPORTING container_name = 'CUSTOM'. CREATE OBJECT ob_grid EXPORTING i_parent = ob_custom. CALL METHOD ob_grid->set_table_for_first_display EXPORTING i_structure_name = 'MARA' CHANGING it_outtab = i_mara.

ELSE. CALL METHOD ob_grid->refresh_table_display. ENDIF.

S-ar putea să vă placă și