Module Pool
Module Pool
v1.0
2 Syntax Description
3 Demonstration
4 Exercises
5 HelpMe
India SAP CoE, Slide 2
Module Pool program.
Program Attributes
“With TOP INCL.” Title
should be checked.
Type “M”
Go back to Repository
Browser, not source
code. Application
PBO Modules
PAI Modules
Subroutines
• An online program consists not only of the screens and their Flow Logic,
but also ABAP program components: Global data, PBO modules, PAI
modules, and subroutines.
• PBO and PAI modules: It contain the main processing logic of online
program and are “called” from within the Flow Logic of the screens.
F8
Transaction Code
Transaction
Program Name Initial Screen
Text
2 Syntax description
3 Demonstration
4 Exercises
5 HelpMe
India SAP CoE, Slide 9
Tools used:
When creating an module pool program, you will use many tools within
the ABAP Development Workbench: Screen Painter, ABAP Editor,
Menu Painter, ABAP Dictionary, and Repository Browser.
Repository Browser
Menu Painter
ABAP Dictionary
Slide 2 Online Programming | 2.01 | August -2003 © Copyright IBM Corporation 2003
•You should always use the Repository Browser to create online programs
because the system will automatically maintain an online program’s sub-
objects and you will be able to see the hierarchy list of these sub-objects.
From this hierarchy list, you will be able to branch to the Screen Painter,
ABAP Editor, Menu Painter, and ABAP Dictionary.
• Using screen user can provide input to program and in turn program will
display result on screen.
• One of the strength is that screen elements are combined with the
ABAP dictionary to allow check the consistency of the data that user
has entered.
Screen
Screen Painter Attributes
Screen
Layout
Field
Attributes
Flow Logic
The number 1000 is reserved for table screens and report selection
screen.
For screens in programs in the SAP namespace, numbers less than 9000
are reserved for SAP screens, numbers between 9000 and 9500 are
reserved for SAP partners, and numbers greater than 9500 are for
customers.
• Modal dialog box – used to display details in a dialog box. Used for data
input, confirmation/error/help messages.
Settings
• Hold data – On checking this, system can hold entries made on the
screen at runtime. System automatically displays this data if the user calls
the particular screen again.
Other Attributes
• Next Screen – Next screen number to be displayed.
• Line/Columns –
Occupied – Specifies the size of the screen area currently occupied with
screen elements
Maintained – Size of the screen in rows/columns.
• Context menu – It will hold a routine name required to set up the context
menu in the program. This routine connects the screen (elements) from the
Screen Painter to the context menu of the program.
The Screen Painter has a layout editor that you use to design your screen
layout.
Both modes offer the same functions but use different interfaces. Graphical
mode of screen designing is commonly used.
• Element bar – screen element attributes appear in this line. You can also
change these attributes in the corresponding field.
Entries in (*********)
Input Box
• To create a user defined menu enter the name of the menu and double
click on it. We can define options for the menu here as below,
• Application tool bar can also be created in same way as menu bar.
• We can assign code to existing function keys. Only keys for which code
is assigned will be active. We can see this when the menu painter is
executed.
• Enter a screen number and title if you want to simulate a whole screen.
If you do not enter a screen number, the system simulates the status
using an empty test screen.
• Output as below, New Menu is added, Find Item in Application tool bar,
Save, Back & Print button on standard tool bar enabled.
• Flow logic refers to code behind the screens. It is the code that processes
a screen.
• By default this module will be commented. To use this uncomment and double
click on it to get the module created.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
module STATUS_0100 output.
* SET PF-STATUS ‘XXX'.
* SET TITLEBAR 'xxx'.
endmodule. " STATUS_0100 OUTPUT
Menu Bar-
• To set menu bar uncomment the SET PF_STATUS and give a name to
status as ,
SET PF-STATUS 'STATUS100'.
• Double click on TITLE100 and click yes to create GUI title. Enter title as
below and click on , save and activate.
• Once all the modules in the PBO block are processed, the system copies
the content of the fields in the ABAP work area to their corresponding
fields in the screen work area.
• This event is triggered once the user invokes function code or presses Enter
key on the screen.
• System variable SY-UCOMM will hold the function code assigned to the
screen elements (push button, radio button, check box etc).
• Within the above module code has to written to branch to group of code
based on the function code from SY-UCOMM.
• The system copies the contents of the fields in the screen work area to their
corresponding fields in the ABAP work area once user clicks Enter key on
screen or any function code is invoked.
WHEN 'BCK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
• There should be a TOP include which will have the data declarations.
• Each include program will insert a include statement in the main program.
t – Message type
nnn –Message Number
WITH – This is optional. It is needed if variables are used in a message.
A message can contain up to four variables, indicated with an
ampersand (&) in the message text.
• I: information I
• A: abend
• X: exit
• W: warning
• E: error X
The message type determines where the message is displayed and what
action the user can or must take on the current screen.
• If you have next screen then the message will be displayed at the bottom
of the next screen.
• After pressing Enter key on dialog box user will be taken to next screen.
The user is not restricted from going on to the next screen.
• Exit message is identical to the ABEND message except that the transaction is
terminated with a short dump instead of the message in a dialog box.
• On pressing the ‘Enter’ key on the current screen, the user will be taken to the
next screen even if no changes were made on the current screen . Thus user is
not restricted from going on to the next screen.
• The user must make changes to the values on the current screen.
• On pressing the ‘Enter’ key on the current screen, the user will be taken
to the next screen only if the appropriate corrections were made on the
current screen.
– Issue an error or warning message with the Flow Logic SELECT statement.
– Define valid values for a screen field with the Flow Logic VALUES statement.
• The purpose of the “FIELD” statement is to keep a single screen field open for
input after an error or warning message is issued.
• If the value entered in this field is not in the valid set, an error message
will be issued by the system.
PROCESS AFTER INPUT.
field PO_NO values ('1', '100').
• This indicates PO_NO can take input as either 1 or 100. For any other
value system will through error and the field will be open for input.
• With VALUES parameter for field, we can get a list of possible values
by clicking on the drop-down arrow of the screen fields or pressing the
‘F4’ key. It will list the values mentioned.
• By default, the cursor will be positioned in the first field open for
input on a screen.
• Cursor position can be changed in two ways –
1. By setting the cursor position in PBO event-
Syntax - SET CURSOR FIELD <field name>
Cursor will be placed on the screen field mentioned.
• Additions are,
ON INPUT
ON REQUEST
AT EXIT-COMMAND
AT CURSOR-SELECTION
• Ex- blanks for character fields and zeroes for numeric fields.
• The basic syntax for this conditional execution Flow Logic command is:
– The PAI <module> will be executed only if the value in <screen field> is not equal to its
initial value.
– The “ON INPUT” addition must be used with a “FIELD” statement because this
condition depends on the value of a particular field.
• The basic syntax for this conditional execution Flow Logic command is:
FIELD <screen field> MODULE <module> ON REQUEST.
– The PAI <module> will be executed only if a value was entered in <screen field>
since the screen was displayed.
– The “ON REQUEST” addition must be used with a “FIELD” statement because this
condition depends on the value of a particular field.
• If the user invokes a type ‘E’ function code, a module with the “AT
EXIT-COMMAND” addition will be executed immediately.
• You can specify that a module should only be called if the cursor is
positioned on a particular screen element.
• The module <mod> is called whenever the function code of the user
action is CS with function type S.
• The module is called in the sequence in which it occurs in the flow logic.
• It does not bypass the automatic input checks.
• You can also combine this MODULE statement with the FIELD
statement:
FIELD <f> MODULE <mod> AT CURSOR-SELECTION.
• We can modify the attributes of the fields and update the screen table using
MODIFY SCREEN.
• Sample code:
loop at screen.
if screen-name = 'GV_MATNR'.
screen-input = 1.
modify screen.
endif.
endloop.
• A field attribute is turned “on” with a value of 1. It is turned “off” with a value
of 0.
Database Database
Database
Transaction Transaction
Transaction
• If an SAP LUW contains database changes, you should either write all
of them or none at all to the database.
• R/3 system contain lock mechanism for SAP LUWs called SAP Locks.
• A lock object definition contains the database tables and their key fields
on the basis of which you want to set a lock.
• When user clicks on change, the program locks the relevant database object by calling the corresponding ENQUEUE
function.
• You can release the lock by calling DEQUEUE function when user clicks on SAVE or when user clicks on BACK button.
• To create a table control, drag & drop table control from screen elements on
screen painter. Give a name to table control.
• Select the table definition and fields clicking on Dictionary/Program fields
object button.
• Each table control need to be declared in declaration part of the program as,
CONTROLS <ctrl> TYPE TABLEVIEW USING SCREEN <scr>.
where <ctrl> is the name of the table control on a screen.
• You must code a LOOP statement in both the PBO and PAI events for each
table in your screen.
• This is because the LOOP statement causes the screen fields to be copied
back and forth between the ABAP program and the screen field.
Screen
Database
er
h ead
h
le wit
al Tab
rn
Inte
• The subscreen displayed in the predefined area will depend on the user’s
request on the main screen.
Subscreen
– Save the subscreen and go to screen layout. Here subscreen are will
be displayed.
– Then, the system returns to finish the PAI event of the “main” screen.
• In both the PBO and PAI of the “main” screen, the “CALL SUBSCREEN”
statement cannot be used inside a “LOOP” or a “CHAIN”.
– SET PF-STATUS
– SET TITLEBAR
– SET SCREEN
– LEAVE TO SCREEN
– CALL SCREEN
Scrolling
• For designing and using tab strip controls, see Transaction BIBS .
ctrl-Activetab = fcode.
• Your element lines now make up a single step loop block. The block includes the original elements
with their attributes and a predefined number of repetition blocks.
• The repetition blocks are consecutively numbered, so that you can establish a reference to a
particular line.
• For Step loop the flow logic statement loop must be coded in both PBO and
PAI event. One form of the Flow Logic “LOOP” statement is;
LOOP.
. . . <flow logic statements> . . .
ENDLOOP.
• Enjoy SAP controls (ALV Grid , ALV Tree, HTML controls etc) can be
displayed in screen.
• If the user presses the ‘F1’ key with the cursor is positioned in <screen
field>, the <supplemental documentation> will be displayed along with
the data element’s short text and documentation.
• The only other Flow Logic statement that can be used in the POH event
is:
FIELD <screen field> MODULE <module>.
• This event is a user-programmed help that occurs when the user presses
F4 with the cursor positioned on a screen field.
• Syntax is:
FIELD <screen field> MODULE <module>.
2 Syntax Description
3 Demonstration
4 Exercises
5 HelpMe
India SAP CoE, Slide 118
Demonstration
Microsoft Word
Document
2 Syntax Description
3 Demonstration
4 Exercises
5 HelpMe
India SAP CoE, Slide 120
Exercises
Please refer the attached documents for hands-on.
• Exercise 1 – This covers input/output, radio button, table control, screen
navigation, flow logic events, Menu painter.
Microsoft Word
Document
• Exercise 2 – This covers tab strip, subscreen, table control, 4 flow logic
events, screen navigation, menu painter.
Microsoft Word
Document
2 Syntax Description
3 Demonstration
4 Exercises
5 HelpMe
India SAP CoE, Slide 122
HelpMe
• Refer help.sap.com
• For screen elements and controls (table control, tabstrip) refer transaction
BIBS.