You are on page 1of 7

A Module Pool program is a Dialog Program (a number of screens that are linked together and use the PBO

and PAI events). An Executable programis a Report which generally has a selection screen and a output screen (these types of programs use the Start of Selection, End of Selection, etc events). Also a Executable program can be run via SE38/SE80, but a module pool program must be run from a transaction code as you need to specify the starting screen. So when you are creating the transaction code, you have to first know what type of program you wrote and choose the appropriate type. If you wrote a screen based dialog program, then choose the 'Dialog program' radio button, and if created a report program, then select the second one for an executable report. Also you can see the below examples... Go to se38 and give demo*dynpro* and press F4. YOu will get a list of demo module pool programs. One more T-Code is ABAPDOCU. YOu can find more examples there. See the prgrams: DEMO_DYNPRO_TABLE_CONTROL_1 Table Control with LOOP Statement DEMO_DYNPRO_TABLE_CONTROL_2 Table Control with LOOP AT ITAB

Simple way of defining Select-options in Module Pool Programming
By Anurag Shukla, JK Lakshmi Cement Ltd Defining select-options in selection-screen is easy task but in module pool it is slightly tricky. Selection-screen can be defined as subscreen and can be applied in the subscreen area of module pool program. Create report with following code. REPORT TABLES : vbrk , vbrp . SELECTION-SCREEN BEGIN OF SCREEN 400 AS SUBSCREEN. PARAMETERS : p_vkorg TYPE vbrk-vkorg OBLIGATORY DEFAULT '1000'. SELECT-OPTIONS : s_vbeln FOR vbrk-vbeln, s_posnr FOR vbrp-posnr. SELECTION-SCREEN END OF SCREEN 400 . START-OF-SELECTION . zselectoptions.

CALL SCREEN 100 . *&---------------------------------------------------------------------* *& Module STATUS_0100 OUTPUT


Define PF status and title bar with any names. Put code in PBO and PAI of screen as shown in below screen shot. * SET TITLEBAR 'xxx'. . * SET PF-STATUS 'xxxxxxxx'. Call subscreen sel including sy-repid ‘400’. " STATUS_0100 OUTPUT *&---------------------------------------------------------------------* *& Module USER_COMMAND_0100 INPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE USER_COMMAND_0100 INPUT. Define screen 100 " USER_COMMAND_0100 INPUT with subcreen area SEL as shown in below . ENDMODULE. ENDMODULE. This is not shown in screen shot.* text *----------------------------------------------------------------------* MODULE STATUS_0100 OUTPUT.

For use of buttons in screen painter. 4. 2. 3. Design screen as per requirement. Module Pool Steps: 1. Note: 1. Define data data : ok_code type sy-ucomm. This ok_code must be included in element List (i. Module Pool Steps 2. Module Pool Module Pool is basically used for the Data entry programming. Now open screen painter by clicking Layout.e. For use of table control where tc is the name of table of screen painter. Now Create Screen by right clicking program name and create screen. Code For Copy & Delete Buttons 1. 2.Activate all objects and execute the report you should get following module pool screen with select-options. Basic steps of module pool is define as follows:1. Define data CONTROLS : tc type tableview using screen '0200'. Create program using transaction code SE80. . all screen fields must be included in the Element List). Program Example 3. 3.

call SCREEN '100'. PBI Module: PROCESS AFTER INPUT. Where BACK is Function Code of button’s property in screen painter. MODULE user_command_0200. LOOP AT izqmrr WITH CONTROL tc. PBO Module: PROCESS BEFORE OUTPUT. GUI Title: set TITLEBAR 'Y_DURGESH321_TITLE'. ENDLOOP. Where Y_DURGESH321_TITLE is the name of the GUI Title. MODULE status_0200. when 'BACK'. ENDLOOP. . LOOP. endcase.And now use code like this – case ok_code.

ENDLOOP. Where 'STATUS' is name of the GUI Status. 3. Add name of icon in table. Now Bothe SAVE and CANCEL icon will be disabled simultaneously. There are following code of line written in MODULE crtrecord for data transfer. If we add excluding 'CANCEL'. APPEND i_stat.e. Now set PF-status excluding i_stat. 2. i_stat-fcode = 'CANCEL'. tc-lines = l_ilines + 18. Create an internal table. Where MODULE crtrecord is created manually for transferring data from screen field to program field i. data entry form to internal table. At PROCESS AFTER INPUT writes following lines – A. describe table lt_results lines l_ilines. MODIFY i_emp INDEX tc-current_line. MODULE crtrecord. of the screen from which we have to save the data. fcode(6) TYPE c. i_stat-fcode = 'SAVE'. Automatically Increase Lines of Table In Entry Screen : data : l_ilines type i. If we have to exclude multiple icon then following procedure will be added.e. DATA : END OF i_stat. APPEND i_stat. LOOP AT i_emp. 1. SET PF-STATUS 'STATUS' EXCLUDING i_stat.GUI Status: set pf-status 'STATUS' excluding 'CANCEL'. MODULE crtrecord INPUT. Saving Data in Table: Steps for saving data are as follows – This is the flow logic of data entry screen i. . 1. CONTROLS : tc type tableview using screen '0200'. Then Cancel button will not be added. DATA : BEGIN OF i_stat OCCURS 10.

. Program Example: PROCESS BEFORE OUTPUT. 2. MESSAGE 'Enter EMP_Name' TYPE 'E'. ENDIF. MESSAGE 'Enter EMP_ID' TYPE 'E'. ENDLOOP. WHEN 'SAVE'. MODULE crtrec. IF sy-subrc = 0. ENDLOOP. MODULE user_command_0100 MODULE user_command_0100 INPUT. EXIT. PROCESS AFTER INPUT. MODIFY ymod FROM TABLE i_emp. i_emp-empname. ENDCASE. ENDLOOP. MODULE STATUS_0100. a. At PROCESS BEFORE OUTPUT writes following lines – LOOP AT i_emp WITH CONTROL tc. ELSEIF i_emp-empname IS INITIAL. CASE ok_code.IF sy-subrc NE 0. ENDMODULE. b. MODULE validate ON CHAIN-REQUEST IF i_emp-empid IS INITIAL. CHAIN. MODULE user_command_0100. ENDIF. LOOP AT i_emp WITH CONTROL tc. APPEND i_emp. MESSAGE 'Record Has Been Updated' TYPE 'S'. ENDIF. SELECT SINGLE empid FROM ymod INTO i_emp-empid WHERE empid = i_emp-empid. 2. ENDCHAIN. This is the code written basically for the saving the data in the table. B. LOOP at i_emp. MODULE validate ON CHAIN-REQUEST. ENDMODULE. EXIT. MODULE STATUS_0100. FIELD : i_emp-empid.

MODULE crtrec. FIELD i_emp-mark MODULE modify ON REQUEST. APPEND i_emp. LOOP AT i_emp. in PAI as given below – PROCESS AFTER INPUT. DELETE i_emp WHERE mark = ''. ELSEIF ok_code = 'DEL'. d. MODIFY i_emp INDEX tc-current_line. c. MODULE user_command_0100. MODULE validation ON CHAIN-REQUEST. DATA: BEGIN OF i_emp OCCURS 0. DELETE i_emp WHERE mark = 'X'. i_emp-empname.. MODULE user_command_0100. MESSAGE 'EMP_ID Already Exist' TYPE 'E'. MODIFY ymod FROM TABLE i_emp.Now Create MODULE modify as follows – MODULE modify INPUT. b. ENDCHAIN. ELSEIF ok_code = 'COPY'. MODIFY i_emp INDEX tc-current_line TRANSPORTING mark. MODULE itablefill.Cearte button in form painter for copy and delete records. ENDIF c. ENDIF. Note: wa_results is workarea like internal table data: wa_results LIKE LINE OF i_emp. IF sy-subrc NE 0.====Filed For delition DATA: END OF i_emp. EXIT. FIELD : i_emp-empid.IF sy-subrc IS INITIAL. IF sy-subrc = 0.Add FIELD i_emp-mark MODULE modify ON REQUEST. ENDIF. ENDMODULE. READ TABLE i_emp WITH KEY mark = 'X' INTO wa_results. Code For Copy & Delete Buttons: a. . ENDLOOP. Add following lines in MODULE user_command_0100 of PAI Module as follows – IF ok_code = 'SAVE'. d. MODULE exit AT EXIT-COMMAND. e. INCLUDE STRUCTURE ymod. APPEND wa_results to i_emp. 3. ENDIF. CHAIN. DATA: mark.Decalre field MARK in internal table of type character. MODIFY ymod FROM TABLE i_emp.