Você está na página 1de 23

IBM Global Business Services

Welcome

Online Programming Example

IBM Corporation 2013

Course Title
IBM Global Business Services

Module 2: Online Programming Example

(Optional client
logo can
be placed here)

IBM Corporation 2013

IBM Global Business Services

Housekeeping

Breaks
Washrooms
Transportation / parking
No pagers or cell phones
Participation
Parking lot issues
Questions

Online Programming Example

IBM Corporation 2013

IBM Global Business Services

Module objectives
At the completion of the module, the participants should be able to:
Create an Online program
Use the object navigator
Maintain the Screen attributes, Screen layout, Field attributes, Flow logic,
ABAP modules, and Global data
Recognize screen to program data transport
Execute an Online program

Online Programming Example

IBM Corporation 2013

IBM Global Business Services

Module agenda
This module deals with the following topics:
Creating an Online program
Object Navigator
Online Program Components
Screen Attributes
Screen Layout
Field Attributes
Flow Logic
ABAP modules
Global data
Screen to Program Data Transport
Executing an Online Program

Online Programming Example

IBM Corporation 2013

IBM Global Business Services

Overview
In this module, we will create a simple Online program. This program will calculate a
players scoring average.

Online Programming Example

IBM Corporation 2013

IBM Global Business Services

Creating an Online program


Online program name
must begin with SAPM
and then either a Y or Z.

Title
With TOP INCL.
should be checked.

Type MODULE

Go back to Repository
Browser, not source
code.
7

Application

Online Programming Example

IBM Corporation 2013

IBM Global Business Services

Object Navigator

Main Program
** SAPMY220_PLAYER_AVG **
INCLUDE MY220_PLAYER_AVGTOP.
Top Include
** MY220_PLAYER_AVGTOP - Include Program **
PROGRAM SAPMY220_PLAYER_AVG.

Online Programming Example

IBM Corporation 2013

IBM Global Business Services

Online Program Components


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.

Enter a screen number


and click on the
Create(F5)
pushbutton.

Online Programming Example

IBM Corporation 2013

IBM Global Business Services

Screen Attributes
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.
Screen Painter
Screen Attributes

10

Short Description

Screen Type

Next Screen

Required

Required

Optional

Online Programming Example

IBM Corporation 2013

IBM Global Business Services

Screen Layout
Screen Painter
Fullscreen Editor

Text fields are


created with
character
strings.

Use an
underscore to
link words into
one text field.

11

Player_Average
Total_Points ______
Total_Games ______
Input / output
templates are
created with
underscores.
Online Programming Example

IBM Corporation 2013

IBM Global Business Services

Field Attributes
Screen Painter
Element List

Field name,
not text
12

Field format
Online Programming Example

Input and output


turned on
IBM Corporation 2013

IBM Global Business Services

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.
Screen Painter
Flow Logic
Screen 9000
Flow
Logic
Command

PROCESS BEFORE OUTPUT.


MODULE INITIALIZE.
PROCESS AFTER INPUT.
MODULE CALCULATE.

13

Online Programming Example

ABAP module to clear


all fields before
screen is displayed.
ABAP module to
calculate average
after user has entered
values and clicked
Enter.
IBM Corporation 2013

IBM Global Business Services

ABAP modules
Main Program

PBO Module

** SAPMYOP_PLAYER_AVG **
INCLUDE MYOP_PLAYER_AVGTOP.

** MYOP_PLAYER_AVGO01 - Include
Program **

INCLUDE MYOP_PLAYER_AVGO01.

MODULE INITIALIZE OUTPUT.

INCLUDE MYOP_PLAYER_AVGI01.

CLEAR: POINTS, GAMES, AVERAGE


ENDMODULE.
PAI Module

The fields POINTS, GAMES,


and AVERAGE need to be
defined as global data.

** MYOP_PLAYER_AVGI01 - Include Program **


MODULE CALCULATE INPUT.
CHECK GAMES <> 0.
AVERAGE = POINTS / GAMES.
ENDMODULE.

14

Online Programming Example

IBM Corporation 2013

IBM Global Business Services

Global data
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 that automatic data
transport will occur between the
Screen Work Area and Program
Work Area.

Top Include
** MYOP_PLAYER_AVGTOP - Include Program **
PROGRAM SAPMYOP_PLAYER_AVG.
DATA:

POINTS TYPE I,
GAMES TYPE I,
AVERAGE TYPE P
DECIMALS 2.

15

Online Programming Example

IBM Corporation 2013

IBM Global Business Services

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.

16

Online Programming Example

IBM Corporation 2013

IBM Global Business Services

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.

Transaction Code

Transaction Text

Program Name

Initial Screen

Required

Required

Required

SAPMY220_PLAYER_AVG

17

Online Programming Example

9000

IBM Corporation 2013

IBM Global Business Services

Demonstration / Practice
For 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.

18

Online Programming Example

IBM Corporation 2013

IBM Global Business Services

Summary of the lesson learnt so far


Let us summarize what we have learnt so far:
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 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.
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.
19

Online Programming Example

IBM Corporation 2013

IBM Global Business Services

Summary of the lesson learnt so far (continued)


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.

20

Online Programming Example

IBM Corporation 2013

IBM Global Business Services

Answer a few questions


Screen 9000

Screen 9001

PROCESS BEFORE OUTPUT.

PROCESS BEFORE OUTPUT.

MODULE INITIALISE.

MODULE CALCULATE.

PROCESS AFTER INPUT.

PROCESS AFTER INPUT.

MODULE CALCULATE.

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?

21

Online Programming Example

IBM Corporation 2013

IBM Global Business Services

Module summary
Now that we have completed this module, we should be able to:
Create an Online program
Use the object navigator
Maintain the Screen attributes, Screen layout, Field attributes, Flow logic,
ABAP modules and Global data
Recognize screen to program data transport
Execute an Online program

22

Online Programming Example

IBM Corporation 2013

IBM Global Business Services

Thank You

23

Online Programming Example

IBM Corporation 2013

Você também pode gostar