You are on page 1of 49

Chapter 12 Introduction to Dialog Programming

Overview and interaction of com ponents


Basic techniques of dialog programming
Defining interfaces with the M enu Painter

SAP AG
Chapter 12 Objectives

Interaction of screen and ABAP/4 module pool


Components of the Screen Painter
Options for field input checking
Dynamic screen flow control
Creating GUI title and GUI status
Basis ergonom ic guidelines

SAP AG
The Main Components of a Dialog Program
Development environm ent

ABAP/4 Screen Menu


ABAP/4
Dictionary Painter Painter

Runtime environm ent

Dialog processor ABAP/4 processor

SAP AG

You use the Screen Painter and the Menu Painter to create and design screen templates and screen
programs.
You define the processing logic in an ABAP/4 program (module pool).
Data structures are defined in the ABAP/4 Dictionary. You can access these structures from the
ABAP/4 program and when defining screen fields.
The dialog processor controls the flow of your dialog program.
Screen Painter ABAP/4

Screen
Painter
Screen Screen Field
attributes layout attributes Flow logic
Screen no. 100 PROCESS BEFORE OUTPUT.
NUM BER
Short text Test Num ber: MODULE INIT.
CHA R
Screen type Normal
10 characters
Next screen 200
Input x PROCESS AFTER INPUT.
...
... MODULE READ.

ABAP/4

Global data PBO modules PAI modules


DATA: NUMBER(10) MODULE INIT OUTPUT. MODULE READ INPUT.
TYPE C. CLEAR NUMBER. SELECT ...
. ENDMODULE. .
.
. . .
ENDMODULE.
. . .
. .
.

SAP AG

To create a screen, take the following steps:


Define the basic features of a screen (screen attributes)
Design the screen layout (in the fullscreen editor)
Define the field attributes (field list)
Write the screen flow logic
The most important ABAP/4 program components are found in the following objects:
Global data or Dictionary structures in the TOP include program (data declarations)
PBO (Process Before Output) module
PAI (Process After Input) module
Subroutines (if required)
Communication: Screen ABAP/4 Module Pool
Screen PROCESS
PROCESS BEFORE
BEFORE OUTPUT.
OUTPUT. PROGRAM
PROGRAM SAPMTALA
SAPMTALA MESSAGE-ID
MESSAGE-ID AT.
AT. ABAP/4
Painter 1 TABLES
TABLES SPFLI.
SPFLI.
MODULE
MODULE INITIALIZE.
INITIALIZE.
MODULE
MODULE INITIALIZE
INITIALIZE OUTPUT.
OUTPUT.
2 CLEAR
CLEAR SPFLI.
SPFLI.
ENDMODULE.
ENDMODULE.
MODULE
MODULE READ_SPFLI
READ_SPFLI INPUT.
INPUT.
PROCESS
PROCESS AFTER
AFTER INPUT.
INPUT. 1 SELECT
SELECT SINGLE
SINGLE ** FROM
FROM SPFLI
SPFLI
MODULE
MODULE READ_SPFLI.
READ_SPFLI. WHERE
WHERE ......
..
MODULE
MODULE ...
... 2 ..
..
.. ENDMODULE.
.. ENDMODULE.

1 Control passes from the dialog processor to the ABAP/4 processor


2 Control passes from the ABAP/4 processor to the dialog processor
Screen
Screen work area M odule pool work area ABAP/4
Painter
SPFLI-CARRID TABLES: SPFLI.
LH LH 0400
PBO CARRID CONNID
SPFLI-CONNID
0400 DATA: OK-CODE(4).
PAI
OK-CODE

II D
DEEN
N TT II C
CAA LL N
NAAM
MEES
S
SAP AG

The screen flow logic is divided into two events for each screen:
The PROCESS BEFORE OUTPUT event (PBO) is executed before the screen is displayed.
The PROCESS AFTER INPUT event (PAI) is executed after the user has pressed ENTER.
The system processes the modules in an event sequentially.
In each module, control passes from the dialog processor to the ABAP/4 processor. After processing,
control is returned to the dialog processor.
When all the PBO modules have been processed, the contents of fields in the ABAP/4 work area are
copied to the identically named fields in the screen work area.
Before the PAI module is processed, the contents of fields in the screen work area are copied to the
identically named fields in the ABAP/4 work area.
Overview: Creating a Dialog Program

Airline carrier LH

Flight number 0400

...
Planned flight
From FRANKFURT
To NEW YORK
Tim e 08:24:00
...

SAP AG

In the following, we are going to create a dialog program which displays a planned flight connection.
On the first screen, the user can enter the key of the planned flight connection. On the second screen,
the system displays the contents of the corresponding entry in table SPFLI.
Creating Programs
Development class Edit
Program
Functional area
Local private objects

$TMP Local objects of the user

Create

Programs
..
.

Choose

Program SAPMTALA
with TOP Include

SAP AG

Create your program (ABAP/4 module pool) in the ABAP/4 Development Workbench.
The TOP include program initially includes just the PROGRAM statement. To this, you add all the
data declarations (global data).
If you are using includes, the system proposes names formulated according to a particular rule. The
first three bytes of the ABAP/4 module pool name are removed and the string starting from the fourth
byte is moved three bytes to the left. In the three free bytes at the end, the system then adds characters
which are appropriate for the include.

Example: The name of the TOP include for the ABAP/4 module pool SAPMTALA is MTALATOP.
Note:
In this chapter, create all of your objects as local private objects
Program Attributes

Title
Test
Type M
Application S

Save

SAP AG

In the program attributes, you maintain the title, the program type and the application. For program
type, enter the value M (module pool). Select S (Basis Component) as the application.
Defining Screens

$TMP User's local objects

programs
SAPMTALA

Create ..
.
screens
..
.

Choose Program SAPMTALA


Screen no. 100

Continue Screen Attributes


Short description Test
Screen type
Normal
..
.
Next screen 200
SAP AG

Create the relevant screens for your module pool from the object list.
After you have entered the screen number, the system branches to the screen attribute maintenance.
Enter a short description, select the screen type Normal and specify the number of the follow-up
screen
Using ABAP/4 Dictionary Fields

Fullscreen Dict/ProgFields

Dict/ProgFields

Get from Dict.


Table/field name
Get from program

Field Form at Length Shrt text Template

Key word
- short
- m edium
- long
- header

Copy

SAP AG

Generally, you define screen fields by using existing ABAP/4 Dictionary field attributes.
You can also use field attributes already stored in the module pool. To do this, a generated version of
the module pool must exist.
You can copy the field texts and the output templates individually or together.
Screen Layout (Graphical Screen Painter)

Field
Field attr.
attr. Dict./prog.fields
Dict./prog.fields Field
Field list
list

Text
Text

Entry
Entry

Check
Check
Airline carrier
Radio
Radio
Connection number
Box
Box

SAP AG

To design screens, you use the Screen Painter.


The interface of the graphical Screen Painter contains easy-to-use functions for defining the various
screen elements (e.g. input/output fields, field texts, boxes, etc.). You choose each screen element and
position it on the screen using the mouse.
To delete screen elements, you select the element with the mouse and then choose Delete.
To move screen elements, you use the mouse to drag the element to the required position.
Note:
From Release 3.0, the graphical Screen Painter is supported by Windows NT, Windows 95 and
UNIX.
If you are using other operating systems, you use the alphanumeric Screen Painter.
Alphanumeric Screen Painter

Dict./program fields Attributes G raphical elem ent Select

Airline carrier__________ ___


Connection number_____ ___

SAP AG

The alphanumeric Screen Painter provides the same functionality as the graphical Screen Painter to
design the layout of your screens.
In the alphanumeric fullscreen editor, you enter underscores for input/output fields.
For radio buttons and checkboxes, you first define an one-byte long input/output field and then enter
a field text.
After maintaining the field list, you define both fields as a graphical element.
To create a group box, enter a title and then choose a graphical element and a group box.
Field List Views

Matchcode/reference

Modification groups

Display attributes

General attributes

Texts/templates

Field types

SPFLI-CARRID
SPFLI-CARRID
.
.
.

SAP AG

There are six field list views available for maintaining the screen field attributes. Alternatively, you
can define them from one of the lists. Attribute maintenance for one field is also possible in the
fullscreen editor.
In the Screen Painter, you use external data types. The external data types of fields that you select
from the ABAP/4 Dictionary are displayed in the Format column. In the case of fields (templates)
that do not have any ABAP/4 Dictionary reference, you define an external data type yourself.
You can find out the correspondence of external data types to internal data types (i.e. ABAP/4 data
types) by referring to the documentation on the ABAP/4 key word TABLES. Examples are as follows:

ABAP/4 Dictionary data type ABAP/4 data type

CHAR C
NUMC N
Field Attributes

Fullscreen Field attr.

Field attributes

Graph. type
Field name
.
.
.
Dict. attributes
Program attributes
Display attributes

SAP AG

You can also maintain the attributes of your screen fields from the Screen Painter by selecting a field
and then choosing the Attributes function.
Defining the Flow Control

Screen
Painter
PROCESS BEFORE OUTPUT.
MODULE INITIALIZE.

PROCESS AFTER INPUT.


MODULE READ_SPFLI.

SAP AG

You specify define your MODULE statements in the flow logic.


If you choose a module by double-clicking, the system creates suitable MODULE ... ENDMODULE
statements in the appropriate include program. This is known as forwards navigation.
If no include program exists, the system will create one if you wish. It also inserts an INCLUDE
statement in the main program.
Creating Follow-up Screens
Screen 100 Copy Screen 200

Screen 200

Attributes Flow control


..
. PROCESS BEFORE
OUTPUT.
Next screen PROCESS AFTER
INPUT.

Screen Field list


SPFLI-CARRID
SPFLI-CARRID ___ SPFLI-CONNID
SPFLI-CO NNID ____
SPFLI-CITYFROM
SPFLI-CITYFROM ______ SPFLI-CITYTO
..
SPFLI-CITYTO ______ .

SAP AG

For screens with a similar structure, you can copy an existing screen and, if necessary, modify it (e.g.
layout, flow logic).
To do this, you work in the ABAP/4 Development Workbench by positioning the cursor on the screen
you want to copy (usually the object) and choose the Copy function.
When you have successfully copied the screen, the system displays the screen as a new sub-object of
the module pool and you can edit it.
Defining Fields in the Module Pool

Top include
ABAP/4
MTALATOP

PROGRAM SAPMTALA.

TABLES: SPFLI.
DATA: ... .

OR

Global data
ABAP/4
DATA: ... .

SAP AG

In dialog processing, data is passed between the screens and the ABAP/4 program at runtime. The
system performs this communication automatically, but you must use identical names in the screens
and the module pool.
Define the relevant fields as global data in the TOP include program. To do this, you process either
the TOP include program as a whole or the sections concerning global data or Dictionary structures.
Even then, the TOP include program is still implicitly in control.
Creating ABAP/4 Modules

$TMP User's local objects


programs
SAPMTALA

Create Create

.. ..
. .
PBO modules PAI modules
.. ..
. .

Choose Choose

PBO module INITIALIZE PAI m odule READ_SPFLI


in include prog. MTALAO01 in include prog. M TALAI01

SAP AG

When creating PBO and/or PAI modules, you can assign them to an include or the main program via
a dialog box. Normally, the system automatically assigns your PBO modules to the include program
xxxxxI01.
Processing in the Module Pool

ABAP/4
MODULE INITIALIZE OUTPUT.
CLEAR SPFLI.
ENDMODULE.

ABAP/4
MODULE READ_SPFLI INPUT.
SELECT SINGLE * FROM SPFLI
WHERE CARRID = SPFLI-CARRID
AND CONNID = SPFLI-CONNID.
.
.
.
ENDMODULE.

SAP AG

The ABAP/4 MODULE statements for PBO modules contain the addition OUTPUT, while the
MODULE statements for PAI modules contain the addition INPUT.
Defining Calls (Transaction Codes)

$TMP User's local objects

Programs
SAPMTALA

Create ..
.
Transactions
..
.

Choose Transaction code TALA


Transaction type
Dialog transaction
..
.

Continue Transaction code TALA


Transaction text TEST
Program SAPM TALA
Screen number 100

SAP AG

You can start an ABAP/4 dialog program ("transaction") by specifying a transaction code.
Customer transactions must begin with Z or Y.
The system stores your specifications in the table TSTC. (Instead of creating a transaction from the
object list, you can maintain the table itself.)
Action Sequence
Screen Action sequence
PROCESS BEFORE OUTPUT. Pain ter
MODULE A. Execute module A

PROCESS AFTER INPUT.


MODULE B. Data transport from
ABAP/4 to screen
work area

Send screen

ENTER

Data transport from


screen to ABAP/4
work area

Execute module B

SAP AG

When all the PBO modules have been processed, the data of identically named fields is transported
from the module pool work area to the screeen work area.-
Before the PAI modules are executed, the data of identically named fields is usually transported from
the screen work area to the module pool work area.
Field Format Checking
Screen
Pain ter
Field list

Field name Format

DATE DATS
.
.
.

Amount DEC

Date 30.02.1996 Date

Amount Amount 12A3

E: Invalid date E: Please enter num eric value

SAP AG

The dialog processor checks the input against the format attributes of the relevant field.
If the system detects an incorrect input value, it displays an error message and makes the field ready
for input again.
Obligatory Field

Screen
Pain ter
Field list

Field name OBLIGATORY

PLANETYPE X

SAP AG

You can assign the attribute obligatory to a screen field.


The dialog processor processes the screen only after values have been entered for all required fields.
Foreign Key Checking
ABAP/4 Check table ABAP/4
Foreign key table
Dictio nary Dictionary

Field no. KeyCheck table Field no. Key


PFELD X
.
. Domain
.
FELD1 P1
.
.
.

Screen
Painter
Field list Check table P1
Field Foreign key PFELD
FELD1 X A
B
C
.
.
.
Feld1 C

SAP AG

Foreign key checking involves the system comparing the value entered in a screen field against a set
of values. If the entered value is not found in the set of values, the system displays an error message
and makes the corresponding field ready for input again.
Here the following requirements apply:

- The screen field is a field in an ABAP/4 Dictionary table (foreign key table).
- The table against which the value is checked (known as the check table) is also defined in the
ABAP/4
Dictionary.
- The foreign key table and the check table are assigned to the same domain.
- The check table is assigned to this domain as a value table.
- The value table becomes the check table by through the definition of a foreign key between the
foreign
key field and the check table field in the ABAP/4 Dictionary.
- The check table field must be the key field of the check table.
You can also perform foreign key checking against check tables with several key fields.
You can display the contents of the check table by placing the cursor on the screen field and pressing
F4.
By pressing F1, you can display the documentation defined at data element level.
Input Checking in the Module Pool

Screen
PROCESS AFTER INPUT. Painter MODULE <module> INPUT. ABAP/4
FIELD <screen field> .
.
MODULE <module>. .
MESSAGE E ... .
ENDMODULE.

1 1

E... m essage

1 ready for input again

SAP AG

If you want to check input values in the module pool and include an error dialog following a negative
check result, use the MODULE parameter with the FIELD statement. You also have to define an error
or warning message in the module pool.
Please note that only the FIELD statement is responsible for modifying the status of a field to make it
ready for input again:
If you define a message in the module pool, but do not call the module within a FIELD statement, the
system sends the message, but the fields are not ready for input.
FIELD Statement and Data Transport
A ENTER
Screen
PROCESS AFTER INPUT. Painter c
Data transport for all
MODULE A. t fields other than X, Y
FIELD X MODULE B.
FIELD Y MODULE C. i from the screen to the
ABAP/4 work area
MODULE D. o
n
Execute module A

s Data transport for X


e
q Execute module B

u
Data transport for Y
e
n Execute module C
c
e Execute module D
SAP AG

In the PAI module, screen fields are transported to identically named ABAP/4 fields. Fields not
defined in FIELD statements are transported first. All the other fields are copied only when the
relevant FIELD statements have been processed.
Setting the Next Screen Dynamically
Screen Screen
Painter Painter
Screen attributes Screen attributes

screen num ber 100 screen number 200


. .
. .
. .
next screen 100 next screen 200

Screen Screen
Painter Painter
PROCESS
PROCESS AFTER
AFTER INPUT.
INPUT. PROCESS
PROCESS BEFORE
BEFORE OUTPUT
OUTPUT
MODULE ..
MODULE OK_CODE.
OK_CODE. ..
..

ABAP/4
MODULE OK_CODE INPUT.
.
. PROCESS
PROCESS AFTER
AFTER INPUT.
INPUT.
. ..
SET SCREEN 200. ..
..
LEAVE SCREEN.

SAP AG

If the functions in your dialog program require a different control process, you can control the screen
sequence dynamically using the SET SCREEN statement.
The statement SET SCREEN nnnn temporarily overwrites the follow-up screen.
Screen nnnn must be a screen from the same module pool.
When the current screen has been processed, the system processes the follow-up screen unless you
cancel the current screen process with LEAVE SCREEN.
You can also use the CALL SCREEN statement for dynamic screen sequence control. Here, you can
insert a screen sequence and then either return to the original call location after this has been
executed or call a screen defined as a modal dialog box. The CALL SCREEN statement is not
covered in this course.
Reading Function Codes in Programs
Screen
Pain ter
PROCESS AFTER INPUT.
.
.
.
Screen MODULE USER_COMMAND.
Pain ter

Display
ABAP/4
DATA: OKCODE(4),
SAVE_OKCODE(4).

MODULE USER_COMMAND INPUT.


SAVE_OKCODE = OKCODE.
Screen
Pain ter CLEAR OKCODE.
Field list CASE SAVE_OKCODE.
Field name Lg Form FctCode WHEN MORE.
.
.
PUSH_100 MORE .
ENDMODULE.
OKCODE 5 OK

SAP AG

You define pushbuttons to enable the user to choose specific functions. When the user presses a
pushbutton, the PAI event is triggered.
You also assign a function code to each pushbutton.
When the user chooses a function, the function code is in the field you have defined in the field list
with the attributes length 5 and format OK.
To be able to react to a function code in the ABAP/4 module pool, you define an identically named
OKCODE field. This contains the current function code after the field has been transported.
You are recommended to use a backup version of the OKCODE field to avoid sending a screen that
already has a function code.
Menu Painter: Overview

Object List GUI title


Developm ent object Edit G oto .... SET TITLEBAR code.
SY-TITLE: Title text
Markers

ENTER GUI status


F1 Help SET PF-STATUS status.
F2 Choose SY-PFKEY: Status
F3 .
.
.

Title bar
M enu bar
Standard toolbar
Application toolbar

SAP AG

You use the Menu Painter to define functions on a screen in a particular status and assign them to the
appropriate menu bar, standard toolbar and application toolbar.
You also define the title.
In general, you define a menu bar for each dialog program and assign it to a status. For each status,
you define which menu functions are to be active/inactive.
All the statuses of a dialog program make up the user interface. If you add a new status, you have to
regenerate the interface.
You assign a status and a title to a screen in the appropriate PBO module using the SET PF-STATUS
and SET TITLEBAR statements respectively. The status can be up to 8 characters long, while the
title code should consist of no more than 3 characters.
GUI Title
SAPMTALA

Create
..
.
GUI title
..
.

Choose

Create title
Title code 001

Continue

Program SAPMTALA
Maint. language ENGLISH
Title code 001
Title
Test dialog program
SAP AG

You can create and/or maintain a title either from the object list or from a GUI status.
To set a title in a PBO module, you use the statement SET TITLEBAR <code> WITH <value1>
<value2> ... <valuen>. The contents of <code> can be up to three characters long. The system
replaces & placeholders in the title with the contents of <value1>....<valuen>.
Once a title is set, it remains valid until you set a new title.
The system field SY-TITLE contains the current screen title.
GUI Status
SAPMTALA
Create
..
.
GUI status
..
.
Choose

Create status
Program SAPMTALA
Status STAT1
Continue
..
.
Short desc. Test status
Status type
- screen
- dialog box
- list
- list in dialog box
SAP AG

You can define one or more statuses for a screen. A status defines which functions the user can
choose and whether they can be selected via the menu bar or standard toolbar, or by pressing function
keys or pushbuttons.
To set a status in a PBO module, you use the statement SET PF-STATUS <status>. The contents of
<status> can have up to eight characters.
By using the EXCLUDING parameter with the SET PF-STATUS statement, you can deactivate the
functions of the current status which were defined as active in the Menu Painter.
Once a status is set, it remains valid until you set a new status.
The system field SY-PFKEY contains the current status.
By choosing a status type, you determine whether the status is to refer to a normal screen or a list.
The system offers different functions for each status type.
Defining the Interface I

Menu bar
- Hide standards

<Object> Edit Goto


Func Name
< .. > O ther <object>
< .. > Create

F key assignment

+ Extended F key assignment

W INDOWS MOTIF APPLE ...

SAP AG

On request, the system proposes default values for the menu bar and the function key setting, but you
can modify these.
Menu bars can contain up to eight menus. You can define up to six of these yourself, but the System
and Help menus are added automatically by the system.
A single menu can contain up to 15 entries, including the functions and their descriptions, sub-menu
names and separator lines.
You should also specify all the functions that are active in a status as active in the menu bar (SAP
ergonomic standard).
Defining the Interface II

Standard toolbar
...

Application toolbar
...

Recom mended function key settings


F2 < .. > Choose
F9 < .. > Select
...

Freely assigned function keys


F5
F6
...

SAP AG

You assign the active functions that a user is most likely to need in the current status to the
application toolbar. Before you can do this, the function code must be assigned to a function key.
You assign function codes to function keys by entering them in the Recommended function key
settings or the Freely assigned function keys sections.
The system automatically assigns the functions in the standard toolbar to special function keys (see
next page).
Chapter 12 Summ ary

Program of type M (module pool) with TOP include


(optional)
Define global data in the TOP include or main program
Generate main program (only if global data is not yet
known in the ABAP/4 Dictionary)
Create first screen for module pool
- design screen layout
- maintain field list (field attributes)
- define module calls in the flow logic
Create other screens (by copying, if necessary)
- complete screen definition
- maintain field list
Create modules in the module pool (general processing,
dialog messages, GUI title, GUI status)
Define transaction code

SAP AG BC400 / 12 - 1
Exercises Chapter 12: Introduction to Dialog Programming

1. Program name: SAPMZ##1


Transaction code: Z##1
Development class: $TMP
Screens 100 Follow-up screen 200
200 Follow-up screen 100
## Group number
Write a dialog program to display the flight data for a selected
flight. To do this, use the table SFLIGHT.
On the first screen, the user should be able to enter values for
the key fields of the table SFLIGHT.
For the second screen, copy the first one and add other fields
(see example). Define all fields on the second screen as
output fields only.
All fields on screen 100 should have initial values when the
screen is called.
a) Screen 100

Schluessel Flugdaten
Fluggesellschaft
Airline carrier ___
Verbindungs-Nummer
Connection number____
Datum des date
Flight Fluges __________

b) Screen 200

Airline carrier
Connection number
Flight date

Flight information

FlgtPrice
Local currency
Plane type
Maximum capacity
Occupied seats
2. Program name: SAPMZ##2
Transaction code: Z##2
Development class: $TMP
Screens 100 Follow-up screen 100
200 Follow-up screen 200
## Group number
Copy your program SAPMZ##1 or the example solution
SAPMTAL1 and add the following functionality:
- The key fields of table SFLIGHT should be defined as
required fields. In addition, they should be used to transfer
data to the SPA/GPA Memory and/or provided with data
from the SPA/GPA Memory.
- If invalid values are entered in the key fields, you should
display an error dialog message on the first screen and make
the field Date of flight ready for input again. Use message
class.
- Changing screens should only be possible by pressing the
appropriate pushbutton (see example).
a) Screen 100

Schluessel Flugdaten
Display
Fluggesellschaft
Airline ___
Verbindungs-Nummer
Connection number____
Datum desofFluges
Date flight __________

b) Screen 200

Back
Airline
Connection number
Date of flight

Flight information
FlgtPrice
Local currency
Plane type
Maximum capacity
Occupied seats
3. Program name: SAPMZ##3
Transaction code: Z##3
Development class: $TMP
Screens 100 Follow-up screen 100
200 Follow-up screen 200
## Group number
Copy your program SAPMZ##2 or the example solution
SAPMTAL2 and modify the copy as follows:
- The dialog program should have a GUI title.
- Define one GUI status. When the transaction is executed,
only the relevant function is to be active (see example).
- On the first screen, implement the Display function as an
icon in the standard toolbar (cf. example).
Note:
When defining the status, use the system standards.
Examples
a) Screen 100

Display flight data


Flight data Goto System Help !

Display flight data


Flight data Goto System elp !
Display Back

b) Screen 200

Display flight data


Flight data Goto System Help !

Display flight data


Flight data Goto System Help !
Display Back
Solutions Chapter 12: Introduction to Dialog Programming

1. Exercise 1
*&---------------------------------------------------------------*

*& Module pool SAPMTAL1 Flow control *

*&---------------------------------------------------------------*

* Screen 100

PROCESS BEFORE OUTPUT.

MODULE INITIALIZE.

PROCESS AFTER INPUT.

MODULE READ_SFLIGHT.

*&---------------------------------------------------------------*

*& Module pool SAPMTAL1 *

*&---------------------------------------------------------------*

PROGRAM SAPMTAL1.

TABLES SFLIGHT.

*&---------------------------------------------------------------*

*& Module INITIALIZE OUTPUT *

*&---------------------------------------------------------------*

MODULE INITIALIZE OUTPUT.

CLEAR SFLIGHT.

ENDMODULE. " INITIALIZE OUTPUT


*&---------------------------------------------------------------*

*& Module READ_SFLIGHT INPUT *

*&---------------------------------------------------------------*

MODULE READ_SFLIGHT INPUT.

SELECT SINGLE * FROM SFLIGHT

WHERE CARRID = SFLIGHT-CARRID

AND CONNID = SFLIGHT-CONNID

AND FLDATE = SFLIGHT-FLDATE .

* SY-SUBRC is not read in this program.

ENDMODULE. " READ_SFLIGHT INPUT


2. Exercise 2
*-------------------------------------------------------------*

*& Module pool SAPMTAL1 Flow control *

*&------------------------------------------------------------*

* Screen 100

PROCESS BEFORE OUTPUT.

MODULE INITIALIZE.

PROCESS AFTER INPUT.

FIELD SFLIGHT-FLDATE MODULE READ_SFLIGHT.

MODULE USER_COMMAND_0100.

* Screen 200

PROCESS BEFORE OUTPUT.

PROCESS AFTER INPUT.

MODULE USER_COMMAND_0100.
*&------------------------------------------------------*

*& Module pool SAPMTAL1 *

*&------------------------------------------------------*

PROGRAM SAPMTAL2 MESSAGE-ID AT.

TABLES SFLIGHT.

DATA: OKCODE(4).

*&------------------------------------------------------*

*& Module INITIALIZE OUTPUT *

*&------------------------------------------------------*

MODULE INITIALIZE OUTPUT.

CLEAR: SFLIGHT, OKCODE.

ENDMODULE. " INITIALIZE OUTPUT


*&------------------------------------------------------*

*& Module READ_SFLIGHT INPUT *

*&------------------------------------------------------*

MODULE READ_SFLIGHT INPUT.

SELECT SINGLE * FROM SFLIGHT

WHERE CARRID = SFLIGHT-CARRID

AND CONNID = SFLIGHT-CONNID

AND FLDATE = SFLIGHT-FLDATE .

IF SY-SUBRC NE 0.

CLEAR OKCODE.

MESSAGE E007.

*E: No table entry for selected key

ENDIF.

ENDMODULE. " READ_SFLIGHT INPUT

*&---------------------------------------------------------------*

*& Module USER_COMMAND_0100 INPUT *

*&---------------------------------------------------------------*

MODULE USER_COMMAND_0100 INPUT.

CASE SY-DYNNR.

WHEN 100.

IF OKCODE = 'MORE'.

SET SCREEN 200.

ENDIF.

WHEN 200.

IF OKCODE = 'BACK'.

SET SCREEN 100.

ENDIF.
ENDCASE.

LEAVE SCREEN. "Optional, because SET SCREEN is the last


"statement in PAI.

ENDMODULE. " USER_COMMAND_0100 INPUT


3. Exercise 3
*&-------------------------------------------------------*

*& Module pool SAPMTAL1 Flow control *

*&--------------------------------------------------------

* Screen 100

PROCESS BEFORE OUTPUT.

MODULE STATUS_100.

MODULE INITIALIZE.

PROCESS AFTER INPUT.

FIELD SFLIGHT-FLDATE MODULE READ_SFLIGHT.

MODULE USER_COMMAND_0100.

* Screen 200

PROCESS BEFORE OUTPUT.

MODULE STATUS_100.

PROCESS AFTER INPUT.

MODULE USER_COMMAND_0100.
*&---------------------------------------------------------------*

*& Module STATUS_100 OUTPUT *

*&---------------------------------------------------------------*

MODULE STATUS_100 OUTPUT.

SET TITLEBAR '100'.

CASE SY-DYNNR.

WHEN 100.

SET PF-STATUS 'BASE' EXCLUDING 'BACK'.

WHEN 200.

SET PF-STATUS 'BASE' EXCLUDING 'MORE'.

ENDCASE.

ENDMODULE. " STATUS_100 OUTPUT

You might also like