AB1011-Module pool Programming- v1.0
Module pool programming
1
Introduction
2
Syntax Description
3
Demonstration
4
Exercises
5
HelpMe
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.
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 the system. But sometimes, the need to create a customer specific transaction arise due to following reasons :
A transaction (also called module pool programs, dialog programs) is defined as a collection of screens (the actual, physical image that the users sees), their Flow Logic (code behind the screens ), and the code within the main ABAP program.
Creating an Online Program
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.
Module Pool Program Components
Top Include
PBO Modules
PAI Modules
ABAP
Subroutines
Module Pool Program
Transaction Code
Transaction Text
F8
Program Name
Initial Screen
required
required
required
Executing an Online Program
Module pool programming
1
Introduction
2
Syntax description
3
Demonstration
4
Exercises
5
HelpMe
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.
Tools used:
Creating a Program
Program Structure
Assigning transaction code
Use of Screen
Screen Painter
Overview of Screen Painter
Screen Painter
Screen Attributes
Screen �Layout
Field Attributes
Flow Logic
Developing Screen
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 9000 are reserved for SAP screens, numbers between 9000 and 9500 are reserved for SAP partners, and numbers greater than 9500 are for customers.
Developing Screen
Developing Screen
Enter description and save.� Check the screen and activate it.
Screen Attributes
Screen Attributes
Screen Type –
Settings
Screen Attributes
Settings
Other Attributes
Screen Attributes
Other Attributes
Occupied – Specifies the size of the screen area currently occupied with screen elements
Maintained – Size of the screen in rows/columns.
Screen Layout Mode
The Screen Painter has a layout editor that you use to design your screen layout.
It works in two modes:
Both modes offer the same functions but use different interfaces. Graphical mode of screen designing is commonly used.
Screen Designing
Components of Layout Editor
Radio Button
Creating Radio Button
Defining Radio Button Group
Assign Radio Buttons into one Group.
Select the Radio Buttons and Follow the steps.
Check Box
Creating Check Box
Name the Check box
Screen Components
Screen Elements
Screen elements are,
� 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. �
Screen Elements
Push Button –
Screen Elements
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
Once screen is designed, it should be saved and checked for errors and activated. Screen looks as below,
Input Box
Testing Screen
Testing Screen
Flow Logic
Menu Painter
PROCESS BEFORE OUTPUT.
MODULE STATUS_0400.
PROCESS AFTER INPUT.
* MODULE USER_COMMAND_0400.
Menu Painter
*&---------------------------------------------------------------------*
*& Module STATUS_0400 OUTPUT
*&---------------------------------------------------------------------*
module STATUS_0400 output.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
Menu Painter
Menu Painter
Menu Painter
Creating Menu bar
Creating Application Tool bar
Assigning function keys
Execution
Execution
More on Flow Logic
(e.g., IF … ENDIF is not valid in Flow Logic).
More on Flow Logic
Keywords supported
Stops processing a screen table
ENDLOOP
Starts processing a screen table
LOOP
Calls a sub screen
CALL
Ends a processing chain
ENDCHAIN
Starts a processing chain
CHAIN
Used in conjunction with FIELD
VALUES
Used in conjunction with FIELD
ON
Specifies the point at which the contents of a screen field should be transported
FIELD
Calls a dialog module in an ABAP program
MODULE
Function
Keyword
PBO Event
MODULE STATUS_<screen number>
Ex:-MODULE STATUS_0100.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
module STATUS_0100 output.
* SET PF-STATUS ‘XXX'.
* SET TITLEBAR 'xxx'.
endmodule. " STATUS_0100 OUTPUT
PBO Event
Menu Bar-
SET PF-STATUS 'STATUS100'.
PBO Event
Title Bar
SET TITLEBAR 'TITLE100'.
PAI Event
MODULE USER_COMMAND_<screen number>.
Ex:- MODULE USER_COMMAND_0100.
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
Includes
Includes
Includes
Message Statement
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.
Message Types
The message type determines where the message is displayed and what action the user can or must take on the current screen.
I
Messages
Messages
Messages
Handling Error messages
FIELD with select statement
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
Error for invalid input
FIELD with Values Check
PROCESS AFTER INPUT.
field PO_NO values ('1', '100').
Values option
CHAIN Statement
CHAIN.� FIELD: <f1>, <f 2>,... � MODULE <mod1>. � FIELD: <g1>, <g 2>,... � MODULE <mod2>. � ...� ENDCHAIN.
Cursor Position
1. By setting the cursor position in PBO event-
Syntax - SET CURSOR FIELD <field name>
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 .
Screen commands
<screen #>.
Screen commands
More on PAI modules
All modules listed in the PAI event get executed from top to bottom.
ON INPUT
ON REQUEST
FIELD <screen field> MODULE <module> ON REQUEST.
AT EXIT-COMMAND
MODULE <module> AT EXIT-COMMAND.
AT EXIT-COMMAND
Assigning Function type
AT CURSOR-SELECTION
AT CURSOR-SELECTION
FIELD <f> MODULE <mod> AT CURSOR-SELECTION.
CHAIN.� FIELD: <f1>, <f 2>,... � MODULE <mod> AT CURSOR-SELECTION.�ENDCHAIN.
Modifying Screen Fields
loop at screen.
if screen-name = 'GV_MATNR'.
screen-input = 1.
modify screen.
endif.
endloop.
Modifying Screen Fields
Logical Unit of Work (LUW)
Screen
2
Screen
1
Screen
3
SELECT A
SELECT B
UPDATE A
DELETE B
Database
Transaction
Database
Transaction
Database
Transaction
LUW
LUW
SAP Locks
SAP Locks
Table Control
CONTROLS <ctrl> TYPE TABLEVIEW USING SCREEN <scr>.
where <ctrl> is the name of the table control on a screen.
Table Control
Processing Table Control
Database
Internal Table with header
Screen
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
Creating Subscreen
Subscreen
Creating Subscreen
Creating Subscreen
Call subscreen in PBO
Call subscreen in PBO
Call subscreen in PAI
- When the “CALL SUBSCREEN” statement is encountered in the “main” screen’s PAI event, the system executes the PAI event of the subscreen.
Call subscreen in PAI
Subscreen Restrictions
Tab Strip Controls
A tab strip control is a screen object consisting of two or more pages.
Tab Strip Control components
TabTtitle
Tab Page
Tab Title Row
Scrolling
Tab Strip Control components
navigate. They are push buttons.
Tab Strip Controls
When you create a tab strip control, you must: ……….
Tab Strip Controls
Assigning a Subscreen Area to a Tab Title
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
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
…
Activetab contains the function code of the last active tab title on the screen.
Tab Strip Controls
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-end
Include subscreen screens in all of your subscreen areas in the
tab strip control.
PROCESS BEFORE OUTPUT.�CALL SUBSCREEN: <subscreen_area1> INCLUDING [<progname 1>] <subscreen_scrn 1>, � <subscreen_area2> INCLUDING [<progname 2>] <subscreen_scrn 2>, � <subscreen_area3> INCLUDING [<progname 3>] <subscreen_scrn 3>,
PROCESS AFTER INPUT
CALL SUBSCREEN: <subscreen_area1>, � <subscreen_area2>, � <subscreen_area3>,
Tab Strip Controls
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 Server
Include one subscreen at a time in a single subscreen area.
PROCESS BEFORE OUTPUT.�CALL SUBSCREEN < subscreen_area> INCLUDING [<progname>] <subscreen_scrn>.
PROCESS AFTER INPUT
CALL SUBSCREEN < subscreen_area>.
Step loops
Creating a Step loop
Step loops
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.
LOOP.
. . . <flow logic statements> . . .
ENDLOOP.
Main screen Flow logic
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
Process on Help
FIELD <screen field> MODULE <module>.
Process on Value
FIELD <screen field> MODULE <module>.
Module pool programming
1
PrepareMe
2
Syntax Description
3
Demonstration
4
Exercises
5
HelpMe
Introduction
Demonstration
Please refer the attached document for demo example.
Module pool programming
1
Introduction
2
Syntax Description
3
Demonstration
4
Exercises
5
HelpMe
Exercises
Please refer the attached documents for hands-on.
Module pool programming
1
Introduction
2
Syntax Description
3
Demonstration
4
Exercises
5
HelpMe
HelpMe