User can
interact with the system by:
¨
Double clicking or pressing F2
¨
Selecting menu option
Like classical
report, the interactive report is also event driven. Both the action mentioned
above trigger events and code is written to handle these events. The events triggered by this action are as
follows:
¨
At line-selection
¨
At user-command
¨
Top-of-Page During Line-Selection for Secondary
Page Header info
Interactive
report consists of one BASIC list and 20 secondary list. Basic list is produced
by START-OF-SELECTION event. When the user double clicks on the basic list or
chooses the menu option, the secondary list is produced. All the events
associated with classical report except end-of-page are applicable only to
basic list.
Double clicking is the way
most users navigate through programs. Double clicking on basic list or any
secondary list triggers the event AT LINE-SELECTION. SY-LSIND denotes the index
of the list currently created. For BASIC list it is always 0. Following piece of code shows how to handle
the event.
Start-of-selection.
Write: / ‘this
is basic list’.
At line-selection.
Write : ‘this
is first secondary list’.
In this case
the output will be displayed on basic list i.e.
This is basic
list.
When user
double clicks on this line, the event at line-selection gets triggered and
secondary list is produced, i.e.
This is first
secondary list.
You can go
back to basic list by clicking on F3 or back icon on the standard tool
bar. For this list, the value of
sy-lsind will be 1.
In this case
thins are much simpler. Consider the case, wherein you display fields from
table sflight in basic list. When user double clicks on any sflight-carrid, you
are displaying the detailed information related to that particular carrid on
secondary list. Hence there is a need to
store the clicked carrid in some variable.
So that you can access this carrid for next list. ABAP/4 has facility; a
statement called HIDE, which
provides the above functionality.
HIDE command
temporarily stores the content of clicked field in system area.
Syntax:
HIDE
.
This statement
stores the contents of variable in relation to the current output
line (system field SY-LINNO) internally in the so-called HIDE area. The
variable must not necessarily appear on the current line.
You have to
place the HIDE statement always directly after the output statement i.e.,
WRITES for the variable . As
when you hide the variable, control is passed to next record. While writing, WRITE statement takes that record from header and writes it on to the
list, but when writing onto your interactive list you will miss out 1st
record.
To hide
several variables, use chain HIDE statement.
As soon as the
user selects a line for which you stored HIDE fields, the system fills the
variables in the program with the values stored. A line can be selected.
¨
By an interactive event.
For each interactive event,
the HIDE fields of the line on which the cursor is positioned during the event
are filled with the stored values.
The HIDE area
is a table, in which the system stores the names and values of all HIDE fields
for each list and line number. As soon
as they are needed, the system reads the values from the table. (Please try to find the name of this table.)
Sy-lsind
indicates the index of the list and can be used to handle all the secondary
lists. When the user double clicks on
the line or presses F2, sy-lsind is increased by one and this new sy-lsind can
be handled. For example:
Write: / ‘this is basic list’.
·
Will create a basic list.
If sy-lsind = 1.
Write: / ‘this is first secondary
list’.
Elseif sy-lsind = 2.
Write: / ‘This is second
secondary list’.
Endif.
When this code
is executed,
·
Basic list is produced.
·
When the user clicks on the basic list, sy-lsind
becomes one.
·
AT LINE-SELECTION event is triggered.
·
Whatever is written under IF Sy-lsind = 1, gets
executed.
·
Secondary list is produced.
·
Again if user clicks on this list, sy-lsind
becomes two.
·
AT LINE-SELECTION gets triggered.
·
Code written under IF Sy-lsind = 2, gets
executed.
Example for Interactive Report Events
*&---------------------------------------------------------------------*
*& Report ZBASU_INTERACTIVE_REPORT_EVENT *
*&---------------------------------------------------------------------*
REPORT
ZBASU_INTERACTIVE_REPORT_EVENT NO STANDARD PAGE HEADING
LINE-SIZE 90 LINE-COUNT 40(2).
Tables: mara, kna1, vbak, vbap.
types:begin of ty_kna1,
kunnr like kna1-kunnr,
name1 like kna1-name1,
end of ty_kna1.
types:begin of ty_vbln,
vbeln like vbak-vbeln,
netwr like vbak-netwr,
end of ty_vbln.
types:begin of ty_vbap,
posnr like vbap-posnr,
matnr like mara-matnr,
end of ty_vbap.
data: it_kna1 type standard table of
ty_kna1,
wa_kna1 like line of it_kna1.
data: it_vbln type standard table of
ty_vbln,
wa_vbln like line of it_vbln.
data: it_vbap type standard table of
ty_vbap,
wa_vbap like line of it_vbap.
START-OF-SELECTION.
select kunnr name1 from kna1 into corresponding fields of table it_kna1.
loop at it_kna1 into wa_kna1.
write:/ wa_kna1-kunnr,
wa_kna1-name1.
hide: wa_kna1-kunnr.
endloop.
TOP-OF-PAGE.
WRITE:/ 'GALAXE SOLUTIONS'.
At line-selection.
case sy-lsind.
when '1'.
select vbeln netwr from vbak into
corresponding fields of table it_vbln.
loop at it_vbln into wa_vbln.
write:/ wa_vbln-vbeln,
wa_vbln-netwr.
hide: wa_vbln-vbeln.
endloop.
when '2'.
select a~posnr b~matnr into
corresponding fields of table it_vbap from
vbap as a inner join mara as b on
a~matnr = b~matnr.
loop at it_vbap into wa_vbap.
write:/ wa_vbap-posnr,
wa_vbap-matnr.
endloop.
endcase.
Top-of-page during line-selection.
if sy-lsind = '1'.
write:/ ' first list'.
elseif sy-lsind = '2'.
write:/ 'second list'.
else.
write:/ 'proper list no'.
endif.