You are on page 1of 13

MODULE-POOL PROGRAMMING

Dialog Programs:
A dialog program allows you to work interactively with the system and to change the contents of the database tables. Each dialog program has a certain sequence of screens that are processed by the system one after the other. From the view of a user, a dialog step consists of receiving a screen for entering data, then after the users clicks a button or selects a menu entry, processing is started. From the view of the SAP system, the screen is prepared and sent. After this, the user receives it and fills it out. Then the system analyzes and processes the data contained on the screen after receiving it from the user. A dialog program must offer: o a user-friendly user interface o format and consistency checks for the data entered by the user o easy correction of input errors o access to data by storing it in the database.

ABAP/4 offers a variety of tools and language elements to meet the requirements for creating and running dialog programs.

Main Components of a Dialog Program


You use the Screen Painter and the Menu Painter to create and design screen templates and screen programs. You define the processing logic in an ABAP/4 program (module pool). Data structures are defined in the ABAP/4 Dictionary. You can access these structures from the ABAP/4 program and when defining screen fields. The dialog processor controls the flow of your dialog program.

Structure of a Dialog Program


A dialog program consists of the following basic components:

Screens (dynpros)
Each dialog in an SAP system is controlled by dynpros. A dynpro (DYnamic PROgram) consists of a screen and its flow logic and controls exactly one dialog step. The flow logic determines which processing takes place before displaying the screen (PBO-Process Before Output) and after receiving the entries the user made on the screen (PAI-Process After Input). The screen layout fixed in the Screen Painter determines the positions of input/output fields, text fields, and graphical elements such as radio buttons and checkboxes. In addition, the Menu Painter allows storing menus, icons, pushbuttons, and function keys in one or more GUI statuses. Dynpros and GUI statuses refer to the ABAP/4 program that controls the sequence of the dynpros and GUI statuses at runtime.

ABAP/4 module pool


Each dynpro refers to exactly one ABAP/4 dialog program. Such a dialog program is also called a module pool, since it consists of interactive modules. The flow logic of a dynpro contains calls of modules from the corresponding module pool. Interactive modules called at the PBO event are used to prepare the screen template in accordance to the context, for example by setting field contents or by suppressing fields from the display that are not needed. Interactive modules called at the PAI event are used to check the user input and to trigger appropriate dialog steps, such as the update task. All dynpros to be called from within one transaction refer to a common module pool. The dynpros of a module pool are numbered. By default, the system stores for each dynpro the dynpro to be displayed next. This dynpro sequence or chain can be linear as well as cyclic. From within a dynpro chain, you can even call another dynpro chain and, after processing it, return to the original chain.

Screen Painter ABAP/4


To create a screen, take the following steps: 1. 2. 3. 4. Define the basic features of a screen (screen attributes) Design the screen layout (in the full screen editor) Define the field attributes (field list) Write the screen flow logic

The most important ABAP/4 program components are found in the following objects: Global data or Dictionary structures in the TOP include program (data declarations) PBO (Process Before Output) module PAI (Process After Input) module Subroutines (if required)

An SAP dynpro consists of several components:


Flow logic: Calls of the ABAP/4 modules for a screen.


Screen layout: Positions of the texts, fields, pushbuttons, and so on for a screen. Screen attributes: Number of the screen, number of the subsequent screen, and Field attributes: Definition of the attributes of the individual fields on a screen.

Sample Dialog Program:


We can create a dialog program in 2 methods so called 1. Offline 2. Online

Offline method includes creating a program in SE51 (screen painter). Online method includes creating a program in SE80 (Object Navigator).
Here I have created a small and basic program to display NAME and CITY of the customer entered.

As discussed above these are the PBO and PAI modules

Screen painter:
Using screen painter we can create text, fields, checkboxes, radio buttons, buttons, tab strips etc..,

As shown below, Every element on the screen has their own attributes.

We can also insert fields from database and program directly as shown below Click on the button Dictionary/ Program fields

Now click on Get from program to get the fields which are defined in the program

Now select the required fields and press ENTER.

Once a field is used, It cannot be reused, You can see a lock symbol as shown below,

Now choose the place where you want to put the fields and drop the selected fields at you desired location.

You will see some thing like this.

Also we can also define sub-screen areas on the screen.

Source Code:
*&---------------------------------------------------------------------*
*& Module Pool Z_TEST_KT *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* PROGRAM Z_TEST_KT. DATA cust like kna1-kunnr. DATA: NAME,CITY. DATA W_KNA1 TYPE TABLE OF kna1 WITH HEADER LINE. *&---------------------------------------------------------------------* *& 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. CASE SY-UCOMM. WHEN 'DISP'. SELECT NAME1 ORT01 FROM KNA1 INTO CORRESPONDING FIELDS OF W_KNA1 WHERE KUNNR EQ CUST. ENDSELECT. LEAVE TO LIST-PROCESSING. IF NAME = 'X'. WRITE W_KNA1-NAME1. ENDIF. IF CITY = 'X'. WRITE W_KNA1-ORT01. ENDIF. ENDCASE. endmodule. " USER_COMMAND_0100 INPUT

Out Put:
Note: You should have a Transaction defined for the Module program to execute .
This is the output you see after executing the program Enter the customer Number and select NAME or CITY or both and click on DISPLAY.

You will be able to see this screen

You might also like