Contents:: Introduction To Screen Programming

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 42

1

Introduction to Screen Programming

Contents:
 Principles of screen programming
 Screen objects
 Dynamic screen modifications
 Screen processing
 GUI status for screens

 SAP AG 1999

© SAP AG BC410 5-1


1.2
Screen Programming: Objectives

At the conclusion of this unit, you will be able to


 Create and process screens

 Use a GUI interface for navigation

PBO PAI PBO PAI PBO PAI

 SAP AG 1999

© SAP AG BC410 5-2


1.3
Overview Diagram

5
6 Flight 7
8
11
9 12
10

2 4

 SAP AG 1999

 Unit 1 Course Overview


 Unit 2 Basics for Interactive Lists
 Unit 3 The Program Interface
 Unit 4 Interactive List Techniques
 Unit 5 Introduction to Screen Programming
 Unit 6 Screen Elements for Output
 Unit 7 Screen Elements for Input/Output
 Unit 8 Screen Elements: Subscreens and Tabstrip Controls
 Unit 9 Screen Elements: Table Controls
 Unit 10 Context Menus on Screens
 Unit 11 Lists in Screen Programming
 Unit 12 Preview: Control Framework

© SAP AG BC410 5-3


1.4
Screen Programming: Principles

Principlesof
Principles of screen
screenprogramming
programming

Screen objects
Screen objects

Dynamicscreen
Dynamic screen modifications
modifications

Screenprocessing
Screen processing

GUIstatus
GUI statusfor
forscreens
screens

 SAP AG 1999

© SAP AG BC410 5-4


1.5
Strengths of Screens

Table control

Flight Dep. city To

0400 Frankfurt New


0402 Frankfurt New
Data entry 2407 Berlin San F
with consistency
checks

Screen Tabstrip control

From Arrive

Country DE
City Berlin
Time 10:10:00

 SAP AG 1999

 Screens allow you to enter and to display data.


 One of their strengths is that they can combine with the ABAP Dictionary to allow you to check the
consistency of the data that a user has entered.
 Screens allow you to create user-friendly dialogs with pushbuttons, tabstrip controls, table controls,
and other graphical elements.

© SAP AG BC410 5-5


1.6
Screens in Dialog Programs

Program ABAP Program


start Data objects

Database
table

ABAP
processing
block

Process
Before
Output

Process
After
Input

ABAP runtime system

 SAP AG 1999 Time

 Let us look at a simple dialog program with a selection screen as its initial screen and a screen for
displaying information for a selected data record.
 When the program starts, the system loads its program context and prepares memory space for the
program data objects. The selection screen is displayed.
 The user enters data on the selection screen and chooses Execute.
 In a processing block, the program reads data from the database. To do so, it passes information
about the data requested by the user to the database. The database fills a structure with the required
data record.
 The processing logic then calls a screen. This triggers a processing block belonging to the screen
called Process Before Output (or PBO). Once the PBO has been processed, the data is transferred to
a structure that serves as an interface to the screen. It is then transferred to the screen and displayed.
 Any user action on the screen (pressing enter, choosing a menu entry, clicking a pushbutton, ... )
returns control to the runtime system. The screen fields are then transported into the structure that
serves as the interface between screen and program, and the runtime system triggers another
processing block belonging to the screen, which is always processed after a user interaction, and is
called Process After Input (or PAI).

© SAP AG BC410 5-6


1.7
Screen Programs: Screen Objects

Principlesof
Principles of screen
screenprogramming
programming

Screenobjects
Screen objects

Dynamicscreen
Dynamic screenmodifications
modifications

Screenprocessing
Screen processing

GUIstatus
GUI statusfor
forscreens
screens

 SAP AG 1999

© SAP AG BC410 5-7


1.8
Screen Objects

Screen object

Attributes:
- Create statically
- Create statically, Methods
change dynamically change
- Change dynamically
attributes

 SAP AG 1999

 In this course, you will learn about screen objects. A screen object is any screen element in the R/3
System that allows users to interact with an ABAP program.
 On the following pages, screen objects are presented from an object-oriented viewpoint, that is, their
attributes are described, along with the methods you can use to work with them.

© SAP AG BC410 5-8


1.9
General Attributes

General attributes

Options
Colors in forms

Colors in lists

General

Fonts

Cursor

Trace

Default size
 SAP AG 1999

 You can use the User settings icon (on the far right hand side of the standard toolbar) to configure the
R/3 window according to your own preferences.
 You can:
· Change the colors of various elements of the R/3 interface
· Change the font of texts displayed in the system
· Modify the R/3 window (for example, hide the standard toolbar or restore the default window size
· Show or hide grid lines in lists
· Change the cursor behavior
 The changes you make to the user settings are stored on your presentation server, not in the R/3
System.
 For more detailed information, refer to the online documentation path in appendix reference DIA-1.

© SAP AG BC410 5-9


1.10
Attributes of Screen Objects (Key)

General attributes

Static Static attribute,


attribute dynamically modifiable
List
 Attribute _  Attribute 1
 Attribute _  Attribute 2
 Attribute _  Attribute 3

Dynamically modifiable
attribute, not accessible
statically

 SAP AG 1999

 The screen objects text field, input/output field, status icon, group box, radio button, checkbox, and
pushbutton all have general attributes, Dictionary attributes, program attributes, and display
attributes.
 The objects subscreen, tabstrip control and table control have general attributes, and special
attributes relating to the respective object type.
 We can divide the attributes of an object into
Statically definable attributes that cannot be changed dynamically
Statically definable attributes that can be changed dynamically
Attributes that can only be changed dynamically
 For complete documentation of the attributes of screen objects, refer to the online documentation
path in appendix reference DIA-2.

© SAP AG BC410 5-10


1.11
Dynamically Modifiable Static Attributes

Attributes SCREEN
General SCREEN-NAME
 Object name
 Modif. groups SCREEN-GROUP1
 Size SCREEN-GROUP2
- Dynamic SCREEN-GROUP3
SCREEN-GROUP4
Program SCREEN-LENGTH
 Dialog behavior
- Input SCREEN-INPUT
- Output SCREEN-OUTPUT
- Required
SCREEN-REQUIRED
SCREEN-INTENSIFIED
Display
 Bright SCREEN-INVISIBLE
 Invisible SCREEN-ACTIVE

 SAP AG 1999

 At the beginning of the PBO, the runtime system reads the statically-created and dynamically-
modifiable attributes of each screen object on the screen into a system table with the line type
SCREEN.
 The slide shows the assignment of the fields in the system table SCREEN to the names of the
statically created attributes of the screen objects.

© SAP AG BC410 5-11


1.12
Screen Programs: Screen Modifications

Principlesof
Principles of screen
screenprogramming
programming

Screenobjects
Screen objects

Dynamicscreen
Dynamic screenmodifications
modifications

Screenprocessing
Screen processing

GUIstatus
GUI statusfor
forscreens
screens

 SAP AG 1999

© SAP AG BC410 5-12


1.13
The System Table SCREEN

INTENSIFIED
REQUIRED

INVISIBLE
GROUP 1

GROUP 2

GROUP 3

GROUP 4

LENGTH

OUTPUT

ACTIVE
NAME

INPUT
HUGO 20 1 1 1 0 0 1

RADIO1 ADM 1 1 1 0 0 0 1

RADIO2 ADM 1 1 1 0 0 0 1

RADIO3 ADM 1 1 1 0 0 0 1

BOX1 35 0 0 0 0 0 1

BOX_TITLE 15 0 1 0 1 0 1

CHECK1 1 1 1 0 0 0 1

 SAP AG 1999

 When a screen is processed, the system table SCREEN contains an entry for each screen object that
has been created in the Screen Painter for that screen.
 It is initialized in the PBO of each screen, and is filled with the screen objects belonging to that
screen.
 You can change the dynamically-modifiable attributes of the elements on the screen using the
construction
LOOP AT SCREEN. ... ENDLOOP.
in a PBO module. To do this, you use the structure SCREEN, which is created automatically by the
system, and filled with the values of each successive line of the system table in the LOOP. Active
attributes have the value '1', inactive attributes have the value '0'. To change the system table, use
MODIFY SCREEN. within the LOOP.
 To find the object whose attributes you want to modify, you can use a LOOP on the SCREEN table,
and query one of the following fields: SCREEN-NAME, SCREEN-GROUP1 to SCREEN-GROUP4.
There is further information about modification groups on the next page.
 For further information about the SCREEN table, see the description of the structure of SCREEN or
the documentation for the LOOP statement.

© SAP AG BC410 5-13


1.14
Modifying Attributes Dynamically: Example

Display/change Display/change

A A

B B

Output field Input/Output field

 SAP AG 1999

 Dynamic changes to the attributes of screen objects are temporary.


 Using this technique to modify the attributes of a screen object (for example, to change whether an
input/output field is ready for input), you can replace long sequences of separate screens, which are
more costly in terms of both programming time and runtime.

© SAP AG BC410 5-14


1.15
Object Attributes: Modification Groups

Screen
Painter
Element list: Modification groups

Element Gr1 Gr2 Gr3 Gr4 ...

SDYN_CONN-CONNID SEL
SDYN_CONN-CITYFROM SEL
SDYN_CONN-CITYTO SEL
...

 SAP AG 1999

 If you want to change the attributes of several attributes at once at runtime, you can include them in a
modification group. To do this, enter the same three-character group name in one of the fields
SCREEN-GROUP1 through SCREEN-GROUP4 of each element.
 Each object can belong to up to four modification groups. You assign the group names in the element
list or layout editor in the Screen Painter.

© SAP AG BC410 5-15


1.16
Modifying Attributes Dynamically: Program

Screen
PROCESS BEFORE OUTPUT. Painter
.
.
.
MODULE modify_screen.
.
.
.

ABAP
MODULE modify_screen OUTPUT.
...
LOOP AT SCREEN.
IF screen-group1 = 'SEL'.
screen-input = 1.
ENDIF.
IF screen-name= 'SDYN_CONN-CARRID'.
screen-active= 0.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
ENDMODULE.
 SAP AG 1999

 You must program your screen modifications in a module that is processed during the PROCESS
BEFORE OUTPUT processing block.
 You use a loop throught the table SCREEN to change the attributes of an object or a group of
objects. (LOOP AT SCREEN WHERE . . . and READ TABLE SCREEN are not supported. )
 To activate and deactivate attributes, assign the value 1 (active) or 0 (inactive), and save your
changes using the MODIFY SCREEN statement.
 Note that objects you have defined statically in the Screen Painter as invisible cannot be reactivated
with SCREEN-ACTIVE = 1. However, objects that you have statically defined as visible in the
Screen Painter can dynamically be made invisible. SCREEN-ACTIVE = 0 has the same effect as the
following three statements:
SCREEN-INVISIBLE = 1, SCREEN-INPUT = 0, SCREEN-OUTPUT = 0.

© SAP AG BC410 5-16


1.17
Screen Programs: Screen Processing

Principlesof
Principles of screen
screenprocessing
processing

Screenobjects
Screen objects

Dynamicscreen
Dynamic screenmodifications
modifications

Screenprocessing
Screen processing

GUIstatus
GUI statusfor
forscreens
screens

 SAP AG 1999

© SAP AG BC410 5-17


1.18
Screens

SAP screen as container


for other screen objects

 SAP AG 1999

 Screens are freely-definable objects that you can use to display or enter information.
 They are a form of dialog between the user and the ABAP program.

© SAP AG BC410 5-18


1.19
Screen: Definition and Use

Screen object
Screen _ _ _ _

Text field
Subscreen
area

Screen attributes

...

Flow logic
PBO. Title
...
PAI. ... ... ... ... ... ...
... Box

 SAP AG 1999

 A screen consists of the input/output mask (layout), the screen attributes, and the screen flow logic.
For further information about how to program screen flow logic, refer to the ABAP User's Guide.
 Screens have four components: the screen mask, the screen attributes, the element list, and the flow
logic. The flow logic contains flow logic code (not ABAP statements).
 Screens are containers for other screen objects.

© SAP AG BC410 5-19


1.20
Screen: Attributes

Screen attributes

Admin. Type Size Sequence Settings

 Program  Normal  Static  Next screen  Cursor


 Screen no.  Subscreen - Maint. position
 Short desc.  Modal dialog - Occupied  Hold data
 Screen grp. box  Dynamic  Fixed font
 Changes  Selection - Starting at  Runtime
 Generation screen - Size compression
 Status  Context menu
 Original lang.
 Dev. class

 SAP AG 1999

 Each screen has a set of administration attributes that specify its type, size, and the subsequent
screen. It also has settings that influence other properties of the screen and of its components.
 The administration attributes Program and Screen number identify the screen by its number and the
program to which it belongs.
 Screen numbers greater than 9000 are reserved for SAP customers. Screen numbers 1000 through
1010 are reserved for the maintenance screens of ABAP Dictionary tables and the standard selection
screens of reports.
 The screen type identifies the purpose of the screen. Certain other special attributes of a screen and
its components depend on this attribute.
 The "Next screen" attribute allows you to specify the screen that should be processed after the
current screen in a fixed sequence.
 For a full list of screen attributes with their meanings, refer to the online documentation path in
appendix reference DIA-3.

© SAP AG BC410 5-20


1.21
Creating Screen

Screen
Screen
Painter
Painter
Screen Screen Field Flow logic
attributes layout attributes
Screen no. 100
NUMBER PROCESS BEFORE OUTPUT.
Short description Number: character MODULE INIT.
Test
10 characters
Screen type normal
Input x PROCESS AFTER INPUT.
Next screen 200
... MODULE READ_100.
...

 SAP AG 1999

 When you create a screen, you must:


Set the general screen attributes (on the attribute screen)
Design the screen layout (in the layout editor)
Set the field attributes (in the field list)
Write the flow logic (in the flow logic editor).

© SAP AG BC410 5-21


1.22
Creating a Screen: Screen Attributes

Object
Object
Navigator
Navigator Create Screen
<Program name>

Program object types Program <Program name>

Fields Screen number ?


Create
Screens
0100 Data selection
0200 Display

Screen
Screen
Screen Attributes Painter
Painter
Short description ?
Screen type

Normal
Subscreen
Modal dialog box
Selection screen

Next screen 0
 SAP AG 1999

 To create a screen from the object list in the Object Navigator, create a new development object with
the type Screen. Position the cursor on Screens and right-click.
 The Object Navigator automatically opens the Screen Painter.
 When you create a screen, you first have to enter its attributes. Enter a screen number, a short text,
and a screen type. You will normally use the screen type Normal. You can specify the number of the
next screen in the Next screen field.
 If you enter 0 (or nothing) for the next screen, the system resumes processing from the point at which
the screen was called once it has finished processing the screen itself.
 You can also create a screen by writing a CALL SCREEN <nnnn> statement in the ABAP Editor and
then double-clicking the screen number <nnnn>.

© SAP AG BC410 5-22


1.23
Creating a Screen: Element List:

References
Modification Groups
Display Attributes
Special Attributes
Texts and I/O Fields
General Attributes

Field name Type Line . .

SDYN_CONN-CARRID CHAR 3 ...


SDYN_CONN-CONNID CHAR 5
OK_CODE OK
...

 SAP AG 1999

To allow you to set the attributes of all screen elements, the Screen Painter contains an element
list with six views. You can also display all of the attributes for a single element from any of the
lists (Attributes). You can also maintain the attributes for an element from the layout editor
using the Attributes function.
Within the Screen Painter, you work with external data types. These correspond to the types
defined in the ABAP Dictionary. For fields that you have chosen that are defined in the ABAP
Dictionary, the system displays the external data type in the Format column. For elements
(templates) that do not have an ABAP Dictionary reference, you must enter an external data
type yourself.
To find out the corresponding external data type for an internal data type (ABAP data type), see
the keyword documentation for the ABAP TABLES statement. For example:
ABAP Dictionary Data Type ABAP Data Type
CHAR C
NUMC N

© SAP AG BC410 5-23


1.24
Creating a Screen: Layout

Attributes Dict/Prog fields Element list

X
Airline
Flight number

 SAP AG 1999

 You usually define screen fields by adopting the corresponding field descriptions from the ABAP
Dictionary. However, you can also use field descriptions that you have defined in your program. In
order to do this, you must generate the program first.
 You can use the key word texts and templates either together or separately.
 The graphical layout editor provides an easy way of defining the various screen elements (such as
input/output fields, key word texts, boxes, and so on). You simply choose the element you require,
and position it on the screen using the mouse.
 To delete a screen element, select it, and choose Delete.
 You can move elements on the screen by dragging and dropping them with the mouse.
Note:
The graphical layout editor is available under Windows NT, Windows 95 and UNIX.
If you use a different operating system, you must use the alphanumeric Screen Painter.

© SAP AG BC410 5-24


1.25
Creating a Screen: Flow Logic

Screen
Screen
Painter
Painter Create Object
PBO module SET_STATUS_100 does not exist.
PROCESS BEFORE OUTPUT.
Do you want to create the object?
MODULE set_status_100.
Yes No Cancel

Double-click
Create PBO Module
PBO module SET_STATUS_100

ABAP Select Include


ABAP
BC410D_DISPO01 New include
MODULE set_status_100 OUTPUT.
SAPBC410_DISP Main program
SET PF-STATUS 'STATUS_100'.
SET TITLEBAR 'TITLE_100'.
ENDMODULE.

 SAP AG 1999

 Screens have their own set of keywords that you use in the PBO and PAI events of the flow logic.
 In the flow logic, you write MODULE calls. The modules are components of the same ABAP
program. They contain the ABAP statements that you want to execute.
 You can create a module by double-clicking the module name in the flow logic Editor.
 To create a module from the object list in the Object Navigator, choose the development module
'PBO module' or 'PAI module'.
 You can call the same module from more than one screen. If the processing depends on the screen
number, you can retrieve the current screen number from the system field sy-dynnr.
 Note that the modules you call in the PBO processing block must be defined using the MODULE
OUTPUT statement; modules that you define using the statement MODULE... INPUT can only be
called in the PAI event.

© SAP AG BC410 5-25


1.26
Communication: Screen - ABAP Program

IDENTICAL NAMES
Time

Program work area


PBO
MODULE trans_to_100 TABLES: sdyn_conn.
After PBO LH 0400
CARRID CONNID
MODULE trans_to_100 OUTPUT.
SDYN_CONN-CARRID
MOVE-CORRESPONDING
LH
wa_spfli to sdyn_conn.
SDYN_CONN-CONNID ENDMODULE.
0402
TABLES: sdyn_conn.
Before PAI LH 0402
CARRID CONNID
PAI MODULE trans_from_100 INPUT.
MODULE trans_from_100 MOVE-CORRESPONDING
sdyn_conn TO wa_spfli.
ENDMODULE.

 SAP AG 1999

 In order for a screen and its ABAP program to be able to communicate, the fields on the screen and
the corresponding fields in the program MUST HAVE IDENTICAL NAMES.
 After it has processed all of the modules in the PBO processing block, the system copies the
contents of the fields in the ABAP work area to their corresponding fields in the screen work area.
 Before it processes the first module in the PAI processing block, the system copies the contents of
the fields in the screen work area to their corresponding fields in the ABAP work area.
 You should use your own structures (SDYN_CONN, …) for transporting data between the screen
and the ABAP program. This ensures that the data being transported from the screen to the program
and vice versa is exactly the data that you want.

© SAP AG BC410 5-26


1.27
Static Screen Sequence

Screen Attributes Screen Attributes

Screen number 100 Screen number 200


Next screen 200 Next screen 300

PBO PAI PBO PAI

 SAP AG 1999

 You can establish a static sequence of screens by entering a value in the Next screen field of the
screen attributes.
 If you enter 0 (or no value) as the next screen, the system resumes processing from the point at
which the screen was initiated, once it has finished processing the screen itself.

© SAP AG BC410 5-27


1.28
Setting the Next Screen Dynamically

Screen
Screen Attributes
Attributes Screen Attributes
Screen
Screen number
number 100
100 Screen number 300
Next
Next screen
screen 200
200 Next screen 400

PBO PAI PBO PAI


400

MODULE ...
SET SCREEN 300.
LEAVE SCREEN.
ENDMODULE.

 SAP AG 1999

 The SET SCREEN <nnnn> statement temporarily overwrites the Next screen attribute.
 The screen <nnnn> must belong to the same program.
 The next screen is processed either when the current screen processing ends, or when you terminate
it using the LEAVE SCREEN statement.
 To specify the next screen and leave the current screen in a single step, use the
LEAVE TO SCREEN <nnnn> statement.

© SAP AG BC410 5-28


1.29
Inserting a Sequence of Screens Dynamically

Screen
Screen Attributes
Attributes Screen Attributes
Screen
Screen number
number 100
100 Screen number 300
Next
Next screen
screen 200
200 Next screen 301

PBO PAI PBO ... PAI

MODULE ... MODULE ...


CALL SCREEN 300. SET SCREEN 0.
... LEAVE SCREEN.
ENDMODULE. ENDMODULE.

 SAP AG 1999

 To interrupt processing of the current screen and branch to a new screen (or sequence of screens), use
the CALL SCREEN <nnnn> statement. The screen <nnnn> must belong to the same program.
 In the program, the system constructs a stack. The stack has to be destroyed before the end of the
program.
 To return to the statement following the CALL SCREEN statement, you can use either SET
SCREEN 0, LEAVE SCREEN, or LEAVE TO SCREEN 0. The screen that called the other screen
is then processed further.
 If you use the above statements outside of a call chain, the program terminates, and control returns to
the point from which it was called. You can also terminate a program using the ABAP statement
LEAVE PROGRAM.

© SAP AG BC410 5-29


1.30
Calling a Dialog Box Dynamically

Screen 101 MODULE user_command INPUT.


...
CALL SCREEN 101
STARTING AT lc ur.
...

ENDMODULE.
101
101

100
100
Screen Attributes MODULE user_command INPUT.
Screen type ...
..
. CALL SCREEN 101
Modal dialog box STARTING AT lc ur
..
. ENDING AT rc lr.
Next screen 101 ...
ENDMODULE.
101
101
100
100

 SAP AG 1999

 In the CALL SCREEN statement, you can use the STARTING AT and ENDING AT additions to
specify the position and size of the screen that you are calling. The screen in the CALL SCREEN
statement must be defined as a modal dialog box.
 If you omit the ENDING AT statement, the size of the dialog box is determined by the Used size in
its screen attributes.
 If you use the ENDING AT addition, the system displays as much of the dialog box as will fit into
the available space. If there is not enough room to show the entire dialog box, it appears with
scrollbars.

© SAP AG BC410 5-30


1.31
Window Coordinates

CALL SCREEN 101


STARTING AT left_col upper_row
ENDING AT right_col lower_row.

left_col right_col
0

upper_row

101
101

lower_row

100
100
 SAP AG 1999

 The starting position (origin) of every SAP window is its top left-hand corner.
 The values that you pass to lc, ur, rc, and lr in the statement
CALL SCREN STARTING AT lc ur ENDING AT rc lr
refer to the R/3 window in which you display the dialog box (on the slide, screen 100).

© SAP AG BC410 5-31


1.32
Setting the Cursor Position Dynamically

SET CURSOR
FIELD <f> [OFFSET <o>].

Screen
Painter
PROCESS
PROCESS BEFORE
BEFORE OUTPUT.
OUTPUT.
MODULE set_cursor.
MODULE set_cursor.
Airline LH
ABAP
MODULE set_cursor OUTPUT. flight number ?
sdyn_conn-carrid = 'LH'. Flight date ?
SET CURSOR
FIELD sdyn_conn-connid.
...
ENDMODULE.

 SAP AG 1999

 When the system displays a screen, it automatically places the cursor in the first input field. If you
want the cursor always to appear in a different field, you can enter the corresponding object name in
the Cursor position field of the screen attributes.
 You can also tell the system in the PBO event to position the cursor in a particular field. This makes
your application more user-friendly.
 You can set the field in which the cursor should appear in the program.
To do this, use the ABAP statement

SET CURSOR FIELD <field_name> OFFSET <position>.


 <field_name> can be a unique name in quotation marks, or a variable containing the object
name. To place the cursor at a certain position within a field, use the OFFSET parameter, specifying
the required position in <position>.
 The system then places the cursor at the corresponding offset position, counting from the beginning
of the field.

© SAP AG BC410 5-32


1.33
Screen Programs: GUI Status for Screens

Principlesof
Principles of screen
screenprogramming
programming

Screenobjects
Screen objects

Dynamicscreen
Dynamic screenmodifications
modifications

Screenprocessing
Screen processing

GUIstatus
GUI statusfor
forscreens
screens

 SAP AG 1999

© SAP AG BC410 5-33


1.34
GUI Status for Screens

Screen
Painter
PROCESS
PROCESS BEFORE
BEFORE OUTPUT.
OUTPUT.
MODULE set_status_100.
MODULE set_status_100.

ABAP
MODULE set_status_100 OUTPUT.
SET TITLEBAR Create Status
'TITLE_100'.
SET PF-STATUS Program xxxxx
'STATUS_100'.
Status STATUS_100
ENDMODULE.
Status Attributes
Short text Status for screen 100
Status type
Dialog status
Dialog box
Context menu
Double-click

 SAP AG 1999

 A GUI status is made up of a menu bar, a standard toolbar, an application toolbar, and of
function key settings. A single screen can have more than one status. You should use a module
set_status_<nnnn> in the PBO (Process Before Output) event of each of your screens to assign a
GUI status and a GUI title to it.
 There are three ways to create a status: from the object list in the Objet Navigator, from the Menu
Painter, or by forward navigation from the ABAP Editor. The status type describes the technical
attributes of the status. Choose Dialog status if you want use the status with a screen in fullscreen
mode, and dialog box, if you are going to use it with a dialog box. Context menus are special menus
that you can attach to the right-hand mouse button. They are described in a separate unit.
 When you change a status, you must activate it before the changes become visible.

© SAP AG BC410 5-34


1.35
Display Standards

Select reserved Icon Function key Function code


function keys
Enter
F11 SAVE
F3 BACK
Ctrl-F3 EXIT
F12 CANCEL

Menu bar Status_100

Display standards
Object Edit Goto Extras Environ.

Application toolbar Status_100


F key assignment Status_100

 SAP AG 1999

 To ensure consistency, you should reuse existing menu bars, application toolbars, and key settings
wherever possible. The Menu Painter administers the links you establish between these objects so
that any changes apply to all other statuses that use them. There is also a set of standard menu
entries that you can use as a template and modify.
 When you assign functions to the reserved function keys in the standard toolbar, you should adhere
to the SAP standards. This makes your program easier for users to understand and for you to
maintain. For further information, refer to the SAP Style Guide.

© SAP AG BC410 5-35


1.36
Processing the Function Code

Screen
Screen
PROCESS
PROCESS AFTER
AFTER INPUT.
INPUT. Painter
Painter
MODULE
MODULE save_ok_code.
save_ok_code.
MODULE
MODULE user_command_100.
user_command_100.
Function key: F3
Function code: BACK
Function type: ' ' ABAP
ABAP
DATA:ok_code
DATA:ok_code LIKE
LIKE sy-ucomm,
sy-ucomm,
save_ok
save_ok LIKE
LIKE ok_code.
ok_code.

MODULE
MODULE save_ok_code
save_ok_code INPUT.
INPUT.
save_ok
save_ok == ok_code.
ok_code.
CLEAR
CLEAR ok_code.
ok_code.
General Attributes ENDMODULE.
ENDMODULE.

Field name Type . . . MODULE


MODULE user_command_100
user_command_100 INPUT.
INPUT.
... CASE
CASE save_ok.
save_ok.
OK_CODE OK WHEN
WHEN 'BACK'.
'BACK'.
LEAVE
LEAVE TO
TO SCREEN
SCREEN 0.
0.
ENDCASE.
ENDCASE.
Screen
Screen Painter
Painter ENDMODULE.
ENDMODULE.
Element
Element list
list
 SAP AG 1999

 When the user triggers a function with type ' ' using a pushbutton, menu entry, or function key, the
system places the relevant function code in the OK_CODE field of the screen.
 To allow you to process this field in the PAI event, you must assign a name to the field, which you
enter in the element list in the Screen Painter. You must then create a field in your ABAP program
with the same name. During the automatic field transport at the beginning of the PAI event, the
function code is passed from the screen to the corresponding field in the program.
 To avoid the function code leading to unexpected processing steps on the next screen (ENTER does
not usually change the OK_CODE field), you should initialize the function code field in the ABAP
program before leaving the screen, otherwise it will be transported back to the screen automatically
in the PBO event.

© SAP AG BC410 5-36


1.37
Screen Programming: Summary

You are now able to:

 Create and process screens


 Use a GUI interface for navigation

 SAP AG 1999

© SAP AG BC410 5-37


Introduction to Screen Programming: Exercises

Unit: Introduction to Screen Programming


Theme: Creating a screen and using it in an executable
program

At the conclusion of these exercises, you will be able to:


 Create screens and use them in your programs.

Create a maintenance screen for your program. Design an interface for it.
The user should see the screen after double-clicking a line on the basic
list.

5-1 Create a screen and include it in your program.


5-1-1 Extend your program Z##BC410_SOLUTION from the previous exercise
(or copy the model solution SAPBC410ILSS_INTERACTIVE_LIST2).
You can use the model solution SAPBC410DIAS_DYNPRO for
orientation.
5-1-2 In the AT LINE-SELECTION event, call screen 100.
5-1-3 Create the following program object:

Screen 0100 Short description:


Maintenance screen
Type: Normal
Next screen: 100

5-1-4 In the PBO event of screen 100, call a module status. Use forward
navigation to create the module in a new include.
Z##BC410_SOLUTIONO01 PBO module include. In this
module, set the GUI status STATUS_100 and GUI title TITEL_100 (Flight
data (&)) and pass “Display” to the title as a parameter. Use a text element
for the parameter, to ensure that it can be translated. You can create the
status and title by forward navigation.
Assign the type Dialog status to the status. Activate the standard function
BACK (F3) with the function type ‘ ’ (space).
5-1-5 Assign the name ok_code to the function code field on your screen, and
create a corresponding variable in the top include of your program.

© SAP AG BC410 5-38


5-1-6 In the PROCESS AFTER INPUT event of screen 100, call the modules
save_ok_code and user_command_100. Use forward navigation to create
the modules in a new include
Z##BC410_SOLUTIONI01 PAI module include. Ensure that
the user can return from screen 100 to the basic list if he or she chooses
BACK (F3).
5-1-7 Make sure that you have inserted the necessary INCLUDE statements in
your main program.

© SAP AG BC410 5-39


Introduction to Screen Programming: Solutions
Unit: Introduction to Screen Programming
Theme: Creating a screen and using it in an executable
program

5-1 Model solution SAPBC410DIAS_DYNPRO


Add the coding in bold type to your program. Create the new modules using forward
navigation.
----------------------------------------------------------------------------------------------------------------
Flow logic for screen 100

PROCESS BEFORE OUTPUT.

MODULE status.

PROCESS AFTER INPUT.

MODULE save_ok_code.
MODULE user_command_100.

------------------------------------------------------------------------------------------------
Main program
*&-----------------------------------------------------------------*
*& program SAPBC410DIAS_DYNPRO *
*& *
*&-----------------------------------------------------------------*

INCLUDE BC410DIAS_DYNPROTOP.
INCLUDE BC410DIAS_DYNPROE01.
INCLUDE BC410DIAS_DYNPROF01.
INCLUDE BC410DIAS_DYNPROO01.
INCLUDE BC410DIAS_DYNPROI01.

----------------------------------------------------------------------------------------------------------------
Top include
fields for ok_code processing
DATA: ok_code LIKE sy-ucomm,
save_ok LIKE ok_code.

© SAP AG BC410 5-40


----------------------------------------------------------------------------------------------------------------
Event include

*&-----------------------------------------------------------------*
*& Event AT LINE-SELECTION.
*&-----------------------------------------------------------------*
AT LINE-SELECTION.
CALL SCREEN 100.

----------------------------------------------------------------------------------------------------------------
PBO module include

*------------------------------------------------------------------*
***INCLUDE BC410DIAS_DYNPROO01.
*------------------------------------------------------------------*
*&-----------------------------------------------------------------*
*& Module STATUS OUTPUT
*&-----------------------------------------------------------------*
MODULE status OUTPUT.
SET PF-STATUS 'STATUS_100'.
SET TITLEBAR 'TITLE_100' WITH 'View'(m01).
ENDMODULE. " STATUS OUTPUT

----------------------------------------------------------------------------------------------------------------
PAI module include
*------------------------------------------------------------------*
***INCLUDE BC410DIAS_DYNPROI01.
*------------------------------------------------------------------*
*&-----------------------------------------------------------------*
*& Module USER_COMMAND INPUT
*&-----------------------------------------------------------------*
MODULE USER_COMMAND_100 INPUT.
CASE SAVE_OK.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND INPUT

© SAP AG BC410 5-41


*&-----------------------------------------------------------------*
*& Module SAVE_OK_CODE INPUT
*&-----------------------------------------------------------------*
MODULE SAVE_OK_CODE INPUT.
SAVE_OK = OK_CODE.
CLEAR OK_CODE.
ENDMODULE. " SAVE_OK_CODE INPUT

© SAP AG BC410 5-42

You might also like