Select Option Modulepool SAP ABAP
Select Option Modulepool SAP ABAP
My favourite interview question 'Can you define select option in module pool?'... Why not? ....
How?...
The key for having select-option in module pool is loading selection-screen in module pool screen.
We know that defining a select option in selection screen is just a matter of line. But do you know
that selection screen can be defined as subscreen and that can be loaded into subscreen area
module pool program. Bingo!! You got the solution. Still confused follow below steps
Step 1: Create a report with following code.
REPORT zreport .
TABLES : ekko , ekpo .
SELECTION-SCREEN BEGIN OF SCREEN 300 AS SUBSCREEN.
PARAMETERS : p_bukrs TYPE ekko-bukrs OBLIGATORY DEFAULT '1000'.
SELECT-OPTIONS : s_ebeln FOR ekko-ebeln ,
s_ebelp FOR ekpo-ebelp .
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' .
ENDMODULE. " status_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module user_command_0100 INPUT
*&---------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
IF sy-ucomm = 'BACK' OR sy-ucomm = 'EXIT' .
LEAVE TO SCREEN 0 .
ENDIF.
ENDMODULE. " user_command_0100 INPUT
Step 2 : Define screen 100 with subcreen area SUB_1 as shown in below screen shot.
Also define PF status and title bar with names 'ZPF01' and 'ZTITLE01' respectively. This is not shown
in any screen shot.
Step 3 : Put code in PBO and PA1 of screen as shown in below screen shot.
Activate all objects and execute the report you should get following module pool screen with selectoptions.
MZDEMO_SUBSCREEN200
*&---------------------------------------------------------------------*
*Selection Screen 200
SELECTION-SCREEN BEGIN OF SCREEN 200 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK blck1 WITH FRAME TITLE text-000.
SELECT-OPTIONS : so_kunnr FOR v_kunnr.
SELECTION-SCREEN END OF BLOCK blck1.
SELECTION-SCREEN END OF SCREEN 200.
Save the Include and Activate it.
STEP 5:
Add the Following code in flow logic editor for Screen 100.
process before output.
module status_0100.
call subscreen sub1 including v_prog v_subdyn1.
process after input.
module user_command_0100.