Professional Documents
Culture Documents
ABAP Chapter 4: Event-Driven Programming Selection Screen
ABAP Chapter 4: Event-Driven Programming Selection Screen
Event-driven Programming
Selection Screen
Event-driven Programming
Application Driven Programming
REPORT ztest.
DATA: today TYPE D.
today = ‘19991231’.
today = today + 1.
WRITE: / today.
Event-Driven Programming
Basic list
Navigating Between Lists
ABAP Editor
Detail list 2
Cancel
Detail list 1
3 | David | ....
ABAP Processor
List buffer
DYNPRO Processor Basic List
John
Peter HIDE area of list level 1
line Field name Value
David
DB Interface 1
2
customers-name
customers-name
John
Peter
Result Set Memory 3 customers-name David
Database Server
Database
At Line Selection(Hide Statement)
Basic List Detail List
At Line-selection
1
SY-LILLI = 2
4
HIDE area of list level 1 Customers Structure
2
line Field name Value 2 | Peter | ....
… … …
2
2
customers-id
customers-name
00000002
Peter
3
3 customers-id 00000003
…
At Line Selection
Tables: spfli,sflight. Basic List (SPFLI)
Start-of-selection.
Select * from spfli.
write : / spfli-carrid, spfli-connid, spfli-cityto.
Hide : spfli-carrid, spfli-connid.
Endselect.
At Line-selection.
select * from sflight where carrid = spfli-carrid Detail List (SFLIGHT)
Detail List
zcustomers-id
zcustomers
zcustomers-name
zsales-cust_id
zsales-qty
zsales-prod_id
zsales
Hide Statement (Report Heading)
List Buffer
Tables customers.
Customers Name
Top-of-page. -----------------------------
write: / ‘Customers Name’. John
Peter
uline. David
Start-of-Selection.
Select * from customers.
write : / customers-name.
Hide customers-name.
HIDE area of list level 1
Endselect.
At line-selection. line Field name Value
3 customers-name John
Write: ‘You Choose :’ , customers-name. 4 customers-name Peter
5 customers-name David
At Line Selection(Hide Statement)
Basic List Detail List
Customers Name
-----------------------------
You choose : Peter
John 5
Peter
David
At Line-selection
1
SY-LILLI = 4
4
HIDE area of list level 1 Customers Structure
2
line Field name Value
3 | Peter | ....
3 customers-name John
4 customers-name Peter 3
5 customers-name David
Invalid Line Selection
…
TOP-OF-PAGE.
…
Hide: spfli-carrid, spfli-connid.
…
Endselect.
Clear: spfli-carrid,spfli-connid.
At Line-selection.
Select * From sflight
Where carrid = spfli-carrid and
connid = spfli-connid.
Write: / spfli-carrid, spfli-connid ,sflight-fldate.
Endselect.
Clear: spfli-carrid,spfli-connid.
Page Heading
Start-of-selection.
Write: ‘Basic List’.
At Line-selection.
Write: ‘Detail List’.
Top-of-page.
Write: ‘Header-Basic List’.
Top-of-page During Line-selection.
Write: ‘Header-Detail List’.
Detail List Page Heading
...
top-of-page during line-selection.
case sy-lsind.
when 1.
write: / ‘Detail List Header #1’.
when 2.
write: / ‘Detail List Header #2’.
endcase.
.....
.....
...
Column Selection
data: fieldname(30).
...
start-of-selection.
select * from spfli.
write: / spfli-carrid,15 spfli-connid, 25 spfli-cityto.
hide: spfli-carrid,spfli-connid.
endselect.
at line-selection.
case sy-lsind.
when 1.
get cursor field fieldname.
case fieldname.
when 'SPFLI-CARRID'.
select single * from scarr where carrid = spfli-carrid.
if sy-subrc = 0.
write: / spfli-carrid,scarr-carrname.
endif.
when 'SPFLI-CONNID'.
select * from sflight where carrid = spfli-carrid and
connid = spfli-connid.
...
Column Selection : Value
...
data: fieldname(30),fieldvalue(30).
...
start-of-selection.
select * from spfli.
write: / spfli-carrid,15 spfli-connid, 25 spfli-cityto.
hide: spfli-carrid,spfli-connid.
endselect.
at line-selection.
case sy-lsind.
when 1.
get cursor field fieldname value fieldvalue.
case fieldname.
when 'SPFLI-CARRID'.
select single * from scarr where carrid = spfli-carrid.
if sy-subrc = 0.
write: / spfli-carrid,scarr-carrname.
endif.
when 'SPFLI-CONNID'.
...
Creating List in Modal Dialog Box
...
at line-selection.
window starting at 10 10
ending at 65 20.
select * from sflight
where carrid = spfli-carrid and
connid = spfli-connid.
write: / sflight-carrid,sflight-connid,sflight-fldate.
endselect.
...
Exercise
Basic List
zsales
zsales-qty
zsales-cust_id zsales-prod_id
zsales-sale_id
zproducts
Detail List zsalereps
zproducts-on_hand
zproducts-p_id
zsalereps-sale_id zsalereps-name
Drill-Down 2 Levels Example
Exercise
SCARR
Drill-down Level 1
SPFLI
Drill-down Level 2
SFLIGHT
Drill-down Level 3
SBOOK
GUI Interface (User Interface)
GUI Interface
SET PF-STATUS …. => GUI Status
SET TITLEBAR …. => GUI Title
AT USER-COMMAND Event
REPORT ztest.
DATA exctab(10) occurs 0 with header line.
....
START-OF-SELECTION.
SET PF-STATUS ‘0100’.
...
exctab = ‘LIST’. APPEND exctab.
exctab = ‘TEST’. APPEND exctab.
...
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN ‘LIST’.
SET PF-STATUS ‘0100’ excluding exctab.
GUI TITLE
...
SET TITLEBAR ‘0100’.
ABAP Practice
Selection Screen
Selection Screen
PARAMETERS Statement
SELECT-OPTIONS Statement
parameters
Parameters
PARAMETERS: tmp1(10) TYPE C,
tmp2(10) TYPE C lower case,
tmp3 LIKE sy-datum default sy-datum,
tmp4 TYPE D default ‘19991231’,
tmp5 TYPE i,
tmp6(5) TYPE N.
Parameters Example
Tables customers.
Parameters pid like customers-id.
START-OF-SELECTION.
select single * from customers where id = pid.
if sy-subrc = 0.
write: / customers-name.
else.
write: / ‘No data found’.
endif.
Selection-Text
By default , the System displays the name of the selection as text on
the Selection Screen
You Should use the Text element/Selection texts function to store a
text line for each Selection Criterion.
Check box
Tables customers.
Select-options sname for customers-name.
START-OF-SELECTION.
Select *
from customers
Where name in sname.
Internal Structure of Select-options
sname
Sign Option Low High
Internal Structure of Select-options
Field Value .
Sign I = Include
E = Exclude
Option BT = Between
CP = Contains Pattern
EQ = Equal
GT = Greater Than
LT = Less Than
GE = Grater Than or Equal
LE = Less Than or Equal
NE = Not Equal
Internal Structure of Select-options
sname
Sign Option Low High
I CP M*
I EQ Smith
I BT A John
SELECT-OPTIONS
sname
Sign Option Low High Select * from customers
Transform
where (name like ‘M%’) or
I CP M* (name = ‘Smith’) or
I EQ Smith (name between ‘A’ and ‘John’).
I BT A John