Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ModulePool Programing

Former Member
0 Likes
698

Hi,

I'm new on Modulepool programing ,can anyone pls send the Modulepool sample programs.

regards,

soni

5 REPLIES 5
Read only

Former Member
0 Likes
594

Hi,

MODULE POOL PROGRAMMING:

-


  • This is also called as DIALOG PROGRAMMING.

  • User can make use of multiple screens in this type of programming.

  • These are type 'M' programs in SAP.

EVENTS IN DIALOG PROGRAMMING:

-


1. PROCESS BEFORE OUTPUT (PBO)

2. PROCESS AFTER INPUT (PAI)

3. PROCESS ON VALUE REQUEST (POVR)

4. PROCESS ON HELP REQUEST (POHR)

Navigations to create a simple MPP program:

-


SE80 -> Select Program from drop-down list -> Specify program name starting with SAPMZ or SAPMY -> Press Enter -> Click on Yes to create object -> Create Top Include File by clicking on Continue icon in pop-up screens -> Save under a package -> Assign a request number -> MPP program with specified name is created with Top include File.

To create screen, Right click on program name -> Select Create -> Screen -> Opens Screen Description page -> Enter short description for screen -> Select screen type as NORMAL -> Click on LAYOUT pushbutton from application toolbar -> Opens Screen Painter -> Drag and drop two input fields from toolbar -> Likewise, create two pushbuttons -> Double click on each component -> Opens Attributes box -> Specify attributes for each screen component -> For pushbutton, specify FCT code -> Save the screen -> Click on Flowlogic pushbutton from application toolbar -> Opens Flow logic editor to create event functionalities for screen components -> Decomment PAI module -> Double click on PAI module name -> Click on Yes to create PAI module object -> Opens PAI module -> Specify the following code within module-endmodule statements:

CASE SY-UCOMM.

WHEN 'DISPLAY'.

LEAVE TO LIST-PROCESSING.

WRITE 😕 IO1, IO2.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

-> Save.

Now double click on 'Includes' Folder (TOP INCLUDE FILE) -> Declare variables for input fields as follows:

DATA : IO1(10), IO2(10).

Save -> Activate.

Now To create Transaction Code, right click on Main Program Name -> Create -> Transaction -> Opens an interface -> Enter Tcode name starting with Z or Y -> Enter short description -> Continue -> Opens interface -> Enter Main program name and Screen number to be called first -> Save under a package -> Assign a request number.

Activate all the objects of MPP program by right clicking on Main program Name -> Click on Activate -> Raises 'Objects Activated' message.

To execute the MPP program, specify Tcode name in the Command Prompt area -> Press Enter.

Hope this helps u,

Regards,

Arunsri

Read only

Former Member
0 Likes
594

Hi,

MODULE POOL PROGRAMMING (MPP):

-


  • These are type M programs in SAP.

  • These programs cannot be executed directly.

  • Transaction Codes (Tcodes) are used to execute MPP programs.

  • Graphical Screen PAinter is the tool used to create GUI in MPP (SE51).

  • MPP programs are created using the transaction code SE80.

  • MPP programs should start with the naming convention SAPMZ or SAPMY.

EVENTS ASSOCIATED WITH SELECTION-SCREEN:

-


INITIALIZATION

AT SELECTION-SCREEN

START-OF-SELECTION

TOP-OF-PAGE

END-OF-PAGE

END-OF-SELECTION.

EVENTS ASSOCIATED WITH MPP:

-


1. PROCESS BEFORE OUTPUT (PBO) - Used to specify initial attributes for the screen.

2. PROCESS AFTER INPUT (PAI) - Used to specify

event functionalities for the components of the screen.

COMPONENTS OF MPP PROGRAM:

-


1. ATTRIBUTES - It holds description about the screen.

2. FLOW LOGIC - This is an editor for MPP programs to specify event functionality for the screen components.

3. ELEMENT LIST - This provides description about the components created in the screen.

TYPES OF SCREEN IN MPP:

-


1. NORMAL SCREEN - A screen which has maximizing, minimizing and closing options

is referred to as normal screen.

2. SUBSCREEN - A screen within a normal screen with either of above three options

is referred to as subscreen.

3. MODAL DIALOG BOX - A screen with only closing option which is used to provide

information to the end user is referred to as modal dialog box.

NAVIGATIONS TO CREATE A SIMPLE MPP PROGRAM:

-


SE80 -> Select Program from the dropdown list -> SPecify program name starting with SAPMZ or SAPMY (eg. SAPMYFIRSTMPP) -> Press Enter -> Click on Yes to Create object -> Opens another dialog box -> Click on Continue to create Top Include File for the program -> Opens another dialog box specifying TOP INCLUDE FILE name (MYFIRSTMPPTOP) -> Click on Continue -> Opens Program Attributes screen -> Enter short description -> The default program type is M -> Save under a package -> Assign Request number -> A folder with specified program name(SAPMYFIRSTMPP) is created with Top Include File.

To create a screen, right click on program name -> Create -> SCreen -> Opens dialog box

-> Specify Screen number (100) -> Continue -> Opens an interface -> Enter short description

-> Select Screen type as Normal -> Click on LAYOUT pushbutton from appn. toolbar

-> Opens Graphical Screen painter -> Drag and drop two input fields, two pushbuttons and

two text fields -> Double click on each component to specify attributes as follows:

INPUT FIELDS: IO1, IO2

FIRST PUSHBUTTON : PB1, PRINT, PRINT

SECOND PUSHBUTTON : PB2, EXIT, EXIT

TEXT FIELDS : LB1 (ENTER NAME), LB2 (ENTER CITY)

-> Save -> Click on Flowlogic Pushbutton from appn. toolbar -> Opens Flow Logic editor

with two events (PA1 and PBO).

To specify event functionalities for screen components,

decomment PAI Module name (USER_COMMAND_0100)

-> Double click on module name -> Click on Yes to create object -> Opens an interface

-> Select Program name from the list -> Continue -> Click on Yes to save the editor

-> Opens PAI module and specify following code:

CASE SY-UCOMM.

WHEN 'PRINT'.

LEAVE TO LIST-PROCESSING.

WRITE 😕 IO1, IO2.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

In TOP INCLUDE FILE, declare input fields as follows:

DATA : IO1(20), IO2(20).

Save -> Activate -> Right click on Program name -> Activate (to activate all inactive objects).

To execute MPP program, right click on program name -> Create -> Transaction

-> Opens an interface -> Specify Tcode starting with Z or Y (zfirstmpp) -> Enter short description -> Continue -> Specify Main program name (SAPMYFIRSTMPP) and initial Screen number (100) -> Save under a package -> Assign a request number -> Execute.

TOP INCLUDE FILE is an area to declare variables for the program, and the variables declared here becomes globally accessed.

SCREEN VALIDATION USING MPP:

-


SCREEN is a predefined structure used to make MPP screen validations dynamically. SCREEN has following components:

GROUP1

INVISIBLE

REQUIRED

INPUT

OUTPUT

INTENSIFIED

IF SCREEN-INVISIBLE = 0 - Sets the input field values as visible.

SCREEN-INVISIBLE = 1 - Sets the input field as password field.

SCREEN-REQUIRED = 0 - Not a mandatory field.

SCREEN-REQUIRED = 1 - Sets input field as mandatory one.

Eg. code to perform validation dynamically for a login screen:

-


1. Create an MPP program.

2. Create a Normal Screen like initial login screen.

3. Assign IO1, IO2 to group GR1, IO3 to GR2.

4. In Top Include file, declare variables.

5. In PBO, specify following code:

LOOP AT SCREEN.

IF SCREEN-GROUP1 = 'GR1'.

SCREEN-REQUIRED = '1'.

ENDIF.

IF SCREEN-GROUP1 = 'GR2'.

SCREEN-INVISIBLE = '1'.

ENDIF.

MODIFY SCREEN. * to update the changes made to the predefined structure.

ENDLOOP.

6. In PAI, specify following code:

CASE SY-UCOMM.

WHEN 'LOGIN'.

CALL TRANSACTION 'SE38'.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

7. Create a Tcode -> Activate all -> Execute.

INSERTING RECORDS FROM MPP SCREEN INTO DATABASE TABLE:

-


1. Create an MPP program.

2. In Top Include File, declare an internal table as follows:

DATA IT_KNA1 LIKE KNA1 OCCURS 0 WITH HEADER LINE.

-> Save -> Activate.

3. Create a screen -> In Screen Painter, click DICTIONARY/PROGRAM FIELDS (F6)

pushbutton from appn. toolbar -> Opens an interface

-> Specify internal table name -> Click on GET FROM PROGRAM pushbutton

-> Select required fields -> Continue -> Paste on Screen Painter

-> Create two pushbuttons (INSERT, EXIT) -> Save -> Flow logic.

4. In PAI, specify following code:

CASE SY-UCOMM.

WHEN 'INSERT'.

INSERT INTO KNA1 VALUES IT_KNA1.

IF SY-SUBRC = 0.

MESSAGE S000(ZMSG).

ELSE.

MESSAGE W001(ZMSG).

ENDIF.

WHEN 'EXIT'.

*LEAVE PROGRAM.

SET SCREEN 0.

ENDCASE.

5. Create a Tcode -> Activate all -> Execute.

LIST OF VALUES:

-


Adding dropdown facility to the input fields is called as LIST OF VALUES.

VRM is a predefined type group which has the following structure and internal table:

VRM_VALUE is a structure with the components KEY and TEXT.

VRM_VALUES is an internal table declared for the above structure without header line.

The above type group is used to fetch values from the internal table declared with user-defined records and insert into the input field in the screen.

'VRM_SET_VALUES' is a function module used to carry the records from the internal table and populate in the input field.

NAVIGATIONS TO CREATE DROPDOWN FACILITY FOR INPUT BOX:

-


1. Create MPP program.

2. Create a screen.

3. Add a input box -> Double click -> Specify name (IO1) -> Select LISTBOX from the dropdown list -> A dropdown facility is added for the input field in the screen.

4. Create two pushbuttons (PRINT, EXIT).

5. In Top Include File, specify following code:

TYPE-POOLS VRM.

DATA IO1(20).

DATA A TYPE I.

DATA ITAB TYPE VRM_VALUES. * To create an internal table of an existing type

DATA WA LIKE LINE OF ITAB. * To create a temporary structure of sameline type of internal table.

6. In PBO, specify following code:

IF A = 0.

WA-KEY = 'ABAP'.

WA-TEXT = 'ADVANCED PROGRAMMING'.

APPEND WA TO ITAB.

WA-KEY = 'BW'.

WA-TEXT = 'BUSINESS WAREHOUSING'.

APPEND WA TO ITAB.

WA-KEY = 'EP'.

WA-TEXT = 'ENTERPRISE PORTAL'.

APPEND WA TO ITAB.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

ID = 'IO1'

VALUES = ITAB.

A = 1.

ENDIF.

7. In PAI, specify following:

CASE SY-UCOMM.

WHEN 'PRINT'.

LEAVE TO LIST-PROCESSING.

WRITE 😕 IO1.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

8. Create a Tcode -> Activate all -> Execute.

CREATING TABSTRIPS IN MPP:

-


In a normal screen, we can add only maximum of 40 components.

To make a screen hold more than 40 components, we can use tabstrip controls.

NAVIGATIONS TO CREATE TABSTRIP CONTROL:

-


1. Create an MPP program.

2. Create a normal screen (100)

-> Add Tabstrip Control component from toolbar

-> By default, a tabstrip control is created with 2 tab buttons

-> Double click on tabstrip control

-> Specify name (TBSTR) in Attributes box

-> Click on First tab button

-> Add Subscreen Area from toolbar to first tab button

-> Double click on subscreen area

-> Specify name (SUB1)

-> Click on Second tab button

-> Repeat same process for adding subscreen area (SUB2)

-> Double click on First tab button

-> Specify attributes (TAB1,FIRST,TAB1)

-> Double click on Second tab button

-> Specify attributes (TAB2, SECOND, TAB2)

-> SAve

-> Flowlogic.

3. Create two subscreens (10, 20) -> Add required components in each subscreen.

4. In Top Include File, specify following code:

DATA : IO1(10), IO2(10), IO3(10), IO4(10).

CONTROLS TBSTR TYPE TABSTRIP.

DATA A LIKE SY-DYNNR.

'CONTROLS' statement is used to allocate a memory area for the tabstrip created in the normal screen. 'TABSTRIP' itself is a data type for the tabstrip control. Whenever a tabstrip is created, SAP creates an object called 'ACTIVETAB' which is used to call the corresponding subscreens for each tab button in PAI.

5. In Flowlogic editor, write following code to initiate the subscreens to the corresponding subscreen areas of each tab button when the main screen is called:

PROCESS BEFORE OUTPUT.

MODULE STATUS_0100.

CALL SUBSCREEN SUB1 INCLUDING 'SAPMZTABSTRIP' '10'.

CALL SUBSCREEN SUB2 INCLUDING 'SAPMZTABSTRIP' '20'.

PROCESS AFTER INPUT.

MODULE USER_COMMAND_0100.

CALL SUBSCREEN SUB1.

CALL SUBSCREEN SUB2.

6. In PAI, specify following code for click events on each tab button:

CASE SY-UCOMM.

WHEN 'TAB1'.

A = '10'. * calls specified subscreen during PAI

TBSTR-ACTIVETAB = 'TAB1'. * makes entire tab button in active status

WHEN 'TAB2'.

A = '20'.

TBSTR-ACTIVETAB = 'TAB2'.

WHEN 'DISPLAY'.

LEAVE TO LIST-PROCESSING.

WRITE 😕 IO1, IO2, IO3, IO4.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

7. Create a Tcode -> Activate all -> Execute.

TABLE CONTROLS:

-


Table Control component is used to view the internal table contents in the screen.

Navigations to create Table control component:

-


1. Create an MPP program.

2. In Top include File, declare variables as follows:

DATA ITAB LIKE KNA1 OCCURS 0 WITH HEADER LINE.

DATA ITAB1 LIKE KNA1 OCCURS 0 WITH HEADER LINE.

CONTROLS TBCL TYPE TABLEVIEW USING SCREEN 100.

DATA CUR TYPE I VALUE 5.

-> Save -> Activate.

3. Create a Screen (100) -> Select Table control component from toolbar -> Double Click and specify name (TBCL) -> Press F6 and specify internal table name (ITAB) -> Select required fields -> Paste on the Table control -> To separate the fields, use Separators option in Table control Attributes -> Specify labels if necessary -> Create pushbuttons (FETCH, MODIFY, PRINT, EXIT) -> Save -> Flowlogic.

4. In PAI module, specify following code:

CASE SY-UCOMM.

WHEN 'FETCH'.

SELECT * FROM KNA1 INTO TABLE ITAB.

TBCL-LINES = SY-DBCNT. * To create Vertical Scrollbar

WHEN 'EXIT'.

LEAVE PROGRAM.

WHEN 'PRINT'.

GET CURSOR LINE CUR.

READ TABLE ITAB INDEX CUR.

LEAVE TO LIST-PROCESSING.

WRITE 😕 ITAB-KUNNR, ITAB-NAME1, ITAB-ORT01, ITAB-LAND1.

WHEN 'MODIFY'.

LOOP AT ITAB1.

MODIFY KNA1 FROM ITAB1.

IF SY-SUBRC = 0.

MESSAGE S002(ZMSG).

ELSE.

MESSAGE E003(ZMSG).

ENDIF.

ENDLOOP.

SELECT * FROM KNA1 INTO TABLE ITAB.

TBCL-LINES = SY-DBCNT.

ENDCASE.

5. In FlowLogic editor, specify following step loops:

PROCESS BEFORE OUTPUT.

MODULE STATUS_0100.

LOOP AT ITAB CURSOR CUR WITH CONTROL TBCL.

ENDLOOP.

PROCESS AFTER INPUT.

MODULE USER_COMMAND_0100.

LOOP AT ITAB.

MODULE NEW. * New module to move records from ITAB to ITAB1. Double click on Module Name (New) to create a new one.

ENDLOOP.

6. Specify following code in the NEW module:

MODULE NEW INPUT.

APPEND ITAB TO ITAB1.

ENDMODULE.

7. Create a Tcode -> Activate all -> Execute.

USING TABLE CONTROL WIZARD:

-


This is a predefined SAP-specific component to create table control using predefined navigations.

1. Create an executable program (Z_TABLEWIZARD) in SE38 editor. Write the following code:

CALL SCREEN 200.

-> Save -> Activate.

2. Goto SE51 -> Specify program name created earlier (Z_TABLEWIZARD) -> Specify Screen number (200) -> Layout -> Select Table Control (Wizard) component from toolbar -> Opens Table control Wizard -> Follow the navigations -> Save and Activate the table control.

3. Execute the program (Z_TABLEWIZARD).

Regards,

Priya.

Edited by: priyadharshini veluswamy on Mar 3, 2008 12:44 PM

Edited by: priyadharshini veluswamy on Mar 3, 2008 12:46 PM

Edited by: priyadharshini veluswamy on Mar 3, 2008 12:46 PM

Read only

Former Member
0 Likes
594

Hi,

You can go to transaction ABAPDOCU and there left side pan you can find the sections. From there select the ABAP USER DIALOG....you will get the ample of example on the module pool programming.

Cheers,

Prashant

Read only

Former Member
0 Likes
594

Hi Soni,

You can see the Program below...

REPORT ZMODULE_CALL.

tables : zstud.

data : itab type standard table of zstud with header line,

ok_code like sy-ucomm.

call screen 101.

  • In 101 u have to design in the screen painter. In that u have *2 place three labels, three input fields -- set the table *column field & one button for update.

&----


*& Module STATUS_0101 OUTPUT

&----


  • text

----


module STATUS_0101 output.

SET PF-STATUS 'TEST'. "set the back button

  • SET TITLEBAR 'xxx'.

endmodule. " STATUS_0101 OUTPUT

&----


*& Module USER_COMMAND_0101 INPUT

&----


  • text

----


module USER_COMMAND_0101 input.

case ok_code.

when 'BACK'.

LEAVE PROGRAM.

when 'CANCEL'.

LEAVE PROGRAM.

when 'UPDATE'.

itab-zstdno = zstud-zstdno.

itab-zstdname = zstud-zstdname.

itab-zstdcourse = zstud-zstdcourse.

append itab.

insert into zstud values itab.

clear zstud-zstdno.

clear zstud-zstdname.

clear zstud-zstdcourse.

  • LEAVE PROGRAM.

endcase.

endmodule. " USER_COMMAND_0101 INPUT

Hope its Helpful..

Reward if Useful.

Regards,

Anita.

Read only

Former Member
0 Likes
594

HI,

Module pool programs are created in abap development work bench (TCODE: SE80).

Here we can do all the works whatever you can do in abap.

Module pool programs are also called dialog programs.

The module Pool are reports prepared for different screens and to manage the sequence of events of these screens, in the transaction SE80 you can see all the dynpros that you have for this kind of report, add new ones, add all types of element to the report.

Process Before Output is the part of the dynpro code that is processed before the user can do anything with the data in the screen

Process After Input is the part of the dynpro code that is processed after the interaction with the user.

Here is the simple program to start with..

1) Create a screen 1001 with the following. This program creates 2 text boxes and insert the given values into a Z table.

2) a and b are the 2 text boxes created in SE41 for this program

3) since a and b refer the predefined type in SE41, they must be declared in this pgm also.

4) If they refer the data dictionary in SE41, we need not declare these 2 variables in this pgm.

5) Create a button called SAVE (Function code is UPDATE)

6) In PBO, set the PF status (enabling the BACK, EXIT, CANCEL) buttons.

report zmod_pool1.

data: int_tab type standard table of ztable11,

fs type ztable11,

ok like sy-ucomm,

a type i,

b(10) type c.

call screen 1001.

module status_1001 output.

set pf-status 'PF_S'.

endmodule. " STATUS_1002 OUTPUT

module user_command_1001 input.

case ok.

when 'UPDATE'.

clear fs.

fs-number1 = a.

fs-name = b.

append fs to int_tab.

insert into ztable11 values fs.

if sy-subrc = 0.

message s001(zkaar).

endif.

when 'BACK'.

leave program.

when 'OTHERS' .

leave program.

endcase.

endmodule.

Hope it helps u....

Kindly reward points if helpful

Cheers,

Shanthi.

Edited by: Shanthi on Mar 3, 2008 1:11 PM