Sie sind auf Seite 1von 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

*&---------------------------------------------------------------------*

text

*----------------------------------------------------------------------* MODULE STATUS_0100 OUTPUT. * SET PF-STATUS 'xxxxxxxx'. * SET TITLEBAR 'xxx'. ENDMODULE. " STATUS_0100 OUTPUT

*&---------------------------------------------------------------------* *& Module USER_COMMAND_0100 INPUT

*&---------------------------------------------------------------------* * text

*----------------------------------------------------------------------* MODULE USER_COMMAND_0100 INPUT. ENDMODULE. Define screen 100 " USER_COMMAND_0100 INPUT with subcreen area SEL as shown in below .

Define PF status and title bar with any names. This is not shown in screen shot. Put code in PBO and PAI of screen as shown in below screen shot.

Call subscreen sel including sy-repid 400.

Activate all objects and execute the report you should get following module pool screen with select-options.

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

And now use code like this case ok_code. when 'BACK'. call SCREEN '100'. endcase. Where BACK is Function Code of buttons property in screen painter.

PBO Module: PROCESS BEFORE OUTPUT. MODULE status_0200. LOOP AT izqmrr WITH CONTROL tc. ENDLOOP. PBI Module: PROCESS AFTER INPUT. LOOP. ENDLOOP. MODULE user_command_0200. GUI Title: set TITLEBAR 'Y_DURGESH321_TITLE'. Where Y_DURGESH321_TITLE is the name of the GUI Title.

GUI Status: set pf-status 'STATUS' excluding 'CANCEL'. Where 'STATUS' is name of the GUI Status. If we add excluding 'CANCEL'. Then Cancel button will not be added. If we have to exclude multiple icon then following procedure will be added. 1. Create an internal table. DATA : BEGIN OF i_stat OCCURS 10, fcode(6) TYPE c. DATA : END OF i_stat. 2. Add name of icon in table. i_stat-fcode = 'SAVE'. APPEND i_stat. i_stat-fcode = 'CANCEL'. APPEND i_stat. 3. Now set PF-status excluding i_stat. SET PF-STATUS 'STATUS' EXCLUDING i_stat. Now Bothe SAVE and CANCEL icon will be disabled simultaneously. Automatically Increase Lines of Table In Entry Screen : data : l_ilines type i. CONTROLS : tc type tableview using screen '0200'. describe table lt_results lines l_ilines. tc-lines = l_ilines + 18. Saving Data in Table: Steps for saving data are as follows

This is the flow logic of data entry screen i.e. of the screen from which we have to save the data. 1. At PROCESS AFTER INPUT writes following lines A. LOOP AT i_emp. MODULE crtrecord. ENDLOOP. Where MODULE crtrecord is created manually for transferring data from screen field to program field i.e. data entry form to internal table. There are following code of line written in MODULE crtrecord for data transfer. MODULE crtrecord INPUT. MODIFY i_emp INDEX tc-current_line.

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

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

Das könnte Ihnen auch gefallen