Post on 10-Feb-2018
7/22/2019 Module Pool Training Presentation
1/123
7/22/2019 Module Pool Training Presentation
2/123
India SAP CoE, Slide 2
Module pool programming
1 Introduction
2 Syntax Description
3 Demonstration
4 Exercises
5 HelpMe
7/22/2019 Module Pool Training Presentation
3/123
India SAP CoE, Slide 3
Module Pool program.
Module Pool Program (also called Online programs , dialog programs, or
transactions) do not produces lists. These programs are a collection of
screens, their Flow Logic, and the code within the main ABAP program.
A dialog program offers:
A user-friendly user interface
Format and consistency checks for the data entered by the user Easy correction of input errors
Access to data by storing it in the database.
7/22/2019 Module Pool Training Presentation
4/123
India SAP CoE, Slide 4
Purpose
For performing any kind of task in SAP R/3 system, a transaction is used.SAP provides a standard set of transactions to manipulate data in thesystem. But sometimes, the need to create a customer specific transactionarise due to following reasons :
Standard SAP may not support that task.
A particular transaction needs to be customized to suit the customerrequirements .
A transaction (also called module pool programs, dialog programs) is
defined as a collection of screens (the actual, physical image that the userssees), their Flow Logic (code behind the screens ), and the code within themain ABAP program.
7/22/2019 Module Pool Training Presentation
5/123
India SAP CoE, Slide 5
Program Attributes
Title
Type M
Application
Online program name
must begin with either a
Y or Z.
Go back to Repository
Browser, not source
code.
With TOP INCL.
should be checked.
Creating an Online Program
7/22/2019 Module Pool Training Presentation
6/123
India SAP CoE, Slide 6
Module Pool Program Components
Top Include
PBO Modules
PAI Modules
ABAP
Subroutines
7/22/2019 Module Pool Training Presentation
7/123
India SAP CoE, Slide 7
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.
Global data: It is declared in the Top Include program.
PBO and PAI modules: It contain the main processing logic of online
program and are called from within the Flow Logic of the screens.
The subroutines (if necessary) are in a separate include program.
Module Pool Program
7/22/2019 Module Pool Training Presentation
8/123India SAP CoE, Slide 8
Transaction Code
Transaction
Text
F8
Program Name Initial Screen
required required required
Executing an Online Program
7/22/2019 Module Pool Training Presentation
9/123India SAP CoE, Slide 9
Module pool programming
1 Introduction
2 Syntax description
3 Demonstration
4 Exercises
5 HelpMe
7/22/2019 Module Pool Training Presentation
10/123India SAP CoE, Slide 10
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.
ABAP Editor (SE38)To maintain main ABAP program. Programcontains data declarations and modules.
7/22/2019 Module Pool Training Presentation
11/123India SAP CoE, Slide 11
Screen Painter(SE51)used to maintain components of screen.
Menu Painter(SE41)Used to design GUI.
Maintain Transaction(SE93)To create transaction code for program.
Object Navigator (Repository Browser)(SE80) - You should always use
the object navigator for online programs because you will be able to see thehierarchy. From this hierarchy list, you will be able to branch to the Screen
Painter, ABAP Editor, Menu Painter, and ABAP Dictionary.
You should alwaysuse the Repository Browserto create online programs
because the system will automatically maintain an online programs 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.
Tools used:
7/22/2019 Module Pool Training Presentation
12/123India SAP CoE, Slide 12
Creating a Program
Create a program using transaction SE38. Program name as
Z_MODULE_TRAINING.
Program type should be Module Pool. Save and activate the program.
Use object navigator(SE80) to further develop the object.
7/22/2019 Module Pool Training Presentation
13/123India SAP CoE, Slide 13
Program Structure
Module pool program when viewed from SE80 transaction will havestructure as below,
7/22/2019 Module Pool Training Presentation
14/123India SAP CoE, Slide 14
Assigning transaction code
Dialog program is executed using transaction code. We can not execute
this like normal report using execute or pressing F8 button.
Transaction is created using SE93 transaction or from object browser by
right clicking on transaction, click on create. Give name and description
and select the radio button Program and screen (dialog transaction)
7/22/2019 Module Pool Training Presentation
15/123India SAP CoE, Slide 15
Use of Screen
Screen is a interface between user and SAP.
Using screen user can provide input to program and in turn program will
display result on screen.
Screen is made up of screen elements such as text box, input/output field,
check box, radio button etc.
One of the strength is that screen elements are combined with the ABAP
dictionary to allow check the consistency of the data that user hasentered.
7/22/2019 Module Pool Training Presentation
16/123India SAP CoE, Slide 16
Screen Painter
To start the Screen Painter, choose the corresponding pushbutton on the
initial screen of the ABAP Workbench or enter Transaction SE51.
Best practice is to go to transaction SE80, enter program name and you
can perform one of the below,
1. Create new screens.
2. Test an existing screen.
3. Create new components for an existing screen.
Screen is always created for an existing program.
7/22/2019 Module Pool Training Presentation
17/123India SAP CoE, Slide 17
Overview of Screen Painter
Screen PainterScreen
Attributes
Screen
Layout
Field
AttributesFlow Logic
7/22/2019 Module Pool Training Presentation
18/123India SAP CoE, Slide 18
Developing Screen
From Object navigator (SE80) we can create the screen as shown, Click on Screen, right click and select create option.
Now enter screen number.
7/22/2019 Module Pool Training Presentation
19/123India SAP CoE, Slide 19
Developing Screen
Screen numbers can be up to 4 characters long, all of which must be
digits.
The number 1000 is reserved for table screens and report selection
screen.
Screen numbers from 9000 are reserved for customer-specific screens.
The use of screen numbers is namespace-dependent.
For screens in programs in the SAP namespace, numbers less than 9000are reserved for SAP screens, numbers between 9000 and 9500 are
reserved for SAP partners, and numbers greater than 9500 are for
customers.
7/22/2019 Module Pool Training Presentation
20/123India SAP CoE, Slide 20
For screens in programs in the Customize namespace, any four digit
number can be used as screen number except 1000 as mentioned above.
Usual practice is to have screen numbers for customize module pool
program, starting with 100 then continue as 200, 300 etc.
Enter screen number and click on create.
Developing Screen
7/22/2019 Module Pool Training Presentation
21/123India SAP CoE, Slide 21
Developing Screen
Enter description and save.Check the screen and activate it.
7/22/2019 Module Pool Training Presentation
22/123India SAP CoE, Slide 22
Screen Attributes
Short descriptionDescribes screen purpose
Original languageDefault logon language
PackageIdentifies the package with which screen is saved
Last changed on/byDate & time screen is last changed
Last generationDate & time screen is last generated.
7/22/2019 Module Pool Training Presentation
23/123India SAP CoE, Slide 23
Screen AttributesScreen Type
NormalDefault setting
SubscreenTo indicate the screen as a subscreen
Modal dialog boxused to display details in a dialog box. Used for data
input, confirmation/error/help messages.
Selection screenIdentifies selection screen. The system sets thisattribute automatically.
Settings
Hold dataOn checking this, system can hold entries made on the screenat runtime. System automatically displays this data if the user calls the
particular screen again.
7/22/2019 Module Pool Training Presentation
24/123India SAP CoE, Slide 24
Screen Attributes
Settings
Switch off runtime compressOn setting this option, the screen is notcompressed at runtime.
Template non executableThis attribute is primarily for internal use bySAP.
Hold scroll position On setting the attribute, the scroll position isretained when the user returns to the screen after processing anotherscreen.
Without application tool barTo suppress the display of the application
toolbar belonging to the current program status.
Other Attributes
Next ScreenNext screen number to be displayed.
7/22/2019 Module Pool Training Presentation
25/123India SAP CoE, Slide 25
Screen AttributesOther Attributes
Cursor positionIdentifies the screen element that contains the cursor when ascreen is first displayed. If you leave this field blank, the system uses the firstscreen field that can accept input.
Screen groupSpecifies a four-character identifier of a group of associatedscreens.
Line/Columns
OccupiedSpecifies the size of the screen area currently occupied withscreen elements
Maintained Size of the screen in rows/columns.
Context menuIt will hold a routine name required to set up the context menuin the program. This routine connects the screen (elements) from the ScreenPainter to the context menu of the program.
7/22/2019 Module Pool Training Presentation
26/123India SAP CoE, Slide 26
Screen Layout Mode
The Screen Painter has a layout editor that you use to design your screenlayout.
It works in two modes:
Graphical modeDrag and drop interface is used, similar to a drawingtool.
Alphanumeric modeKeyboard and menus are used for designing.
Both modes offer the same functions but use different interfaces. Graphicalmode of screen designing is commonly used.
7/22/2019 Module Pool Training Presentation
27/123
India SAP CoE, Slide 27
Screen Designing We have learnt about creating a screen.
To start screen design, click on layout button on screen.
Graphical Screen painter will start loading.
7/22/2019 Module Pool Training Presentation
28/123
India SAP CoE, Slide 28
Components of Layout Editor
Element paletteUsed for creating screen elements. These can be drag& dropped on screen.
Work AreaScreen design is done in this area.
Element barscreen element attributes appear in this line. You can also
change these attributes in the corresponding field.
7/22/2019 Module Pool Training Presentation
29/123
India SAP CoE, Slide 29
Creating Radio Button
Radio Button
Click on the Radio Button Icon and Click on the Screen.
Create at least two Radio Buttons
Name the Radio Buttons and Activate it.
7/22/2019 Module Pool Training Presentation
30/123
India SAP CoE, Slide 30
Defining Radio Button Group
Assign Radio Buttons into one
Group.
Select the Radio Buttons
and Follow the steps.
7/22/2019 Module Pool Training Presentation
31/123
India SAP CoE, Slide 31
Click on the Check Box Icon and Click on the Screen.Name the Check Box and Activate it.
Special input/output fields that the user can either select (value X) or
deselect (value SPACE). Checkbox elements can be linked with
function codes.
Creating Check Box
Check Box
Name the Check box
7/22/2019 Module Pool Training Presentation
32/123
India SAP CoE, Slide 32
Screen Components
Screen element properties can be seen indetail by double clicking on the element.
Properties of an element can be set here,such as variable length, F4 help,input/output, mode of display etc.
Best practice is to define screenelements by adopting the correspondingfield from the ABAP Dictionary.However, you can also use fielddescriptions that you defined in your
program. To do this you must generatethe program first.
7/22/2019 Module Pool Training Presentation
33/123
India SAP CoE, Slide 33
Screen Elements
Screen elements are, Text field
Input/Output field
Check box
Radio button
Push button
Tab strip
Box
Sub screen area
Table control
Custom control Status Icon
Each element will have unique name.
Function code will be assigned for push
buttons, tab titles in tab strip controls,Input/output fields with the "Dropdown box"
attribute.
Each element will have its position on
screen, visible/definite length, mode of
display etc.
7/22/2019 Module Pool Training Presentation
34/123
India SAP CoE, Slide 34
Screen Elements
Push Button
Can be placed on screen by drag& drop from Element palette.
To set the properties, doubleclick on it.
Each screen element shouldhave unique name.
In addition to that push button
will have text and function codeassigned to it.
7/22/2019 Module Pool Training Presentation
35/123
India SAP CoE, Slide 35
Function Code for Push Buttons, check box, Radio Button
Assign Parameter ID to Input / Output Field
Dict. Tab is Selected
Program Tab is Selected
Tick If Input or Output Box
Entries in (*********)
Choose if want to Make the Field Mandatory
Screen Elements
7/22/2019 Module Pool Training Presentation
36/123
India SAP CoE, Slide 36
Screen Elements
Once screen is designed, it should be saved and checked for errors and activated.
Screen looks as below,
Input Box
7/22/2019 Module Pool Training Presentation
37/123
India SAP CoE, Slide 37
Testing Screen
Screen can tested by executing F8 or click on button
7/22/2019 Module Pool Training Presentation
38/123
India SAP CoE, Slide 38
Testing Screen
7/22/2019 Module Pool Training Presentation
39/123
India SAP CoE, Slide 39
Flow Logic
Default flow logic for any screen is generated as shown below,
7/22/2019 Module Pool Training Presentation
40/123
India SAP CoE, Slide 40
Menu Painter
In all programs GUI consists of a menu bar, a standard toolbar, anapplication toolbar and title bar.
A programs GUI is created in Menu Painter.
To Create a Menu for a screen, in flow logic uncomment MODULE
STATUS_0400. in PBO event
PROCESS BEFORE OUTPUT.
MODULE STATUS_0400.
PROCESS AFTER INPUT.
* MODULE USER_COMMAND_0400.
7/22/2019 Module Pool Training Presentation
41/123
India SAP CoE, Slide 41
Menu Painter
Now double click onSTATUS_0400. A pop up window will appear. Clickon Yes.
Module will be created as below,
*&---------------------------------------------------------------------*
*& Module STATUS_0400 OUTPUT
*&---------------------------------------------------------------------*
module STATUS_0400 output.* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
endmodule. " STATUS_0400 OUTPUT
7/22/2019 Module Pool Training Presentation
42/123
India SAP CoE, Slide 42
Menu Painter
Uncomment the line SET PF-STATUS 'xxxxxxxx'. and replace
'xxxxxxxx with name STATUS_400.
Click on STATUS_400. Click Yes on the pop-up.
7/22/2019 Module Pool Training Presentation
43/123
India SAP CoE, Slide 43
Menu Painter
Enter description and choose the status type as Normal screen which isdefault.
7/22/2019 Module Pool Training Presentation
44/123
India SAP CoE, Slide 44
Menu Painter
Click on to expand the menu bar, application toolbar and functionkeys.
System and Help are default in menu bar
7/22/2019 Module Pool Training Presentation
45/123
India SAP CoE, Slide 45
Creating Menu bar
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,
7/22/2019 Module Pool Training Presentation
46/123
India SAP CoE, Slide 46
Creating Application Tool bar
Application tool bar can also be created in same way as menu bar.
7/22/2019 Module Pool Training Presentation
47/123
India SAP CoE, Slide 47
Assigning function keys
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.
7/22/2019 Module Pool Training Presentation
48/123
India SAP CoE, Slide 48
Execution
We can test the menu painter by clicking on F8 key or execute button
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.
7/22/2019 Module Pool Training Presentation
49/123
India SAP CoE, Slide 49
Execution
Output as below, New Menu is added, Find Item in Application tool bar,
Save, Back & Print button on standard tool bar enabled.
7/22/2019 Module Pool Training Presentation
50/123
India SAP CoE, Slide 50
More on Flow Logic
Flow logic refers to code behind the screens. It is the code that processesa screen.
Flow Logic commands are different than ABAP commands
(e.g., IF ENDIF is not valid in Flow Logic).
Dynamic Processor (DYNPRO) controls the flow logic and prepares datato be displayed on the screen.
7/22/2019 Module Pool Training Presentation
51/123
India SAP CoE, Slide 51
More on Flow Logic
Each screen has its own Flow Logic which is divided into four main events:
PROCESS BEFORE OUTPUT (PBO) - event processed before the
screen is displayed.
PROCESS AFTER INPUT (PAI) - event processed after the user has
invoked a function code (e.g., clicked on a pushbutton) or pressed the
Enter key.
Process on Value Request (POV) - Triggered when the user requests
Value help (F4)
Process on Value Request (POH) - Triggered when the user requests
field help (F1)
Each screen must be generated. If you make a change to any component of a
screen, the screen must be re-generated before execution.
7/22/2019 Module Pool Training Presentation
52/123
India SAP CoE, Slide 52
Keywords supported Keywords supported by flow logic events are as below,
Keyword Function
MODULE Calls a dialog module in an ABAP program
FIELD Specifies the point at which the contents of a screen
field should be transported
ON Used in conjunction with FIELD
VALUES Used in conjunction with FIELD
CHAIN Starts a processing chain
ENDCHAIN Ends a processing chain
CALL Calls a sub screen
LOOP Starts processing a screen table
ENDLOOP Stops processing a screen table
7/22/2019 Module Pool Training Presentation
53/123
India SAP CoE, Slide 53
PBO Event By default the module created in PBO event will be like
MODULE STATUS_Ex:-MODULE STATUS_0100.
This module will be processed before the screen is displayed.
By default this module will be commented. To use this uncomment anddouble 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
7/22/2019 Module Pool Training Presentation
54/123
India SAP CoE, Slide 54
PBO Event
Menu bar and title bar can be set in this module.
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 STATUS100 and click yes to create GUI status.
7/22/2019 Module Pool Training Presentation
55/123
India SAP CoE, Slide 55
PBO Event
Title Bar
To assign a title uncomment SET TITLEBAR and give a name as,
SET TITLEBAR 'TITLE100'.
Double click on TITLE100 and click yes to create GUI title. Enter titleas below and click on , save and activate.
Once all the modules in the PBO block are processed, the system copiesthe content of the fields in the ABAP work area to their correspondingfields in the screen work area.
7/22/2019 Module Pool Training Presentation
56/123
India SAP CoE, Slide 56
PAI Event Default module in PAI event will be
MODULE USER_COMMAND_.Ex:- MODULE USER_COMMAND_0100.
This event is triggered once the user invokes function code or pressesEnter key on the screen.
System variable SY-UCOMMwill hold the function code assigned tothe screen elements (push button, radio button, check box etc).
Within the above module code has to written to branch to group of codebased on the function code from SY-UCOMM.
The system copies the contents of the fields in the screen work area totheir corresponding fields in the ABAP work area once user clicks Enterkey on screen or any function code is invoked.
7/22/2019 Module Pool Training Presentation
57/123
India SAP CoE, Slide 57
PAI Event- Sample Code*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT*&---------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'ENT'.
SELECT ebeln ebelp bukrs
INTO CORRESPONDING FIELDS OF TABLE it_po
FROM ekpo
WHERE ebeln = po_no.
WHEN 'BCK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
7/22/2019 Module Pool Training Presentation
58/123
India SAP CoE, Slide 58
Includes
To have structured way of code it is best practice to have includes.
There should be a TOP include which will have the data declarations.
Include for PBO modules, include for PAI modules.
Include for POV and POH modules if any.
7/22/2019 Module Pool Training Presentation
59/123
India SAP CoE, Slide 59
Includes
To create include right click on object name, select Include from theCreate menu.
7/22/2019 Module Pool Training Presentation
60/123
India SAP CoE, Slide 60
Includes
We can gave the include names as Z_TOP,
Z_PBO, Z_PAI. This will help to understandwhich modules are covered in each include.
Each include program will insert a include statement in the main
program.
7/22/2019 Module Pool Training Presentation
61/123
India SAP CoE, Slide 61
Message Statement
The MESSAGE statement is used to issue user messages.
Syntax isMESSAGE [WITH ].
tMessage type
nnnMessage Number
WITHThis 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.
We can code the Message statement in the PAI event.
7/22/2019 Module Pool Training Presentation
62/123
India SAP CoE, Slide 62
Message Types S: success
I: information
A: abend
X: exit
W: warning
E: error X
The message type determines where the message is displayed and whataction the user can or must take on the current screen.
I
7/22/2019 Module Pool Training Presentation
63/123
India SAP CoE, Slide 63
Messages
Successmessage is displayed at the bottom of the screen.
If you have next screen then the message will be displayed at the bottom
of the next screen.
Information message is displayed in a dialog box in same 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.
7/22/2019 Module Pool Training Presentation
64/123
India SAP CoE, Slide 64
Messages
Abend message is displayed on the current screen in a dialog box.
The user cannot make any changes to the values on the current screen.
After pressing the Enter key on the dialog box, transaction will beterminated.
Exitmessage is identical to the ABEND message except that the transactionis terminated with a short dump instead of the message in a dialog box.
WARNINGmessage is displayed at the bottom of the current screen.
On pressing the Enter key on the current screen, the user will be taken tothe next screen even if no changes were made on the current screen . Thususer is not restricted from going on to the next screen.
7/22/2019 Module Pool Training Presentation
65/123
India SAP CoE, Slide 65
Messages
ERRORmessage is displayed at the bottom of the current 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 takento the next screen only if the appropriate corrections were made on the
current screen.
If no corrections were made, the error message would be redisplayed atthe bottom of the current screen.
When a warning or error message is triggered the system will stop atcurrent screen, prompting the user to make corrections. However theinput fields on the screen will be disabled for input.
7/22/2019 Module Pool Training Presentation
66/123
India SAP CoE, Slide 66
Handling Error messages
There are 2 ways to issue error/warning messages.
Issue an error or warning message with the Flow Logic SELECTstatement.
Define valid values for a screen field with the Flow Logic VALUESstatement.
FIELDstatement is a Flow Logic command, not an ABAP command.
The purpose of the FIELD statement is to keep a single screen field openfor input after an error or warning message is issued.
FIELD statement is used in PAI event.
Syntax is: FIELD MODULE .
7/22/2019 Module Pool Training Presentation
67/123
India SAP CoE, Slide 67
FIELD with select statement Screen field can be validated against entry in database table.
To validate Purchase order number in PAI module,
PROCESS AFTER INPUT.
field PO_NO module PO_CHECK.
MODULE USER_COMMAND_0100.
Module PO_CHECK is as below,
module paycheck input.
data: lv_ebeln type ekko-ebeln.
select single ebeln into lv_ebeln
from ekko where ebeln = PO_NO.
if sy-subrc ne 0.
message e003(Z6).
endif.
endmodule. " po_check INPUT
7/22/2019 Module Pool Training Presentation
68/123
India SAP CoE, Slide 68
Error for invalid input
Error for Purchase order when invalid number is entered.
7/22/2019 Module Pool Training Presentation
69/123
India SAP CoE, Slide 69
FIELD with Values Check
The Flow Logic VALUES statement defines a set of valid values for thescreen field specified in the FIELD statement.
If the value entered in this field is not in the valid set, an error messagewill 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 othervalue 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 byclicking on the drop-down arrow of the screen fields or pressing the F4key. It will list the values mentioned.
7/22/2019 Module Pool Training Presentation
70/123
India SAP CoE, Slide 70
Values option
PO_NO with values 1 and 100.
CHAIN S
7/22/2019 Module Pool Training Presentation
71/123
India SAP CoE, Slide 71
CHAIN Statement
To keep multiple screen fields open for input after an error or warningmessage is displayed, you need to use the CHAIN and ENDCHAINFlow Logic commands.
These statements group the FIELD statements and the MODULEstatements together.
The basic syntax of these statements is:
CHAIN.FIELD: , ,...MODULE .
FIELD: , ,...MODULE .
...ENDCHAIN.
If an error or warning message is issued in , all thescreen fields listed in the FIELD statements will be open for input.
C P i i
7/22/2019 Module Pool Training Presentation
72/123
India SAP CoE, Slide 72
Cursor Position
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
Cursor will be placed on the screen field mentioned.
2. Cursor position in screen attributes-Mention the field name where cursor to be placed on
screen in cursor position attribute .
S d
7/22/2019 Module Pool Training Presentation
73/123
India SAP CoE, Slide 73
Screen commands
The LEAVE SCREENstatement ends the current screen andcalls the subsequent screen.
When the system encounters the SET SCREEN ABAP statement, it temporarilyoverrides the NextScreen attribute with this and the PAI
processing continues. After all PAI modules are executed,the system goes to the PBO event of
.
S d
7/22/2019 Module Pool Training Presentation
74/123
India SAP CoE, Slide 74
Screen commands
LEAVE TO SCREEN ABAP statement,terminates the screens PAI event and immediately goes tothe PBO of .
The LEAVE TO SCREEN statement performs
the functionality of two statements: SET SCREEN and LEAVE SCREEN.
CALL SCREEN ABAP statement, temporarilysuspends the current screens PAI processing and
immediately goes to the PBO event of . Whencontrol returns back to the calling screen, its PAI
processing will resume.
M PAI d l
7/22/2019 Module Pool Training Presentation
75/123
India SAP CoE, Slide 75
More on PAI modules
All modules listed in the PAI event get executed from top tobottom.
We can control the execution of the modules using additionsto MODULE.
Additions are,
ON INPUT
ON REQUEST
AT EXIT-COMMAND
AT CURSOR-SELECTION
ON INPUT
7/22/2019 Module Pool Training Presentation
76/123
India SAP CoE, Slide 76
ON INPUT
With the ON INPUT addition to the MODULE statement, a module will be
executed only if the specified fields value is not equal to the initial valueappropriate to its data type
Ex- blanks for character fields and zeroes for numeric fields.
The basic syntax for this conditional execution Flow Logic command is:
FIELD MODULE ON INPUT.
The PAI will be executed only if the value in is
not equal to its initial value.
The ON INPUT addition must be used with a FIELD statementbecause this condition depends on the value of a particular field.
ON REQUEST
7/22/2019 Module Pool Training Presentation
77/123
India SAP CoE, Slide 77
ON REQUEST
With the ON REQUEST, a module will be executed only if a value has
been entered in the specified field since the screen was displayed.
The basic syntax for this conditional execution Flow Logic command is:
FIELD MODULE ON REQUEST.
The PAI will be executed only if a value was entered in since the screen was displayed.
The ON REQUEST addition must be used with a FIELD statementbecause this condition depends on the value of a particular field.
If you want to conditionally execute a module that is coded within aCHAIN ENDCHAIN, you must use ON CHAIN-REQUEST.
AT EXIT COMMAND
7/22/2019 Module Pool Training Presentation
78/123
India SAP CoE, Slide 78
AT EXIT-COMMAND
With the AT EXIT-COMMAND addition to theMODULE statement, a module will be executed only ifthe user invokes a function code with the E function type.
Function type assigning is explained in slide 73.
The basic syntax for this conditional execution Flow Logiccommand is:
MODULE AT EXIT-COMMAND.
AT EXIT COMMAND
7/22/2019 Module Pool Training Presentation
79/123
India SAP CoE, Slide 79
AT EXIT-COMMAND
The PAI will be executed only if the user invokes aFUNCTION type E.
The AT EXIT-COMMAND addition cannot be used with a
FIELD statement.
If the user invokes a type E function code, a module with the ATEXIT-COMMAND addition will be executed immediately.
It will be executed even before the automatic field checks.
A i i F ti t
7/22/2019 Module Pool Training Presentation
80/123
India SAP CoE, Slide 80
Assigning Function type
Function type can beassigned for screen
buttons and for menupainter keys.
In menu painter, clickon the required key.In the pop-up windowselect function type asE from drop down.
AT CURSOR SELECTION
7/22/2019 Module Pool Training Presentation
81/123
India SAP CoE, Slide 81
AT CURSOR-SELECTION
You can specify that a module should only be called if the cursor ispositioned on a particular screen element.
Syntax -MODULE AT CURSOR-SELECTION.
The module is called whenever the function code of the useraction 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.
AT CURSOR SELECTION
7/22/2019 Module Pool Training Presentation
82/123
India SAP CoE, Slide 82
AT CURSOR-SELECTION
You can also combine this MODULE statement with the FIELD
statement:
FIELD MODULE AT CURSOR-SELECTION.
For more than one field:
CHAIN.
FIELD: , ,...
MODULE AT CURSOR-SELECTION.
ENDCHAIN.
Modifying Screen Fields
7/22/2019 Module Pool Training Presentation
83/123
India SAP CoE, Slide 83
Modifying Screen Fields
All fields of the current screen are stored in the system table SCREENwith their attributes.
The LOOP AT SCREENstatement places this information in theheader line of the system table.
We can modify the attributes of the fields and update the screen tableusing MODIFY SCREEN.
Sample code:
loop at screen.
if screen-name = 'GV_MATNR'.
screen-input = 1.
modify screen.
endif.
endloop.
Modifying Screen Fields
7/22/2019 Module Pool Training Presentation
84/123
India SAP CoE, Slide 84
Modifying Screen Fields
You can dynamically modify the following attributes of a field: ACTIVE
REQUIRED
INPUT
OUTPUT
INTENSIFIED
INVISIBLE
LENGTH
DISPLAY 3D
VALUE HELP
A field attribute is turned on with a value of 1. It is turned off with avalue of 0.
The statements LOOP AT SCREEN ... ENDLOOP define a loop arounda statement block.
Logical Unit of Work (LUW)
7/22/2019 Module Pool Training Presentation
85/123
India SAP CoE, Slide 85
Logical Unit of Work (LUW)
LUW refers to a collection of actions performed at the database level as acomplete unit.
In this ex: LUW is selecting A and B from the database, updating A, anddeleting B.
This would be the desired LUW because we would want to rollback allchanges if any of these actions failed.
Screen2
Screen1
Screen3
SELECT A
SELECT BUPDATE A DELETE B
Database
Transaction
DatabaseTransaction
DatabaseTransaction
LUW
7/22/2019 Module Pool Training Presentation
86/123
India SAP CoE, Slide 86
LUW
Changes will be saved (commit work) in database at the end of thirdscreen.
An SAP LUW will end with either the COMMIT WORK orROLLBACK WORK statement.
A logical unit consisting of dialog steps, whose changes are written tothe database in a single database LUW is called an SAP LUW.
If an SAP LUW contains database changes, you should either write all ofthem or none at all to the database.
Include a database commit when the transaction has ended successfully,and a database rollback in case the program detects an error.
LUW
7/22/2019 Module Pool Training Presentation
87/123
India SAP CoE, Slide 87
LUW
Since database changes from a database LUW cannot be reversed in a
subsequent database LUW, you must make all of the database changes for
the SAP LUW in a single database LUW.
In our example, we need to perform UPDATE A and DELETE B at the
end of third screen.
SAP Locks
7/22/2019 Module Pool Training Presentation
88/123
India SAP CoE, Slide 88
SAP Locks
R/3 system contain lock mechanism for SAP LUWs called SAP Locks.
Lock object is created in ABAP Dictionary.
A lock object definition contains the database tables and their key fields
on the basis of which you want to set a lock.
System automatically generates two function modules with the namesENQUEUE_ and DEQUEUE_when a lock is generated.
Locks can be set and released on corresponding database table by callingthese function modules in program.
SAP Locks
7/22/2019 Module Pool Training Presentation
89/123
India SAP CoE, Slide 89
SAP Locks Consider below example,
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 clickson SAVE or when user clicks on BACK button.
Table Control
7/22/2019 Module Pool Training Presentation
90/123
India SAP CoE, Slide 90
Table Control
A table control is an area on the screen where the system displays data in atabular form. It is processed using a loop.
To create a table control, drag & drop table control from screen elementson screen painter. Give a name to table control.
Select the table definition and fields clicking on Dictionary/Programfields object button.
Each table control need to be declared in declaration part of the programas,
CONTROLS TYPE TABLEVIEW USING SCREEN .
where is the name of the table control on a screen.
Table Control
7/22/2019 Module Pool Training Presentation
91/123
India SAP CoE, Slide 91
Table Control
Youmustcode 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.
For this reason, at least an empty LOOP...ENDLOOP must be there.
7/22/2019 Module Pool Training Presentation
92/123
India SAP CoE, Slide 92
Processing Table Control
DatabaseScreen
Table Control
7/22/2019 Module Pool Training Presentation
93/123
India SAP CoE, Slide 93
Table Control
Sample code -
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
LOOP AT it_po INTO wa_ekpo WITH CONTROL tab2 CURSOR
tab2-current_line.
ENDLOOP.
PROCESS AFTER INPUT.
field po_no module po_check.
module exit_mod at exit-command.
MODULE USER_COMMAND_0100.loop at it_po.
endloop.
Subscreen
7/22/2019 Module Pool Training Presentation
94/123
India SAP CoE, Slide 94
Subscreen A subscreen is a screen that is displayed in a specified area of the main
screen.
A subscreen cannot be displayed by itself.
The subscreen displayed in the predefined area will depend on the usersrequest on the main screen.
Subscreen is used to vary the fields displayed on a screen. As anexample:
The main screen contains the customer number, name, and apredefined area for a subscreen.
One subscreen contains customer address information.
Another subscreen contains customer bank information.
Creating Subscreen
7/22/2019 Module Pool Training Presentation
95/123
India SAP CoE, Slide 95
Creating Subscreen In main screen,
In the screen layout, place the screen element subscreen on layout. You can set the length and width of the subscreen by double clicking
on subscreen.
Provide unique name to subscreen, save and activate it.
Subscreen
Creating Subscreen
7/22/2019 Module Pool Training Presentation
96/123
India SAP CoE, Slide 96
Creating Subscreen Create a subscreen
Create a screen as given in earlier slides. Screen type should be subscreen.
Specify the screen length and height as in main screen.
Save the subscreen and go to screen layout. Here subscreen are willbe displayed.
Creating Subscreen
7/22/2019 Module Pool Training Presentation
97/123
India SAP CoE, Slide 97
Creating Subscreen
User can design in the subscreen area as below,
Call subscreen in PBO
7/22/2019 Module Pool Training Presentation
98/123
India SAP CoE, Slide 98
Call subscreen in PBO
To include a subscreen in a predefined area on the main screen, use the
CALL SUBSCREEN statement in the main screens PBO event.
syntax :CALL SUBSCREEN INCLUDING .
: name of the subscreen area defined on the main screen. This
subscreen area will be the location of the subscreen. This cannot be
enclosed in single quotes.
: name of the program where the subscreen exists.
Call subscreen in PBO
7/22/2019 Module Pool Training Presentation
99/123
India SAP CoE, Slide 99
Call subscreen in PBO
: number of the subscreen to display in the subscreenarea.
The and can be literals (i.e. enclosed insingle quotes) or variables.
When the CALL SUBSCREEN statement is encountered in themain screens PBO event, the system executes the PBO event of thesubscreen. Then, the system returns to finish the PBO event of themain screen.
Call subscreen in PAI
7/22/2019 Module Pool Training Presentation
100/123
India SAP CoE, Slide 100
Call subscreen in PAI
If the subscreen contains any PAI code, use the CALL SUBSCREEN
statement in the PAI event of the main screen.
Syntax : CALL SUBSCREEN .
The is the name of the subscreen area defined on the mainscreen. This cannot be enclosed in single quotes.
The CALL SUBSCREEN statement must be used to invoke the PAIevent of the subscreen.
- When the CALL SUBSCREEN statement isencountered in the main screens PAI event, the systemexecutes the PAI event of the subscreen.
Call subscreen in PAI
7/22/2019 Module Pool Training Presentation
101/123
India SAP CoE, Slide 101
Call subscreen in PAI
Then, the system returns to finish the PAI event of the mainscreen.
Without this CALL SUBSCREEN statement in the PAI event ofthe main screen, the PAI event of the subscreen cannot be
processed by the system.
If the subscreen does not contain any PAI code, this CALLSUBSCREEN statement is notneeded in the PAI event of the mainscreen.
In both the PBO and PAI of the main screen, the CALL
SUBSCREEN statement cannot be used inside a LOOP or aCHAIN.
Subscreen Restrictions
7/22/2019 Module Pool Training Presentation
102/123
India SAP CoE, Slide 102
Subscreen Restrictions
The following ABAP/4 statements cannotbe used in a subscreens PBO
or PAI modules (instead, they must be used in the main screen):
SET PF-STATUS
SET TITLEBAR
SET SCREEN
LEAVE TO SCREEN
CALL SCREEN
Note: These ABAP/4 statements in a subscreen will pass a syntaxcheck; however, they will result in runtime errors.
Tab Strip Controls
7/22/2019 Module Pool Training Presentation
103/123
India SAP CoE, Slide 103
Tab Strip Controls
Each tab page consists of a tab title and a page area.
If the area occupied by the tab strip control is too narrow to display all of thetab titles, a scrollbar appears, allowing you to reach the titles that are not
displayed.
Tab strips allow users to access multiple sub screens on one normal screen.
This allows for a more intuitive user interface by logically separating the
information presented to the user into different headings. The user can sort through the information by clicking on a corresponding tab
A tab strip control is a screen objectconsisting of two or more pages.
Tab Strip Control components
7/22/2019 Module Pool Training Presentation
104/123
India SAP CoE, Slide 104
Tab Strip Control components
TabTtitle Tab PageTab Title Row
Scrolling
Tab Strip Control components
7/22/2019 Module Pool Training Presentation
105/123
India SAP CoE, Slide 105
Tab TitleTitle of the component to which user can
navigate. They are push buttons.
Tab title row - All tab titles will appear in a row.
Tab Page - A tab page contains a collection of fields that logicallybelong together. Tab pages are implemented using subscreens.
For designing and using tab strip controls, see Transaction BIBS.
Tab Strip Control components
Tab Strip Controls
7/22/2019 Module Pool Training Presentation
106/123
India SAP CoE, Slide 106
Tab Strip Controls
Tab strip controls allow you to place a series of screens belonging to an
application on a single screen, and to navigate between them easily.
From a technical point of view, a tab page is a sunscreen with a pushbutton
assigned to it, which is displayed as the tab title.
When you create a tab strip control, youmust: .
1. Define the tab area on a screen and the
tab titles.
2. Assign a subscreen area to each tab title.3. Program the screen flow logic.
4. Program the ABAP processing logic.
Tab Strip Controls
7/22/2019 Module Pool Training Presentation
107/123
India SAP CoE, Slide 107
Assigning a Subscreen Area to a Tab Title
1. Paging in the SAPgui
PROCESS BEFORE OUTPUT.
...CALL SUBSCREEN: area1 INCLUDING [prog1] dynp1,
area2 INCLUDING [prog2] dynp2,
area3 INCLUDING [prog3] dynp3,
...PROCESS AFTER INPUT.
...CALL SUBSCREEN: area1,
area2,
area3,
2. Paging on the application server
PROCESS BEFORE OUTPUT.
...
CALL SUBSCREEN area INCLUDING [prog] dynp.
...
PROCESS AFTER INPUT.
...
CALL SUBSCREEN area.
Tab Strip Controls
Tab Strip Controls
7/22/2019 Module Pool Training Presentation
108/123
India SAP CoE, Slide 108
Handling in the ABAP Program
Create a control for each control in the declaration part of your
program using the following statement:
CONTROLS ctrl TYPE TABSTRIP.
PROCESS BEFORE OUTPUT....
Assign the function code of the corresponding tab title to the
component Activetab:
ctrl-Activetab = fcode.
PROCESS AFTER INPUT
Activetabcontains the function code of the last active tab title on the
screen.
Tab Strip Controls
Tab Strip Controls
7/22/2019 Module Pool Training Presentation
109/123
India SAP CoE, Slide 109
Programming the Flow Logic
The flow logic is restricted to that necessary to include the appropriate
subscreen screens in the right subscreen areas.
Local Scrolling at the Front-endInclude subscreen screens in all of your subscreen areas in the
tab strip control.
PROCESS BEFORE OUTPUT.CALL SUBSCREEN: INCLUDING [] ,
INCLUDING [] ,
INCLUDING [] ,
PROCESS AFTER INPUTCALL SUBSCREEN: ,
,
,
Tab Strip Controls
Tab Strip Controls
7/22/2019 Module Pool Training Presentation
110/123
India SAP CoE, Slide 110
Programming the Flow Logic
The flow logic is restricted to that necessary to include the appropriate
subscreen screens in the right subscreen areas.
Scrolling at the Application ServerInclude one subscreen at a time in a single subscreen area.
PROCESS BEFORE OUTPUT.
CALL SUBSCREEN < subscreen_area> INCLUDING [] .
PROCESS AFTER INPUT
CALL SUBSCREEN < subscreen_area>.
ab St p Co t o s
Step loops
7/22/2019 Module Pool Training Presentation
111/123
India SAP CoE, Slide 111
p p
Step loops are considerable less flexible than table controls.
Used to group screen elements together. A step loop is a repeated series
of loop blocks. A loop block consists of one or more loop lines of
graphical screen elements.
Loop blocs can be defined as fixed or variable.
In a fixed loop, the lower limit of the loop area always remains as
originally defined.
For a variable loop, the number of repetitions is adjusted dynamically
in the screen program to suit the size of the current window.
Creating a Step loop
7/22/2019 Module Pool Training Presentation
112/123
India SAP CoE, Slide 112
g p p
Open a screen in the layout editor.
In one or more lines, create the elements you want to repeat.
Select all the elements on the desired line(s) as a group.
Choose EditGroupingStep loopDefine.
Your element lines now make up a single step loop block. The blockincludes the original elements with their attributes and a predefined numberof repetition blocks.
Each repetition contains a copy of the first block without attributes.
The repetition blocks are consecutively numbered, so that you can establisha reference to a particular line.
Step loops
7/22/2019 Module Pool Training Presentation
113/123
India SAP CoE, Slide 113
p p To use a Step-Loop block in an online program, you must create one work
area for the Step-Loop block. To hold all the lines of a Step-Loop block in
the programs memory area, use an internal table.
Ex:-TYPES: BEGIN OF TY_REC,
MATNR TTPE MARA-MATNR,
MATKL TYPE MARA-MATKL,
END OF TY_REC.DATA: GT_MARA TYPE TABLE OF TY_REC WITH
HEADER LINE.
For Step loop the flow logic statement loop must be coded in both PBO andPAI event. One form of the Flow Logic LOOP statement is;
LOOP.. . . . . .
ENDLOOP.
Main screen Flow logic
7/22/2019 Module Pool Training Presentation
114/123
India SAP CoE, Slide 114
g
Main screen flow logic for calling subscreen.
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
call subscreen SUB1 including 'Z_MODULE_TRAINING' '0110'.
PROCESS AFTER INPUT.
call subscreen SUB1.
MODULE USER_COMMAND_0100.
Additions with ABAP OOPS
7/22/2019 Module Pool Training Presentation
115/123
India SAP CoE, Slide 115
Enjoy SAP controls (ALV Grid , ALV Tree, HTML controls etc) can be
displayed in screen.
To place these grids we need to have screen element Custom Control
placed on the screen.
Also we need to have ABAP OOPS knowledge. ( Refer package SLIS
for examples)
Process on Help
7/22/2019 Module Pool Training Presentation
116/123
India SAP CoE, Slide 116
p
This event is a user programmed help.
If the user presses the F1 key with the cursor is positioned in , the will be displayed along withthe data elements short text and documentation.
The only other Flow Logic statement that can be used in the POH eventis:
FIELD MODULE .
Process on Value
7/22/2019 Module Pool Training Presentation
117/123
India SAP CoE, Slide 117
This event is a user-programmed help that occurs when the user pressesF4 with the cursor positioned on a screen field.
The modules specified in the subsequent FIELD statement is called
instead of the SAP help.
Syntax is:
FIELD MODULE .
Module pool programming
7/22/2019 Module Pool Training Presentation
118/123
India SAP CoE, Slide 118
1 PrepareMe
2 Syntax Description
3 Demonstration
4 Exercises
5 HelpMe
Introduction
Demonstration
7/22/2019 Module Pool Training Presentation
119/123
India SAP CoE, Slide 119
Please refer the attached document for demo example.
Module pool programming
7/22/2019 Module Pool Training Presentation
120/123
India SAP CoE, Slide 120
p p g g
1 Introduction
2 Syntax Description
3 Demonstration
4 Exercises
5 HelpMe
Exercises
7/22/2019 Module Pool Training Presentation
121/123
India SAP CoE, Slide 121
Please refer the attached documents for hands-on. Exercise 1This covers input/output, radio button, table control, screen
navigation, flow logic events, Menu painter.
Exercise 2This covers tab strip, subscreen, table control, 4 flow logic
events, screen navigation, menu painter.
Module pool programming
7/22/2019 Module Pool Training Presentation
122/123
India SAP CoE, Slide 122
p p g g
1 Introduction
2 Syntax Description
3 Demonstration
4 Exercises
5 HelpMe
HelpMe
7/22/2019 Module Pool Training Presentation
123/123
Referhelp.sap.com
Refer Transaction code ABAPDOCU(check in drop down ABAP User
Dialogs) for documentation and examples
For screen elements and controls (table control, tabstrip) refer transaction
BIBS.
Refer package SLIS for examples of ALV grids, ALV Tree.