Database tables
Database views
Structures
Data elements
Domains
Search helps
Lock objects
Data elements
Each field refers to a data element that describes the
meaning of the field
Domain
Determines the technical properties of the field
Data type and size (including number of decimal places)
Allowed data values
Output characteristics
The Data Dictionary
Domain
Provides the technical description
Element
Determines the role played
Create a domain called id_number
Create elements student_id and staff_id based on
the id_number domain
Customer Table
fields
Data
Elements
Domain
z_phonew
Label: work number
phone_w
phone_f
zphone
z_phonef
Label: fax number
phone_h
type: char
len: 12
z_phoneh
Data Element
Definition
Field Information
Tables
12
13
Transparent table
Pooled table
Cluster table
14
Pooled Table
15
Clustered Table
16
From the
Data dictionary
Click on the table radio button & enter the table name
From the dictionary table: table/structure: display fields
screen choose utilitiestable contents
Sort Buttons
Table Name
Database Views
20
Database Views
21
Projection Views
22
Help Views
23
Maintenance View
24
Integrity Checking
Domain range/value integrity checks
Value table
Only values contained in the value table can be
entered in fields referring to this domain
Fixed values
Only values that match a value in the user specified
list of admissible values can be entered in fields
referring to this domain
26
Integrity Checking
Referential integrity checking
Check table
Foreign key values must match an entry in the
specified check table
Check tables bound to input fields on data entry
screens
Position the cursor on input field and press F4 to
get a list of permissible values
The default check table for a field is the value table
of the underlying domain
From the dictionary: table/structure: display fields
screen, select GoToforeign
The Data Dictionary keys (F8)
27
ABAP Commands
Move Statements
Write To Statements
ABAP Commands
30
Move Statements
MOVE f TO g.
MOVE f+off1(len1) TO
g+off2(len2).
MOVE c1 TO c2 PERCENTAGE n.
Move-corresponding itab1 to
itab2.
ABAP Commands
31
Write To Statements
WRITE f TO g[+off][(len)].
WRITE f TO itab[+off][(len)] INDEX
idx.
ABAP Commands
32
DONTS.
MOVE-CORRESPONDING
ITAB1 TO ITAB2.
ABAP Commands
33
Condense
Shift
Split
ABAP Commands
Replace
Translate
34
Translate STATMENTS
TRANSLATE c TO UPPER CASE.
TRANSLATE c TO LOWER CASE.
Example :
DATA letters(3) TYPE C.
MOVE xyz' TO letters.
TRANSLATE letters TO UPPER CASE.
TRANSLATE letters TO UPPER CASE.
ABAP Commands
35
Replace Statements
REPLACE f ...WITH g
...INTO h.
Example :
Data field(10).
Move XYZAB' to field.
REPLACE 'B' WITH 'string' INTO
Field.
ABAP Commands
36
Concatenate Statements
CONCATENATE f1 ... fn INTO g.
Additions :
.. Separated by h .
Example :
DATA: ONE(10) VALUE 'john',
TWO(3) VALUE 'F.',
THREE(10) VALUE 'Kennedy',
NAME(20).
Concatenate one two three into name separated by space.
ABAP Commands
37
Condense Statements
CONDENSE c.
Additions :
No-gaps.
Example :
DATA: BEGIN OF NAME,
TITLE(8)
VALUE ' dr.',
FIRST_NAME(10) VALUE 'Michael',
SURNAME(10) VALUE 'Hofmann',
END OF NAME.
Condense name no-gaps.
Output :
Dr.MichaelHofmann
ABAP Commands
38
Split Statements
SPLIT f AT g INTO h1 ... hn.
SPLIT f AT g INTO TABLE itab.
ABAP Commands
39
ABAP Commands
40
Contd
Types: begin of ITAB_type,
word(20),
end
of ITAB_type.
Data: ITAB type standard table of ITAB_type
with non-unique default key initial size 5.
SPLIT 'STOP two STOP three STOP
'STOP' INTO TABLE ITAB.
ABAP Commands
' AT
41
Shift Statements
SHIFT c.
SHIFT c BY n PLACES.
SHIFT c UP TO c1.
SHIFT c LEFT DELETING LEADING c1.
SHIFT c RIGHT DELETING TRAILING c1.
ABAP Commands
42
ABAP Commands
43
Contd
Variants :
Shift c by n places
Example :
Data: alpha1(10) type c value
'ABCDEFGHIJ',
alpha2 type string,
five
type i value 5.
Alpha2 = alpha1.
Shift alpha1 by five places.
Shift alpha2 right by 2 places.
ABAP Commands
44
Contd
Other variants :
SHIFT c LEFT DELETING LEADING c1.
SHIFT c RIGHT DELETING TRAILING c1
ABAP Commands
45
46
ABAP Commands
47
GE / >=
LE / <=
GT / >
LT / <
NE / <>
ABAP Commands
48
Useful Keywords
Initial
If w_var1 is initial.
..
ENDIF.
Space
Data : w_var1 type c.
If w_var1 is space.
..
ENDIF.
ABAP Commands
49
IF VAR1 GT VAR2 .
WRITE : TEST1.
WRITE : TEST1.
ELSE.
WRITE : TEST2.
WRITE : TEST2.
ENDIF.
ENDIF.
ABAP Commands
50
51
Continue Statements
Continue
Effect :
CONTINUE terminates the current loop pass, return the processing to the
beginning of the loop and starts the next loop pass, if there is one
Example :
Do 100 times.
If SY-index >= 10 and SY-index <= 20.
Continue.
ENDIF.
...
Enddo.
ABAP Commands
52
Exit Statements
Exit :
Effect :
Within a loop structure:
terminates loop processing (DO, WHILE, LOOP,
SELECT).
Within subroutines and other modularization
units (but not in a loop structure):
leaves the subroutine or modularization unit
(FORM, MODULE, FUNCTION, TOP-OF-PAGE,
END-OF-PAGE).
ABAP Commands
53
More Looping
DO.
WRITE: / 'SY-INDEX
W_INDEX = W_INDEX + 1.
WRITE: W_INDEX
IF SY-INDEX = 10.
EXIT.
ENDIF.
ENDWHILE.
ABAP Commands
54
DATABASE Commands
Update
Modify
Delete
Insert
Select
ABAP Commands
55
56
57
INSERT dbtab
INSERT (dbtabname)
FROM TABLE itab.
[CLIENT SPECIFIED]
ABAP Commands
58
MODIFY dbtab.
MODIFY *dbtab.
MODIFY (dbtabname) ... .
MODIFY dbtab
FROM TABLE itab.
MODIFY (dbtabname) FROM TABLE itab.
ABAP Commands
59
ABAP Commands
60
WA_SBOOK-CUSTTYPE, WA_SBOOK-smoker,
WA_SBOOK-LUGGWEIGHT, WA_SBOOK-WUNIT,
WA_SBOOK-invoice.
ENDSELECT.
ABAP Commands
61
62
63
Contd ...
Select ESLL~ktext1 ESLL~MENGE ESLL~MEINS
ESLL~NETWR
Into table i_ESLL
From ESLH outer join ESLH
On ( ESLH~PACKNO = ESLL~PACKNO )
Where ESLH~HPACKNO EQ
GS_XEKPO-PACKNO
AND ESLH~DEL EQ c_space
AND ESLL~DEL EQ c_space
ABAP Commands
64
Join Conditions
ABAP Commands
65
Internal Tables
Internal Tables
67
Internal Tables
Database tables store long-life data
Internal tables store temporary data
Table calculations on subsets of database tables
Implementing complex data structures
Reorganize the contents of database tables
according to specific processing needs
Generate ranked lists
Combine contents from more than one database table
into a single table for easier processing
Internal Tables
68
Internal Tables
Used as
Snapshots of database tables
Containers for volatile data
69
Internal Tables
70
71
Internal Tables
72
Internal Tables
73
Internal Tables
74
Standard Tables
(History)
Release 2.2
Release 3.0
Header lines optional
Introduction of type concept
Release 4.0
Introduction of sorted & hashed table types
Allows key definition
& uniqueness attributes
Internal Tables
75
76
R/3 Database
Internal Tables
77
R/3 Database
Internal Tables
78
Ease of use
Dont have to explicitly move data into the work area
structure and then append the work area structure to the
table
80
Internal Tables
81
DATA:
begin of LineType,
F1,f2,
End of LineType.
itab TYPE STANDARD TABLE OF
LineType [WITH DEFAULT KEY]
Initial size 100
With header line.
Internal Tables
82
DATA:
begin of LineType,
F1,f2,
End of LineType.
itab TYPE SORTED TABLE OF
LineType WITH {NONUNIQUE|UNIQUE} KEY f1
With header line.
Internal Tables
83
DATA:
begin of LineType,
F1,f2,
End of LineType.
itab TYPE HASHED TABLE OF
LineType WITH UNIQUE KEY f1
Initial size 100
With header line.
Internal Tables
84
Declaring Internal
Tables
Internal Tables
85
Internal Tables
86
Data:
Internal Tables
87
Internal Tables
88
Accessing Internal
Tables table
work area
work area acts as interface for transferring data
read from table
contents of table line overwrite work area
program refers to work area
write to table
first enter data in the work area then transfer to table
Internal Tables
89
Internal Tables
90
Internal Tables
91
92
Append
APPEND [ <wa> TO | INITIAL LINE TO] <itab>
Appends new line to itab
<wa> TO specifies the source area
<wa>
INITIAL LINE TO appends line with
each field set to default values
according to field type
To be used only with STANDARD
table
Data:
Internal Tables
93
Collect
COLLECT [ <wa> INTO] <itab>
used to fill an internal table which has unique table key (or
standard key for standard table if no key defined):
standard key is combination of non-numeric key fields
if table entry exists with the same table key values as the
work area <wa> or the header line of the table
COLLECT adds the contents of the numeric fields of the work
area to contents of the numeric fields in the existing entry
else
COLLECT is the same as APPEND
Internal Tables
94
Collect
Often used to generate summary
information
data:
Internal Tables
95
Internal Tables
96
Collect
database
header line
abc 1 6
abc 1 6
def 5 4
def 5 4
internal table
insert
abc 1 6
abc 1 6
def 5 4
abc 1 7
abc 1 7
accumulate
abc 1 13
def 5 4
Insert
INSERT [ <wa> INTO | INITIAL LINE INTO] <itab>
[INDEX <idx>].
SY-TABIX
Holds the index of the current line in the table
SY-SUBRC
Return code for operation
SY-SUBRC = 0
Operation was sucessful
SY-SUBRC <> 0
Operation failed
SY-DBCNT
Number of lines that were affected by the operation
How many lines haveInternal
already
been processed
Tables
98
Internal Tables
99
Loop
LOOP AT <itab> [INTO <wa>] [FROM <n1>] [TO
<n2>] [WHERE <condition>].
Reads <itab> line by line
INTO <wa> specifies the target
area for tables without header
line
FROM & TO specify begin and
end index values (for
STANDARD and SORTED
table only)
data:
Internal Tables
100
Continue:
Control goes to the beginning of the loop.
Internal Tables
101
READ - by INDEX
READ TABLE <itab> [INTO <wa>] INDEX <idx>.
Reads the line with index
data: itab type standard table of
<idx> from table <itab>
spfli,
faster than accessing the
wa like itab.
table with the key value
if <idx> < 0 a runtime error select * into table itab from spfli.
occurs
INDEX valid only for
read table itab into wa index 7.
STANDARD and SORTED write: / wa-carrid, wa-connid.
table
INTO <wa> specifies the target
area for tables without header
line
Internal Tables
102
Internal Tables
103
READ - by KEY
READ TABLE <itab> [INTO <wa>]
KEY <key> [BINARY SEARCH].
WITH
Reads the line with key <key> data: itab type standard table of
from table <itab>
spfli,
system reads the first entry
wa like itab.
of itab which matches the
key value
select * into table itab from spfli.
INTO <wa> specifies the target read table itab into wa with key carrid
area for tables without header = LH connid = 0400.
line
write: / wa-carrid, wa-connid.
endloop.
Internal Tables
104
READ Variations
Defining a sequence of key fields
WITH KEY <k1> = <f1> <kn> = <fn>
105
Describe
DESCRIBE TABLE <itab> [LINES <lin>] [OCCURS
<occ>].
Internal Tables
106
Changing lines
Modify
Write to
Not recommended. Does not recognise the structure of
a table line. Overwrites section of table line even across
fields from start pos for length len
Deleting lines
Selected lines in a loop
Using the index
Adjacent duplicate lines
Internal Tables
107
Modify
MODIFY [TABLE] <itab> [FROM <wa>] [INDEX <idx>]
[TRANSPORTING <f1><fn>] [WHERE <cond>].
Replaces a line in <itab> with
contents of <wa>
INDEX option specifies the target
line of <itab>
can be used only with standard
and sorted table
without index, the target line is
determined by search key
TRANSPORTING moves only the
named fields from <wa> to <itab>
data:
Internal Tables
108
Delete
DELETE <itab>.
Deletes line from itab
can be used only in a loop
data:
Internal Tables
109
Delete
DELETE <itab> INDEX <idx>.
deletes line from itab with
data: itab type standard table of
index <idx>
spfli.
after deleting the line the index
of the following lines is
select * into table itab from spfli.
decremented by one
delete itab index 5.
not allowed with hashed table
Internal Tables
110
Delete
DELETE ADJACENT DUPLICATES
<itab> [COMPARING <comp>].
deletes all adjacent duplicate
lines from itab
without COMPARING
uses table key to determine
duplicates
with COMPARING
uses the contents of the
specified fields in <comp>
to determine duplicates
data:
FROM
Internal Tables
111
Delete
DELETE <itab> [FROM <n1>] [TO <n2>] [WHERE
<condition>].
deletes all lines from itab
where index is between n1 and
n2
without FROM
starts from first line
without TO
deletes to end of table
without WHERE
unconditional deletion of
lines between n1 and n2
data:
Internal Tables
112
Sort
SORT <itab> [<order>] [AS TEXT] [BY <f1> [<order>]
[AS TEXT] ... [BY <f1> [<order>] [AS TEXT] .
without BY
data: itab type standard table of
uses table key to sort
spfli.
<order>
ASCENDING or
select * into table itab from spfli.
DESCENDING
as TEXT
sort itab by carrid connid descending.
char fields sorted
alphabetically rather than by
internal binary
representation
Internal Tables
113
Appendsorted By
APPEND [<wa> TO] <itab> SORTED BY <f>.
Uses only with standard table
builds itab sorted by <f>
descending sort order
it <itab> is less then 100 lines
use APPEND SORTED BY
otherwise use SORT after
table is populated
table can contain only the
number of lines specified in the
OCCURS clause
data:
Internal Tables
114
Internal Tables
115
Standard Table
INSERT
COLLECT
MODIFY
DELETE
READ
LOOP
n
INSERT
APPEND
MODIFY
DELETE
READ
LOOP
SORT
Sorted Table
inserts in
correct position
sort sequence
may be broken
Internal Tables
see above
Hashed Table
works like append
No Index
Operations
116
Simple Reports
What Is a Report
Reports
118
119
120
Purpose of Report
Reports
122
Structure of Report
Reports
123
Reports
124
external control
event begin
processing block
internal control
event end
event keyword
external control
processing block
internal control
...
Reports
125
Internal Control
Statements
If
IF statements can be
nested to any level.
All IF statements must
be terminated with
ENDIF in the same
processing block.
IF logexpr1.
Processing1.
ELSEIF logexpr2.
Processing2.
Else.
processingN.
ENDIF.
Reports
126
Internal Control
Statements
Case
CASE f.
WHEN f11 or f12 or f1n.
Processing f1.
WHEN f21 or f22 or f2n.
Processing f2.
When .
When others.
Processing others.
ENDCASE.
F is a variable name
F11..fnn may be variables or
literals
CASE statements can be
nested
No further WHENs can follow
WHEN OTHERS
Reports
127
Iteration
Do ENDDO.
Loop ENDLOOP.
While ENDWHILE.
Select ENDSELECT.
Reports
128
Do ... Enddo
Variations
Do ... ENDDO.
DO n TIMES ... ENDDO.
Additions
VARYING f FROM f1 NEXT f2.
129
Do ... Enddo
Sum = 0.
Do
Sum = sum + sy-index.
Counter = counter + 1.
Write sum.
If counter > 10.
Exit.
endif.
Enddo.
Sum = 0.
Do 10 times
Sum = sum + sy-index.
Write sum.
Enddo.
Reports
130
Exit
Always leaves the current unit and the program
continues after that unit
Context sensitive
Only leaves inner structure if structures are nested
Can be used in
Unconditional loops (DO...Enddo)
Conditional loops (WHILE...Endwhile)
Subroutine (FORM...ENDFORM)
Reports
Function (FUNCTION...ENDFUNCTION)
131
Stop
Cancels all data selection
No further tables are read
Followed immediately by the END-OFSELECTION event
IF logexp.
Stop.
ENDIF.
Reports
132
Reject
Used in logical database processing
Stops processing the current database table
line and resumes with the next line of the
table on the same hierarchy level
IF logexp.
Reject.
ENDIF.
Reports
133
Continue
Terminates the current loop pass and returns
processing to the beginning of the next loop
pass (if there is one)
Excludes lines where logexp is true from the list
IF logexp.
Continue.
ENDIF.
Reports
134
Check
CHECK logexp
Evaluates the subsequent logical expression
Expression is true
Processing continues with the next statement
Expression is false
Terminates the current loop pass and goes back to the
start of the next loop pass (if there is one)
135
While Endwhile
Variations
WHILE logexp ... ENDWHILE.
Additions
VARYING f FROM f1 NEXT f2.
136
Select ENDSELECT
Used for processing lines of data returned
directly from a database table
Variations
SELECT < * | field list > [target]
FROM <table>
* Where +
* Group by +
* Order by +
ENDSELECT.
Reports
137
Endloop.
Additions
From n1
To n2
Where logexp
Reports
138
The ABAP
Processor
ABAP program is a collection of processing
blocks which are executed in response to
specific events
Processing blocks do not have to occur in any
specific order
At program start time the system starts a process,
(the ABAP processor)
Calls these modules
Controls the external
program flow
Reports
139
Events
INITIALIZATION
AT SELECTION-SCREEN OUTPUT
AT SELECTION-SCREEN
TOP-OF-PAGE
END-OF-PAGE
START-OF-SELECTION
GET Events
END-OF-SELECTION
TOP-OF-PAGE DURING
LINE-SELECTION
AT LINE-SELECTION
AT USER-COMMAND
Interactive Events
Reports
AT PF<nn>
140
141
Reports
142
Run-Time Events
Initialization
Processed before the presentation of the
selection screen
Can be used to initialise values in the selection
screen or to assign values to any parameters
that appear on the selection screen
Reports
143
Run-Time Events
At selection-screen
Processing block is started after the user has
specified all the criteria in the selection screen
If an error message is displayed from this
processing block the system displays the
selection screen again and all input fields can
be changed
Reports
144
Run-Time Events
Start-of-selection
Processing block that is executed after
processing the selection screen and before
accessing database tables using a logical
database
Use this processing block to set the value of
internal fields
All statements that are not attached to an
event keyword or in a subroutine are
processed in this event
Reports
145
Run-Time Events
End-of-selection
Processing block executed after the system has
read and processed all database table records
Reports
146
Top Of Page
147
End Of Page
Reports
148
At new <f> - beginning of a group of lines with the same contents in the field <f>
and in the fields left of <f>
2.
At end of <f> - end of a group of lines with the same contents in the field <f> and in
the fields left of <f>
3.
4.
Reports
149
control statement>
...
at end of <f2>.... ENDAT.
AT END OF <f1>.... ENDAT.
At last..... ENDAT.
Endloop.
Reports
150
151
Report Statement
152
Report Statement
153
SELECT Overview
SELECT <result>
which columns?
FROM <table>
which table?
INTO <target>
where to?
WHERE <condition>
which entries?
GROUP BY <fields>
ORDER BY <fields>
Reports
154
select * into wa
from spfli
where carrid = LH.
endselect.
select single * into wa
from spfli
where carrid = LH.
Reports
155
SELECT Clause
Select *
SELECT <f1> <f2> ... <fn>
SELECT *
returns all columns of the database table
SELECT <f1> <f2> ... <fn>
<f> can be either fields or aggregate functions
MIN, MAX, AVG, SUM, COUNT
NB. No commas between fields in field list
Reports
156
TABLE <itab>
selected data not processed line by line but all at once
Reports
157
WHERE
Reports
158
<operator>
EQ
GE
LE
=
>=
<=
NE
GT
LT
<>
>
<
=>
=<
><
Reports
159
<pattern>
special characters _ and %
_
represents a single character
%
represents any sequence of characters
160
Reports
161
ORDER BY
determines sort order of selected result table
162
Reports
163
Termination
The message appears in a dialog box, and the program terminates. When the
user has confirmed the message, control returns to the next-highest area menu.
Error
Information
The message appears in a dialog box. Once the user has confirmed the
message, the program continues immediately after the MESSAGE statement.
Status
The program continues normally after the MESSAGE statement, and the
message is displayed in the status bar of the next screen.
Warning
Exit
Reports
164
Messages in Reports
messages are stored in table T100
165
Messages in Reports
MESSAGE xnnn.
x is one of
I
Info
W Warning
list level
E
Error
list level
A
Abend
message
X
Exit
termination
S
Success
Displayed
Outcome
window
status line
resumes processing
terminates current
status line
terminates current
window
termination after
status line
immediate
status line
resumes processing
Reports
nnn is the message number
166
Messages in Reports
MESSAGE xnnn *WITH <f1><f4>+.
& characters serve as placeholders in a message
200 Level &1 not allowed here
WITH option allows contents of fields < fi > to replace the &i
according to the value of I
MESSAGE E200 WITH SY-LSIND.
Reports
167
Messages in Reports
MESSAGE ID <id> TYPE <x>
NUMBER <nnn> *WITH <f1> <f4>+.
allows a message to be specified dynamically at runtime
do not need the MESSAGE-ID xx option in the REPORT
statement
<id> is the message application area
<x> is the message type (I, W, E, A, X, S)
<nnn> is the message number
Reports
168
Write Statements
Write : / Var1 As Checkbox.
Write : / Var2 As Symbol.
Write : / Var3 As Icon.
Write : / Var4 As Line.
Reports
169
NO-ZERO
NO-SIGN
DD/MM/YY
LEFT-JUSTIFIED
RIGHT-JUSTIFIED
CENTERED
USING EDIT MASK mask
USING NO EDIT MASK
DECIMALS d
Reports
170
No grouping
CURRENCY w
EXPONENT e
ROUND r
Reports
171
Formatting of Report
172
field length
left-justified
field length
left-justified
11
22
right-justified
right-justified
2*fieldlength (+1)
right-justified
left-justified
left-justified
2*field length
Reports
left-justified
173
Positioning Output
WRITE AT [/] [pos] [(len)] <f> .
/ Denotes new line
<Pos>
Horizontal position
Always output at that position regardless of whether there is
enough space or other fields overwritten
(<Len>)
Output length
If <len> is too short
Numeric fields truncated (left), asterisk displayed
All others truncated (right) with no indication
Reports
174
Reports
01
175
LEFT-JUSTIFIED
RIGHT-JUSTIFIED
CENTERED
UNDER <g>
NO-GAP
USING EDIT MASK <m>
USING NO EDIT MASK
NO-ZERO
COLOR <c>
176
text
write: / c using edit mask _:_%_8_!. t:e%x8t!
Reports
177
NO-SIGN
DECIMALS <d>
EXPONENT <e>
ROUND <r>
CURRENCY <c>
UNIT <u>
178
DD/MM/YY
MM/DD/YY
DD/MM/YYYY
MM/DD/YYYY
DDMMYY
MMDDYY
YYMMDD
Reports
179
Reports
180
Format
formatting options used in a WRITE statement overwrite the
corresponding settings of a previously issued FORMAT
statement for the current output
for each new event the system resets all formatting options to
their default values
all options have a default value of OFF except the
INTENSIFIED option
FORMAT RESET
sets all formatting options to OFF in one go
Reports
181
COLOURS IN LISTS
FORMAT COLOR = <c>
INTENSIFIED = <int>
INVERSE =<inv>
Reports
182
<c>
Colour
Intended For
OFF or COL_BACKGROUND
1 or COL_HEADING
grey-blue
headings
2 or COL_NORMAL
light grey
list bodies
3 or COL_TOTAL
yellow
totals
4 or COL_KEY
5 or COL_POSITIVE
green
6 or COL_NEGATIVE
red
7 or COL_GROUP
violet
group levels
Reports
183
Color Examples
Data:
I type i value 0, col(15).
While I < 8.
Case I.
When 0. Col = COL_BACKGROUND.
When 1. Col = COL_HEADING.
When ...
endcase.
Format intensified color = I.
Reports
184
Reports
185
Vertical Lines
WRITE [AT [/] [<pos>] ] SY-VLINE.
WRITE *AT */+ *<pos>+ + |.
Blank Lines
SKIP [<n>]
SKIP TO LINE <n>.
Reports
186
ignored
Reports
187
188
SY-LINNI
Number of current line of current list
SY-COLNO
Number of column where cursor is positioned
in the current list
Reports
189
190
Selection Screens
Objective
Concepts associated with
Selection Screen
192
Selection Screens
Used to allow the user to control the database
selections of the report
Allows interactive
Assignment of values to variables
With the PARAMETERS statement
Selection Screen
193
194
Parameters
Used to enable user to enter values for single
fields on the selection screen
Define variables in the program using
PARAMETERS statement.
Basic form of PARAMETERS statement:
PARAMETERS <p>[(<length>)] [TYPE
<type>|like <obj>] [DECIMALS <d>].
Selection Screen
195
Parameters Variants
PARAMETERS <p> ...... DEFAULT <f> ......
PARAMETERS <p> ...... OBLIGATORY ......
196
PARAMETERS: P1 TYPE P,
P2(6) TYPE C DEFAULT ITB255.
P1
P2
ITB255
Selection Screen
Selection Screen
197
Select-options
Allow the user to easily handle complex
selections
Basic form of the SELECT-OPTIONS statement :
SELECT-OPTIONS <seltab> for <f>.
198
Select-options Contd..
Structure of selection tables
SIGN type C length 1
Values I or E
OPTION type c length 2
Values EQ, NE, LT, BT, etc.
199
Select-options Variants
SELECT-OPTIONS <seltab> FOR <f> DEFAULT
<g> [TO <h>] ....
SELECT-OPTIONS <seltab> FOR <f> ...
LOWERCASE ..............
SELECT-OPTIONS <selcrit> FOR <f> ...
OBLIGATORY ..............
SELECT-OPTIONS <seltab> FOR <f> ..... NOEXTENSION .....
SELECT-OPTIONS <seltab> FOR <f> ..... NO
INTERVALS .....
Selection Screen
200
REPORT ZSAPTEST.
TABLES: SFLIGHT.
SELECT-OPTIONS: AIRLINE FOR SFLIGHT-CARRID,
CONN
FOR SFLIGHT-CONNID.
201
Selection-screen
SELECTION-SCREEN SKIP [<n>].
SELECTION-SCREEN ULINE [[/]<pos(len)>]
SELECTION-SCREEN COMMENT [/]<pos(len)>
<comm> [FOR FIELD <f>]
Selection Screen
202
Selection-screen Elements on a
Single Line
Several Elements in a Single line
SELECTION-SCREEN BEGIN OF LINE.
...
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN POSITION <pos>.
E.g.
SELECTION-SCREEN BEGIN OF LINE.
Selection Screen
203
Selection-screen Blocks of
Elements
Create logical block of elements on selection
screen
SELECTION-SCREEN BEGIN OF BLOCK <block>
[WITH FRAME [TITLE <title>]]
[NO INTERVALS].
...
Selection-screen end of block <block>.
E.G.
Selection-screen begin of block rad1
with frame title text-002.
Selection Screen
204
Calling Selection-screen
Standard selection screen
Called automatically between the INITIALIZATION
and START-OF-SELECTION events.
Selection Screen
205
206
Loop at Screen
You can modify screen in your ABAP program
The only statements that can be used with
SCREEN are
Loop at screen.
...
Modify screen.
...
Endloop.
No further additions are allowed in the LOOP
AT SCREEN statement
Selection Screen
207
208
At selection-screen
At selection-screen output
At selection-screen on
At selection-screen on block
At selection-screen on help-request
At selection-screen on RADIOBUTTON
At selection-screen on value-request
Selection Screen
209
At Selection-screen
Basic form of a series of events
These events are called between
INITIALIZATION and START-OF-SELECTION.
Defined to change selection screen or process
user input, i.E. Validations, etc.
Selection Screen
210
Contd..
At selection-screen output
Allows you to modify selection-screen directly before it is displayed.
E.G.
Parameters: test1(10),
test2(10),
test3(10),
test4(10).
At selection-screen output.
Loop at screen.
If screen-name = test1'.
Screen-intensified = '1'.
Modify screen.
Continue.
ENDIF.
If screen-name = test3'.
Screen-input = '0'.
Modify screen.
ENDIF.
Endloop.
Selection Screen
211
Contd..
AT SELECTION-SCREEN ON <field>
Is triggered when the contents of the field are
passed from the selection screen to the ABAP
program.
E.G.
At selection-screen on test1.
IF TEST1 = not OK.
Message e001.
ENDIF.
Selection Screen
212
Contd..
AT SELECTION-SCREEN ON BLOCK <block>
Is triggered when the contents of all of the fields in a block are passed from the
selection screen to the ABAP program
E.G.
Selection-screen begin of block part1 with frame.
Parameters: number1 type i,
number2 type i,
number3 type i.
Selection-screen end of block part1.
At selection-screen on block part1.
If number3 LT number2 or
number3 LT number1 or
number2 LT number1.
Message e020.
ENDIF.
Selection Screen
213
Contd..
AT SELECTION-SCREEN ON HELP-REQUEST FOR <field>
Is triggered when the user calls the F1 help for the
field <field>.
E.G.
At selection-screen on help-request for p_CARR_2.
Call screen 100 starting at 10 5
ending at 60 10.
Selection Screen
214
Contd..
AT SELECTION-SCREEN ON RADIOBUTTON GROUP <radi>
Is triggered when the contents of all of the fields in a radio
button group are passed from the selection screen to the
ABAP program
E.G.
At selection-screen on RADIOBUTTON group rad1.
If r1 = 'x'.
Message w040.
ENDIF.
Selection Screen
215
Contd..
AT SELECTION-SCREEN ON VALUE-REQUEST FOR <field>
Is triggered when the user calls the F4 help for the
field <field>
E.G.
At selection-screen on value-request for p_CARR_2.
Call screen 100 starting at 10 5
ending at 50 10.
Module value_list output.
Selection Screen
216
<seltab>
<seltab> is an internal table with 4 fields
SIGN
I
E
OPTION
LOW
HIGH
EQ
NE
LT
GT
LE
GE
BT
NB
CP
NP
Selection Screen
217
218
219
REPORT ZSAPTEST.
TABLES: SFLIGHT.
SELECT-OPTIONS: AIRLINE FOR SFLIGHT-CARRID
DEFAULT AA TO LH
OPTION NB
SIGN I.
Selection Screen
220
221
Selection Screen
222
REPORT ZSAPTEST.
TABLES: SFLIGHT.
SELECT-OPTIONS AIRLINE
FOR SFLIGHTCARRID
NO-EXTENSION.
Selection Screen
223
REPORT ZSAPTEST.
TABLES: SFLIGHT.
SELECT-OPTIONS AIRLINE
FOR SFLIGHTCARRID
NO INTERVALS.
Selection Screen
224
225
226
PARAMETERS: A AS CHECKBOX,
B AS CHECKBOX DEFAULT X.
A
x B
Selection Screen
227
Dep.Time
to
Price
to
Show Luggage Weight
Selection Screen
228
229
DISCOUNT
ECONOMY
BUSINESS
FIRST
Selection Screen
230
231
REPORT ZSAPTEST.
TABLES: SPFLI, SFLIGHT, SBOOK.
SELECTION-SCREEN: BEGIN OF LINE,
COMMENT 1(11) TEXT-002,
POSITION 33.
PARAMETERS: PRICE LIKE SFLIGHT-PRICE OBLIGATORY.
SELECTION-SCREEN: COMMENT 55(8) TEXT-003,
POSITION 65.
PARAMETERS: CURRENCY LIKE SFLIGHT-CURRENCY OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Selection Screen
232
Selection Screen
233
REPORT ZSAPTEST.
TABLES: SPFLI, SFLIGHT, SBOOK.
SELECTION-SCREEN BEGIN OF BLOCK SPFLI
WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS CARR FOR SPFLI-CARRID DEFAULT LH.
SELECT-OPTIONS CITY FOR SPFLI-CITYFROM
DEFAULT BERLIN.
SELECT-OPTIONS DEPART FOR SPFLI-DEPTIME
DEFAULT 100000 TO 130000.
SELECTION-SCREEN END OF BLOCK SPFLI.
Selection Screen
234
Selection Screen
235
236
Reports &
Variants
Variant
set of values for all parameters and select-options
when a report is executed with a variant the fields of the
selection screen are filled with the values of the chosen
variant
Creating a Variant
execute the report & fill in the selection screen
GoTo Variants Save as Variant
Enter a name and short description for the variant
Fill in Variant Attributes as required
Selection Screen
237
Save as Variant
Selection Screen
238
239
Selection Screen
240
241
Conclusio
n
RADIOBUTTON group
Provides a one of the following type selection
Selection Screen
242
Conclusion
SELECT-OPTIONS
defines an internal table which holds selection
conditions
internal table has 4 attributes
SIGN, OPTION, LOW, HIGH
243
Conclusion
Selection screen can be formatted with
Lines, comments, frames
244