Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 57

DIALOG PROGRAMMING

02-Sep-09

Kaavian Systems

Transactions
A Transaction is a program that conducts a
dialog with the User
In a typical dialog, the system displays the screen
on which the user

can enter or request

information.
As per the user input or request, transaction is
used to
- Branch to the next Screen
- Display an output
- Change/Update the database

02-Sep-09

Kaavian Systems

Central Components of a
Program

ABAP/4 Development Workbench

ABAP/4 Screen
Dictionary Painter

ABAP/4
Editor

Menu
Painter

Runtime environment
Online processor

02-Sep-09

ABAP/4 Processor

Kaavian Systems

Components
Structure of the Dialog Programming

Screen Painter

Menu Painter

Input Checks

Error Handling

Flow Logic

Screen Modification

Table Control

Tab strip

02-Sep-09

Kaavian Systems

Structure of the Dialog


Programming
Program Name

Dictionary Structure

Global Data

PBO Modules

PAI Modules

Subroutines

Screens

GUI Status

Transaction Code

02-Sep-09

Kaavian Systems

Screen Painter (SE51)


Each Screen contains fields used to
display or request Information. The fields can be
text String, Input/Output fields, Radio Buttons,
Check boxes or Pushbuttons.

Each screen consists of

Screen Attributes

Screen Elements

Screen Fields

Screen Flow Logic

02-Sep-09

Kaavian Systems

Screen Attributes
Program (type M)
Screen Number :
A four-digit number, unique within the ABAP
program, that identifies
the screen within the program.

Screen Type:
A normal screen occupies a whole GUI window.
Modal dialog boxes only cover a part of a GUI window. A
subscreen is a screen that you can display in a subscreen
area on a different screen in the same ABAP program.

Next Screen :
Specifies the next screen.

Hold Data :
Kaavian
Systems
If the user
calls
the screen more than once
during a terminal session, he or she can retain changed data

02-Sep-09

Screen Elements
Text Fields:

Display elements, which cannot be changed

either by the user or by the ABAP program.

Input/Output Fields:

Used to display data from the

ABAP program or for entering data on the screen. Linked to


screen fields

Radio Buttons:

Special input/output fields that are

combined into groups. Within a radio button group, only a


single button can be selected at any one time.

Check boxes:

Special input/output fields which the user

can select (value X) or deselect (value SPACE).


02-Sep-09

Kaavian Systems

Screen Elements
Pushbuttons:

Elements on the screen that


trigger the PAI event of the screen flow logic when
chosen by the user. There is a function code attached
to each pushbutton, which is passed to the ABAP
program when it is chosen.

Subscreen:

Area on the screen in which you can


place another screen.

Table Controls: Tabular input/output fields.


Tab Strip Controls:

Areas on the screen in


which you can switch between various pages.

Status Icons:

Display elements, indicating the


status of the application program.

Ok_Code Field
02-Sep-09

Kaavian Systems

Screen Fields
Screen fields are fields in the working memory
of a screen. Their contents are passed to
identically-named fields in the ABAP program in
the PAI event, and filled from the same
identically-named fields in the program in the
PBO event. The screen fields are linked with the
input/output fields.

02-Sep-09

Kaavian Systems

10

Screen Flow logic

Screen flow logic drives the processing sequence


for the screen
How the program reacts to user actions

Screen processing events include

02-Sep-09

PBO (process before output)


Before a screen appears
Used to initialize screen fields and global
variables
PAI (process after input)
After a user has selected a function key, menu
item, etc
POV (process on value request)
On F4 (request for list of possible values)
POH (process on help
Kaavian request)
Systems
On F1 (request for help information)

11

Leaving Screen
Syntax:

LEAVE TO SCREEN <screen number>.


(or)
SET SCREEN <screen number>.
LEAVE SCREEN.
LEAVE TO SCREEN 0.
From called screen
From main screen

02-Sep-09

Kaavian Systems

12

Leaving to List Processing


To pass control from the dialog processor to the list
processor, the following statement must be included in
one of the dialog modules:
LEAVE TO LIST-PROCESSING [AND RETURN TO SCREEN
<nnnn>].
Leaving to list processing in two ways:
By leaving the basic list using the Back, Exit, or
Cancel function.
By using the following statement during list
processing:
LEAVE LIST-PROCESSING.
02-Sep-09

Kaavian Systems

13

Processing User Request


To ensure that a PAI module is only called when a certain
condition applies by using the following statement:
FIELD <f> MODULE <mod> ON INPUT|REQUEST|*INPUT.
Additions:

02-Sep-09

On Input
On Request

Kaavian Systems

14

Processing User Request


To ensure that one or more PAI modules are only called
when several screen fields meet a particular condition,
all the calls in the flow logic must be combined to form
a

processing

chain.

The

processing

chains

are

performed as follows:
CHAIN.
FIELD: <f1>, <f 2>,...
MODULE <mod1> ON CHAIN-INPUT|CHAINREQUEST.
FIELD: <g1>, <g 2>,...
MODULE <mod2> ON CHAIN-INPUT|CHAINREQUEST.
...
ENDCHAIN.
02-Sep-09

Kaavian Systems

15

Modules

Simple module calls are processed in the sequence in


which they appear in the screen flow logic.

The syntax of the screen language also allows to make


PAI module calls dependent on certain conditions by
using the MODULE statement together with the FIELD
statement.

Conditional module calls can help to reduce the


runtime of the program

02-Sep-09

Kaavian Systems

16

Menu Painter

SET TITLEBAR T01 WITH v1 v2 v3 v4


Example:
Module status_100.
SET TITLEBAR T01 with EKKO-EBELN.
Endmodule.

SET PF-STATUS xxxxxxxx.


SET PF-STATUS xxxxxxxx EXCLUDING
<itab>.
Example:
Module Status_100 on input.
SET PF-STATUS PF0100.
End Module.

02-Sep-09

Kaavian Systems

17

Input Checks
Field format Check :
This format limits the kind of input that is
valid.
For ex. , a DATS field (Date field) is an 8 char
string in YYYYMMDD format. All char must be
numbers . For the given value entered, the system
checks that the day value is valid.

Required Check :
In the screen painter you can set a fields
required Input Attribute . The system requires the
user to enter the input before entering PAI
Processing.

Foreign Key Check :


The field can have a foreign key relationship
with another table or its domain can specify a fixed
02-Sep-09
Kaavian Systems
value list for the field.The
system checks the user
input value can be found in the related check table or

18

Field Format Check


Screen
Painter

Field list
Field name Format
DATE
.
.
.

DATE

AMOUNT

Date

02-Sep-09

31.11.1993

DEC

Date

3A9Y

Amount 11.13.1996

Amount 12A3

E: Invalid date

E: Please enter numeric value


Kaavian Systems

19

Required Field
Screen
Painter

Field list

Field name OBLIGATORY


TEST FIELD

02-Sep-09

Kaavian Systems

20

Foreign Key Check


ABAP/4
Dictionary
Field nameCheck table
.
.
.
FIELD1
.
.
.

P1
Check table
KEY
A
B
C
.
.
.

Screen
Painter

Field list

P1

Field
Foreign key
FIELD1 X
Check
Field1C
02-Sep-09

Kaavian Systems

21

Input Check in the Module Pool


The FIELD..MODULEstatement checks the
validity for a particular screen field.
Screen
PROCESS AFTER INPUT.Painter
FIELD <screen field>
MODULE <module>.

ABAP/4
MODULE <module> INPUT.
.
.
.
MESSAGE E ... .
ENDMODULE.

E...Message
02-Sep-09

Kaavian Systems

22

Input Check in the Module Pool


Example
PROCESS
PROCESS AFTER
AFTER INPUT.
INPUT.
FIELD
FIELD SCOUR-COURSE
SCOUR-COURSE
MODULE
MODULE CHECK_SCOUR.
CHECK_SCOUR.

MODULE
MODULE CHECK_SCOUR
CHECK_SCOUR INPUT.
INPUT.

Screen
Painter

ABAP/4

SELECT
SELECT SINGLE
SINGLE ** FROM
FROM SCOUR
SCOUR
WHERE
WHERE AREA
AREA =
= SCOUR-AREA
SCOUR-AREA
AND
AND COURSE
COURSE =
= SCOUR-COURSE.
SCOUR-COURSE.
IF
IF SY-SUBRC
SY-SUBRC NE
NE 0.
0.
MESSAGE
MESSAGE E123
E123 WITH
WITH 'SCOUR'.
'SCOUR'.
ENDIF.
ENDIF.
ENDMODULE.
ENDMODULE.
02-Sep-09

Kaavian Systems

23

Field Group-Related Checks


Screen
PROCESS AFTER INPUT.Painter
CHAIN.
FIELD: <screen field1>,
<screen field2>,
.
.
.
<screen field n>.
MODULE <module>.
ENDCHAIN.

ABAP/4
MODULE <module> INPUT.
.
.
.
MESSAGE E ... .
ENDMODULE.

1
..
.

E... Message
1 Ready for Input
02-Sep-09

Kaavian Systems

24

Field Group-Related Checks


Example
PROCESS
PROCESS AFTER
AFTER INPUT.
INPUT.
CHAIN.
CHAIN.
FIELD:
FIELD: SCOUR-AREA,
SCOUR-AREA, SCOUR-COURSE.
SCOUR-COURSE.
MODULE
MODULE CHECK_FIELD.
CHECK_FIELD.
ENDCHAIN.
ENDCHAIN.

MODULE
MODULE CHECK_SCOUR
CHECK_SCOUR INPUT.
INPUT.

Screen
Painter

ABAP/4

SELECT
SELECT SINGLE
SINGLE ** FROM
FROM SCOUR
SCOUR
WHERE
WHERE AREA
AREA =
= SCOUR-AREA
SCOUR-AREA
AND
AND COURSE
COURSE =
= SCOUR-COURSE.
SCOUR-COURSE.
IF
IF SY-SUBRC
SY-SUBRC NE
NE 0.
0.
MESSAGE
MESSAGE E123
E123 WITH
WITH 'SCOUR,COURSE.
'SCOUR,COURSE.
ENDIF.
ENDIF.
ENDMODULE.
ENDMODULE.
02-Sep-09

Kaavian Systems

25

Error Handling

Error (E)

Warning (W) - Displays Warning Message on the current

- Displays Error Message on the current screen

screen

Information (I) - Displays Popup Message on the current


screen

Abend (A) - The current Transaction will be Terminated

Success (S)

- Message is displayed on the Following

screen

02-Sep-09

Kaavian Systems

26

Error Handling Overview


PROCESS AFTER INPUT.
CHAIN.
FIELD: <screen field 1>,
<screen field 2>.
MODULE CHECK.
ENDCHAIN.

Screen
Painter

ABAP/4
PROGRAM B220MAIN MESSAGE-ID <id>.
.
.
.
MODULE CHECK INPUT.
.
.
.
IF SY-SUBRC ...

MESSAGE <qnnn>
WITH <value 1>..<value 4>.
ENDIF.
ENDMODULE.
02-Sep-09

Kaavian Systems

27

Dynamic Screen Modification

Display

Change

Change <-> Display

Change <-> Display

A
B

A
B

Output template

02-Sep-09

Input/output
template

Kaavian Systems

28

Field Attributes You Can Modify


Dynamically
Field and its attrib. active
SCREEN-ACTIVE

02-Sep-09

Required entry field

SCREEN-REQUIRED

Input field

SCREEN-INPUT

Output field

SCREEN-OUTPUT

Highlighted

SCREEN-INTENSIFIED

Invisible

SCREEN-INVISIBLE

Shorter output length

SCREEN-LENGTH

Kaavian Systems

29

Dynamic Screen Modifications:


Program

PROCESS
BEFORE OUTPUT.
..
.
MODULE
MODIFY_SCREEN.
..
.

Screen
Painter

ABAP/4
MODULE
MODIFY_SCREEN OUTPUT.
..
.

LOOP AT SCREEN.
IF SCREEN-GROUP1 = 'GR1'.
SCREEN-INPUT = 1.
ENDIF.
IF SCREEN-NAME = 'TAB-FELD'.
SCREEN-ACTIVE= 0.
ENDIF.
MODIFY SCREEN.

ENDLOOP.
02-Sep-09

Kaavian Systems

30

Subscreens
Subscreens allows to expand the content of a screen
dynamically at runtime.
For example,
Screen exits, which are part of the enhancement
concept, use
the subscreen technique.
Some complex screen elements, like tabstrip
controls, also use
them.
Prerequisite to use a subscreen:

02-Sep-09

Define the subscreen area(s) on a screen.


Define suitable subscreen screens.
Include the subscreen screen in the
subscreen area.
Kaavian Systems

31

Screen Tables
A screen table is a repeated series of table rows
in a screen. Each entry contains one or more fields,
and all rows have the same field structure.
Table controls and step loops are types of screen
tables you can add to a screen in the Screen
Painter.
These are the two mechanisms offered by ABAP/4
for displaying and using table data in a screen.
02-Sep-09

Kaavian Systems

32

Table Controls

With table controls, the user can:


Scroll through the table vertically and
horizontally
Re-size the width of a column
Select table rows or columns
Re-order the sequence of columns

02-Sep-09

Kaavian Systems

33

Mechanism of Table Control

To process table controls, data is from the database into


an intermediary internal table in the module pool.

During the PBO event, data is read line by line from the
internal table into the control table in screen painter.

During the PAI event, the contents and attributes of the


control table are once again fed line by line into the
internal table in the module pool, and then if necessary,
into the database.

Table controls are created in screen painter like other


fields. With the graphical screen painter table controls can
be selected and placed on the screen. In the alphanumeric
screen painter choose EDIT => Create Element => Table
control.

From within the ABAP program, the table control is


defined of type 'TABLEVIEW', which is a complex type
structure storing all of the attributes of the control table.

02-Sep-09

Kaavian Systems

34

Syntax for Table Controls


At PBO.
Loop at <itab> with control <name> cursor
<name>-top_line.
Module <mod_name>.
Endloop.

At PAI.
Loop at <itab>.
Endloop.

Declaration for table control.


controls <name> type tableview using screen
<no>.
02-Sep-09

Kaavian Systems

35

Tabstrip Controls
A tabstrip control is a screen object consisting of two
or more pages. Each tab page consists of a tab title
and a page area.
Tabstrip controls allow you to place a series
of screens belonging to an application on a
single screen
When you create a tabstrip control, you must:
Define the tab area on a screen and the tab
titles.
02-Sep-09

Assign a subscreenKaavian
area
to each tab title.
Systems
Program the screen flow logic.

36

Mechanism of Tabstrip
Before using a tabstrip control in theABAP program,
a control for each control in the declaration part of the
program using the following statement must be
created:
CONTROLS <ctrl> TYPE TABSTRIP.
Before the screen is displayed, the control is used to
set the tab page that is currently active. To do this,
assign the function code of the corresponding tab title
to the component ACTIVETAB:
<ctrl>-ACTIVETAB = <fcode>.
In the PAI event, ACTIVETAB contains the function
code of the last active tab title on the screen
02-Sep-09

Kaavian Systems

37

Leaving to a Transaction
To branch to another transaction and end the
current

one,

use

the

LEAVE

TO

TRANSACTION

statement:

Syntax :
LEAVE TO TRANSACTION '<TRAN>'.
Once the new transaction starts, the user can
not return to the previous transaction by pressing the
Exit icon. Any data the user did not save in the
previous transaction is lost.
02-Sep-09

Kaavian Systems

38

Calling a Transaction

If you want the user to be able to return to


the initial transaction after processing an interim
transaction, use the ABAP/4 statement:

Syntax:
CALL TRANSACTION '<TRAN>'.

02-Sep-09

Kaavian Systems

39

Suppressing the Transaction's


Initial Screen
When you call a transaction, you can tell the
system to suppress the transaction's initial screen and
proceed directly to the next screen in the sequence:

Syntax:
CALL TRANSACTION '<TRAN>' AND SKIP FIRST
SCREEN.
The

initial

screen

is

processed

but

not

displayed. while suppressing the first screen, for all


required fields in the initial screen, your program
must pass in data values when calling the transaction.
02-Sep-09

Kaavian Systems

40

Passing Data with SPA/GPA


Parameters

You can pass data to a called program using

SPA/GPA parameters. SPA/GPA parameters are field


values saved globally in memory. Each parameter is
identified by a three-character code.

There are
parameters:

two

ways

to

use

SPA/GPA

by setting field attributes in the Screen Painter

by using
PARAMETER

the

SET PARAMETER
statements

or

GET

Syntax:
SET PARAMETER ID 'RID'
<FIELD NAME1>.
KaavianFIELD
Systems
GET PARAMETER ID 'RID' FIELD <FIELD

02-Sep-09

41

Programming Field- and ValueHelp


You can program help texts and possible
values lists using the PROCESS ON HELP-REQUEST
(POH)

and

PROCESS

ON

VALUE-REQUEST

(POV)

events.

Syntax:
PROCESS ON HELP-REQUEST.
FIELD <field> MODULE <module>.
PROCESS ON VALUE-REQUEST.
FIELD <field> MODULE <module> .
02-Sep-09

Kaavian Systems

42

Creating Screens
We can create a screen using
Transaction SE51

Click the create button


02-Sep-09

Kaavian Systems

43

Graphical Screen Editor

02-Sep-09

Kaavian Systems

44

Screen Table Processing


Enter the Table or field name on the Table/Field
name and click on the Get from program

02-Sep-09

Kaavian Systems

45

Screen Table Processing


Now write the code for the PBO, PAI, PVR and POH
for this screen flow logic

02-Sep-09

Kaavian Systems

46

Screen Table Processing


In the PBO write the relevant code for PF-STATUS
and TITLE BAR

Click on the SAVE icon to save the code .


02-Sep-09

Kaavian Systems

47

Menu Editor (SE41)


This is a GUI status containing buttons and
menus for the screen. All ABAP programs will
have a default GUI status.

02-Sep-09

Kaavian Systems

48

Title Bar
The title Bar of the window that you will use to
display.

02-Sep-09

Kaavian Systems

49

Code
In the PAI of the flow logic we can use the
conditional statement

Click on the SAVE icon to save the code .


02-Sep-09

Kaavian Systems

50

Code for the Field check in the PAI


module

Click on the SAVE icon to save the code.


02-Sep-09

Kaavian Systems

51

Modules
In this module we can even write the code to
Retrieve the Data, Branching to Different Screen
and also use function codes.

02-Sep-09

Kaavian Systems

52

Changing Screen Attributes Dynamically


Depending on the user requirements in the
previous screen 100, you can dynamically change
the Attributes of the object using SCREEN
Attributes in the screen 200.

02-Sep-09

Kaavian Systems

53

POV
In the Process on value request (POV) of the flow
logic we can use the search help for a particular
field

02-Sep-09

Kaavian Systems

54

Example
We will design the screen with a text object and the
table control object

02-Sep-09

Kaavian Systems

55

Reference

The
learning
material
contained
in
this
PowerPoint
Presentation is prepared with the help of http://help.sap.com/
and sap press book. All rights reserved by SAP AG.
Unless otherwise specifically stated, this learning material is
intended for the sole purpose of class room session, internal use
and for knowledge transfer to the Consultants.
However, for detailed information on this learning material,
http://help.sap.com / sap press book may be referred.
Kaavian is not liable for any legal liability or responsibility for
the accuracy, completeness or usefulness of any information
disclosed in these learning materials.
No portion of the learning materials
shall be modified,
reproduced or transmitted in any form by any means, whether
by electronic, photocopier or otherwise without the written
permission of Kaavian. In no event shall Kaavian be liable for
any damage whatsoever resulting in any action arising in
connection with the use of learning material.

02-Sep-09

Kaavian Systems

56

THANK YOU

02-Sep-09

Kaavian Systems

You might also like