chapter 02_online programming example

Upload: raul-thomas

Post on 03-Jun-2018

226 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 Chapter 02_Online Programming Example

    1/19

    IBM Global Services

    2005 IBM CorporationOnline Programming Example | 6.02 March-2005

    Online Programming Example

  • 8/12/2019 Chapter 02_Online Programming Example

    2/19

    IBM Global Services

    2005 IBM Corporation2 March-2005Online 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

  • 8/12/2019 Chapter 02_Online Programming Example

    3/19

    IBM Global Services

    2005 IBM Corporation3 March-2005Online Programming Example | 6.02

    Overview

    In this chapter, we will create a simple online program. This program willcalculate a players scoring average.

  • 8/12/2019 Chapter 02_Online Programming Example

    4/19

    IBM Global Services

    2005 IBM Corporation4 March-2005Online 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

  • 8/12/2019 Chapter 02_Online Programming Example

    5/19

    IBM Global Services

    2005 IBM Corporation5 March-2005Online 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.

  • 8/12/2019 Chapter 02_Online Programming Example

    6/19

    IBM Global Services

    2005 IBM Corporation6 March-2005Online 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 theprogram name and then single click on the icon other objects(shift+F5)

    application toolbar to create program components.

    Online Program Components

  • 8/12/2019 Chapter 02_Online Programming Example

    7/19

    IBM Global Services

    2005 IBM Corporation7 March-2005Online 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 theScreen Painter. There are two required fields in the Screen Attributes section.

  • 8/12/2019 Chapter 02_Online Programming Example

    8/19

    IBM Global Services

    2005 IBM Corporation8 March-2005Online 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.

  • 8/12/2019 Chapter 02_Online Programming Example

    9/19

    IBM Global Services

    2005 IBM Corporation9 March-2005Online Programming Example | 6.02

    Field Attributes

    Element List

    Field name,

    not text FieldformatInput and output

    turned on

    Screen Painter

  • 8/12/2019 Chapter 02_Online Programming Example

    10/19

    IBM Global Services

    2005 IBM Corporation10 March-2005Online Programming Example | 6.02

    Flow Logic

    Screen Painter

    PROCESSBEFORE 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 theScreen Painter. Each screen has its own Flow Logic which is divided into two

    main events PBO AND PAI.

  • 8/12/2019 Chapter 02_Online Programming Example

    11/19

    IBM Global Services

    2005 IBM Corporation11 March-2005Online 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.

  • 8/12/2019 Chapter 02_Online Programming Example

    12/19

    IBM Global Services

    2005 IBM Corporation12 March-2005Online 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

    DECIMALS2.

    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.

  • 8/12/2019 Chapter 02_Online Programming Example

    13/19

    IBM Global Services

    2005 IBM Corporation13 March-2005Online 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

    beforeany PAI modules are executed.

  • 8/12/2019 Chapter 02_Online Programming Example

    14/19

    IBM Global Services

    2005 IBM Corporation14 March-2005Online 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 cannotuse the F8 key or Program > Execute menu path to execute an online program.

    SAPMY220_PLAYER_AVG 9000

  • 8/12/2019 Chapter 02_Online Programming Example

    15/19

    IBM Global Services

    2005 IBM Corporation15 March-2005Online 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.

  • 8/12/2019 Chapter 02_Online Programming Example

    16/19

    IBM Global Services

    2005 IBM Corporation16 March-2005Online 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.

  • 8/12/2019 Chapter 02_Online Programming Example

    17/19

    IBM Global Services

    2005 IBM Corporation17 March-2005Online Programming Example | 6.02

    Summary

    When you create an online program, its name must begin with SAPM and theneither 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 seethe 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.

  • 8/12/2019 Chapter 02_Online Programming Example

    18/19

    IBM Global Services

    2005 IBM Corporation18 March-2005Online Programming Example | 6.02

    Summary (Contd.)

    The Flow Logic refers to the code behind the screens and it is maintained in theScreen 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.

  • 8/12/2019 Chapter 02_Online Programming Example

    19/19

    IBM Global Services

    2005 IBM Corporation19 March-2005Online 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?