Sei sulla pagina 1di 19

IBM Global Services

2005 IBM Corporation Online Programming Example | 6.02 March-2005


Online Programming Example
IBM Global Services
2005 IBM Corporation 2 March-2005 Online Programming Example | 6.02
Objectives
The participants will be able to:
Create an online program
Use the object navigator
Maintain the
Screen attributes
Screen layout
Field attributes
Flow logic
ABAP modules
Global data
Recognize screen to program data transport
Execute an online program
IBM Global Services
2005 IBM Corporation 3 March-2005 Online Programming Example | 6.02
Overview
In this chapter, we will create a simple online program. This program will
calculate a players scoring average.

IBM Global Services
2005 IBM Corporation 4 March-2005 Online Programming Example | 6.02
Creating an Online Program
Online program name
must begin with SAPM
and then either a Y or
Z.
Go back to Repository
Browser, not source
code.
With TOP INCL.
should be checked.
Title
Type MODULE
Application
IBM Global Services
2005 IBM Corporation 5 March-2005 Online Programming Example | 6.02
Object Navigator
Main Program
** SAPMY220_PLAYER_AVG **
INCLUDE MY220_PLAYER_AVGTOP.
Top Include
** MY220_PLAYER_AVGTOP - Include Program **
PROGRAM SAPMY220_PLAYER_AVG.
IBM Global Services
2005 IBM Corporation 6 March-2005 Online Programming Example | 6.02
Enter a screen number
and click on the
Create(F5)
pushbutton.
In the online programs hierarchy list in the Object Navigator, double-click on the
program name and then single click on the icon other objects(shift+F5)
application toolbar to create program components.
Online Program Components
IBM Global Services
2005 IBM Corporation 7 March-2005 Online Programming Example | 6.02
Screen Attributes
Screen Attributes
Screen Painter
Short Description Screen Type Next Screen
Required Required Optional
For each screen you create, you must maintain the Screen Attributes in the
Screen Painter. There are two required fields in the Screen Attributes section.
IBM Global Services
2005 IBM Corporation 8 March-2005 Online Programming Example | 6.02
Screen Layout
Fullscreen Editor

Player_Average

Total_Points ______

Total_Games ______
Input/output
templates are
created with
underscores.
Use an
underscore to
link words into
one text field.
Screen Painter
Text fields are
created with
character
strings.
IBM Global Services
2005 IBM Corporation 9 March-2005 Online Programming Example | 6.02
Field Attributes
Element List
Field name,
not text
Field format
Input and output
turned on
Screen Painter
IBM Global Services
2005 IBM Corporation 10 March-2005 Online Programming Example | 6.02
Flow Logic
Screen Painter

PROCESS BEFORE OUTPUT.
MODULE INITIALIZE.

PROCESS AFTER INPUT.
MODULE CALCULATE.
Flow
Logic
Command
ABAP module to clear
all fields before
screen is displayed.
ABAP module to
calculate average
after user has entered
values and clicked
Enter.
Screen 9000
Flow Logic
The Flow Logic refers to the code behind the screens and it is maintained in the
Screen Painter. Each screen has its own Flow Logic which is divided into two
main events PBO AND PAI.
IBM Global Services
2005 IBM Corporation 11 March-2005 Online Programming Example | 6.02
** SAPMYOP_PLAYER_AVG **
INCLUDE MYOP_PLAYER_AVGTOP.
INCLUDE MYOP_PLAYER_AVGO01.
INCLUDE MYOP_PLAYER_AVGI01.
ABAP Modules
Main Program
PBO Module
** MYOP_PLAYER_AVGO01 - Include
Program **
MODULE INITIALIZE OUTPUT.
CLEAR: POINTS, GAMES, AVERAGE
ENDMODULE.
PAI Module
** MYOP_PLAYER_AVGI01 - Include Program **
MODULE CALCULATE INPUT.
CHECK GAMES <> 0.
AVERAGE = POINTS / GAMES.
ENDMODULE.
The fields POINTS, GAMES,
and AVERAGE need to be
defined as global data.

IBM Global Services
2005 IBM Corporation 12 March-2005 Online Programming Example | 6.02
Global Data
Top Include
** MYOP_PLAYER_AVGTOP - Include Program **
PROGRAM SAPMYOP_PLAYER_AVG.
DATA: POINTS TYPE I,
GAMES TYPE I,
AVERAGE TYPE P
DECIMALS 2.
Main Program
** SAPMYOP_PLAYER_AVG **
INCLUDE MYOP_PLAYER_AVGTOP.
INCLUDE MYOP_PLAYER_AVGO01.
INCLUDE MYOP_PLAYER_AVGI01.
It is important that these program
fields are named the same as the
screen fields so automatic data
transport will occur between the
screen work area and program
work area.

IBM Global Services
2005 IBM Corporation 13 March-2005 Online Programming Example | 6.02
Screen to Program Data Transport
When the PAI event is triggered, values are
transported from the screen work area to
the program fields with the same names
before any PAI modules are executed.
IBM Global Services
2005 IBM Corporation 14 March-2005 Online Programming Example | 6.02
Transaction Code
Transaction Text Program Name Initial Screen
Required Required Required
Executing an Online Program
To execute an online program, you must create a transaction code. You cannot
use the F8 key or Program > Execute menu path to execute an online program.
SAPMY220_PLAYER_AVG 9000
IBM Global Services
2005 IBM Corporation 15 March-2005 Online Programming Example | 6.02
Demonstration
Creation of an online program to display a players scoring average.
Two screens are required to be created for this program .
The first screen takes the total points and the number of games as input.
The scoring average is output in the next screen.
IBM Global Services
2005 IBM Corporation 16 March-2005 Online Programming Example | 6.02
Practice
Creation of an online program to display a players scoring average.
Two screens are required to be created for this program .
The first screen takes the total points and the number of games as input.
The scoring average is output in the next screen.
IBM Global Services
2005 IBM Corporation 17 March-2005 Online Programming Example | 6.02
Summary
When you create an online program, its name must begin with SAPM and then
either a Y or Z. The last characters in the program SAPMzaaa... can be
letters or numbers.
The program type is M for module pool. This type M will automatically be
defaulted for you if your program name begins with SAPM.
In the Object Navigator, you can double-click on the online program name to see
the programs hierarchy of sub-objects (components). From this hierarchy list, you
can create all the components of the online program by double-clicking on the
Program object types branch (see next slide).
For each screen you create, you must maintain the Screen Attributes in the
Screen Painter.
You maintain the physical layout of a screen in the Fullscreen Editor of the
Screen Painter.
Use the Element List tab for the screen to name the screen fields.
IBM Global Services
2005 IBM Corporation 18 March-2005 Online Programming Example | 6.02
Summary (Contd.)
The Flow Logic refers to the code behind the screens and it is maintained in the
Screen Painter.
The PBO and PAI modules contain the main processing logic of the online
program and are called from within the Flow Logic of the screens with the
MODULE command.
The global data for an online program is declared in the Top Include program.
When the PAI event is triggered, values are transported from the screen work
area to the program fields with the same names before any PAI modules are
executed.
To execute an online program, you must create a transaction code. You cannot
use the F8 key or Program -> Execute menu path to execute an online
program.
IBM Global Services
2005 IBM Corporation 19 March-2005 Online Programming Example | 6.02
Questions

PROCESS BEFORE OUTPUT.
MODULE CALCULATE.

PROCESS AFTER INPUT.

Screen 9001

PROCESS BEFORE OUTPUT.
MODULE INITIALISE.

PROCESS AFTER INPUT.
MODULE CALCULATE.
Screen 9000
We could have calculated the players average in the PBO of screen 9001.
Why is it better to do the calculation in the PAI of screen 9000 instead of the
PBO of screen 9001?

Potrebbero piacerti anche