Contents:: Introduction To Screen Programming
Contents:: Introduction To Screen Programming
Contents:: 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 1999
5
6 Flight 7
8
11
9 12
10
2 4
SAP AG 1999
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
Table control
From Arrive
Country DE
City Berlin
Time 10:10:00
SAP AG 1999
Database
table
ABAP
processing
block
Process
Before
Output
Process
After
Input
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).
Principlesof
Principles of screen
screenprogramming
programming
Screenobjects
Screen objects
Dynamicscreen
Dynamic screenmodifications
modifications
Screenprocessing
Screen processing
GUIstatus
GUI statusfor
forscreens
screens
SAP AG 1999
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.
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.
General attributes
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.
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.
Principlesof
Principles of screen
screenprogramming
programming
Screenobjects
Screen objects
Dynamicscreen
Dynamic screenmodifications
modifications
Screenprocessing
Screen processing
GUIstatus
GUI statusfor
forscreens
screens
SAP AG 1999
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.
Display/change Display/change
A A
B B
SAP AG 1999
Screen
Painter
Element list: Modification groups
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.
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.
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 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.
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.
Screen attributes
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.
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
Object
Object
Navigator
Navigator Create Screen
<Program name>
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>.
References
Modification Groups
Display Attributes
Special Attributes
Texts and I/O Fields
General Attributes
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
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.
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
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.
IDENTICAL NAMES
Time
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 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.
Screen
Screen Attributes
Attributes Screen Attributes
Screen
Screen number
number 100
100 Screen number 300
Next
Next screen
screen 200
200 Next screen 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.
Screen
Screen Attributes
Attributes Screen Attributes
Screen
Screen number
number 100
100 Screen number 300
Next
Next screen
screen 200
200 Next screen 301
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.
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.
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).
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
Principlesof
Principles of screen
screenprogramming
programming
Screenobjects
Screen objects
Dynamicscreen
Dynamic screenmodifications
modifications
Screenprocessing
Screen processing
GUIstatus
GUI statusfor
forscreens
screens
SAP AG 1999
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.
Display standards
Object Edit Goto Extras Environ.
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.
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.
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 1999
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-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.
MODULE status.
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.
*&-----------------------------------------------------------------*
*& 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