0% found this document useful (0 votes)
2 views

Chapter 02_Online Programming Example

This document provides a comprehensive guide on creating an online program in SAP, specifically focusing on calculating a player's scoring average. It covers essential components such as program naming conventions, screen attributes, flow logic, and the execution process. The guide emphasizes the importance of maintaining data transport between screens and program fields, as well as the necessity of creating a transaction code for execution.

Uploaded by

Aniruddha_Ghosh
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Chapter 02_Online Programming Example

This document provides a comprehensive guide on creating an online program in SAP, specifically focusing on calculating a player's scoring average. It covers essential components such as program naming conventions, screen attributes, flow logic, and the execution process. The guide emphasizes the importance of maintaining data transport between screens and program fields, as well as the necessity of creating a transaction code for execution.

Uploaded by

Aniruddha_Ghosh
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 19

IBM Global Services

Online Programming Example

Online Programming Example | Dec-2008 © 2005 IBM Corporation


IBM Global Services

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

2 Online Programming Example | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Overview

 In this chapter, we will create a simple online program. This program will
calculate a player’s scoring average.

3 Online Programming Example | Dec-2008 © 2005 IBM Corporation


IBM Global 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 Application
code.

4 Online Programming Example | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Object Navigator

Main Program

** SAPMY220_PLAYER_AVG **
INCLUDE MY220_PLAYER_AVGTOP.

Top Include

** MY220_PLAYER_AVGTOP - Include Program **


PROGRAM SAPMY220_PLAYER_AVG.

5 Online Programming Example | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Online Program Components


 In the online program’s 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.

6 Online Programming Example | Dec-2008 © 2005 IBM Corporation


IBM Global 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

Short Description Screen Type Next Screen

Required Required Optional

7 Online Programming Example | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Screen Layout

Screen Painter

Fullscreen Editor

Text fields are


Player_Average
created with
character
strings. Total_Points ______

Use an Total_Games ______


Input/output
underscore to templates are
link words into created with
one text field. underscores.

8 Online Programming Example | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Field Attributes

Screen Painter

Element List

Field name, Input and output


not text Field format
turned “on”

9 Online Programming Example | Dec-2008 © 2005 IBM Corporation


IBM Global 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 ABAP module to clear


PROCESS BEFORE OUTPUT.
Logic all fields before
MODULE INITIALIZE. screen is displayed.
Command

PROCESS AFTER INPUT. ABAP module to


MODULE CALCULATE. calculate average
after user has entered
values and clicked
‘Enter’.
10 Online Programming Example | Dec-2008 © 2005 IBM Corporation
IBM Global Services

ABAP Modules

Main Program PBO Module

** SAPMY220_PLAYER_AVG ** ** MY220_PLAYER_AVGO01 - Include


INCLUDE MY220_PLAYER_AVGTOP. Program **
INCLUDE MY220_PLAYER_AVGO01. MODULE INITIALIZE OUTPUT.
INCLUDE MY220_PLAYER_AVGI01. CLEAR: POINTS, GAMES, AVERAGE
ENDMODULE.

PAI Module

The fields POINTS, GAMES, ** MY220_PLAYER_AVGI01 - Include Program **


and AVERAGE need to be MODULE CALCULATE INPUT.
defined as global data.
CHECK GAMES <> 0.
AVERAGE = POINTS / GAMES.
ENDMODULE.

11 Online Programming Example | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Global Data

Main Program
It is important that these program
** SAPMY220_PLAYER_AVG ** fields are named the same as the
screen fields so automatic data
INCLUDE MY220_PLAYER_AVGTOP. transport will occur between the
INCLUDE MY220_PLAYER_AVGO01. screen work area and program work
INCLUDE MY220_PLAYER_AVGI01. area.

Top Include
** MY220_PLAYER_AVGTOP - Include Program **
PROGRAM SAPMY220_PLAYER_AVG.
DATA: POINTS TYPE I,
GAMES TYPE I,
AVERAGE TYPE P
DECIMALS 2.

12 Online Programming Example | Dec-2008 © 2005 IBM Corporation


IBM Global 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.

13 Online Programming Example | Dec-2008 © 2005 IBM Corporation


IBM Global 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 9000

14 Online Programming Example | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Demonstration

 Creation of an online program to display a player’s 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.

15 Online Programming Example | Dec-2008 © 2005 IBM Corporation


IBM Global Services

Practice

 Creation of an online program to display a player’s 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.

16 Online Programming Example | Dec-2008 © 2005 IBM Corporation


IBM Global Services

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 program’s 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.

17 Online Programming Example | Dec-2008 © 2005 IBM Corporation


IBM Global Services

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.

18 Online Programming Example | Dec-2008 © 2005 IBM Corporation


IBM Global Services

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 player’s 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?

19 Online Programming Example | Dec-2008 © 2005 IBM Corporation

You might also like