Anda di halaman 1dari 54

ABAP Training

Interactive Reporting

Interactive Reporting
Graphical User Interfaces for Lists
ABAP Training Interactive Reporting 2

Objectives

 Interactive reporting
 What are interactive lists

 Basic & secondary lists

 The HIDE statement

 Event control

 At line-selection

 SY-LSIND

 AT pf<nn>

 At user-command

 System fields for secondary lists


ABAP Training Interactive Reporting 3

Non-interactive Reporting
ABAP Training Interactive Reporting 4

Interactive Reporting

Secondary
List

Report
Interactive
List
Transaction
ABAP Training Interactive Reporting 5

Non-interactive Vs. Interactive Lists


 Non-interactive
 Static structure

 Single, extensive and detailed list

 User searches through the list to find the relevant parts

 Interactive
 User selectively retrieves and presents data

 Select lines, enter commands from menus, function keys or

pushbuttons, type input


 Detailed information presented in secondary lists

 Ability to call transactions or other reports


ABAP Training Interactive Reporting 6

Interactive Reports Are Event Driven

REPORT ZSAPTEST.
*Basic List
START-OF-SELECTION. *Secondary Lists

GET … AT LINE-SELECTION.

END-OF-SELECTION. AT USER-COMMAND.

TOP-OF-PAGE. AT PF<nn>.

END-OF-PAGE. TOP-OF-PAGE DURING


LINE-SELECTION.
ABAP Training Interactive Reporting 7

The Basic List

 Output of the data created while processing either


 Start-of-selection

 GET <dbtable>

 By default a basic list has a standard page header


 If TOP-OF-PAGE / END-OF-PAGE event occurs

 System writes data to page header / page footer and then

displays basic list data on the output screen


 System field SY-LSIND = 0
ABAP Training Interactive Reporting 8

Secondary Lists

 Basic list + up to 20 secondary lists can exist in parallel


 On moving to (next) secondary list
 Current list added to memory area

 SY-LSIND incremented by one

 Using back or exit


 Logically superior list is displayed again

 SY-LSIND decremented by one

 No standard heading for secondary lists


ABAP Training Interactive Reporting 9

Basic
List
REPORT ZSAPTEST. SY-LSIND = 0

WRITE: / ‘Basic List’. choose


AT LINE-SELECTION. 1. Secondary
CASE SY-LSIND. List
WHEN ‘1’. SY-LSIND = 1
:
choose
WHEN ‘2’.
: 2. Secondary 3. Secondary
List List
WHEN ‘3’. SY-LSIND = 2 SY-LSIND = 2
SY-LSIND = SY-LSIND-1.
: choose
ABAP Training Interactive Reporting 10

Page Headers for Secondary Lists


 On secondary lists
 System does not display a standard page header

 Does not trigger the TOP-OF-PAGE event

 Top-of-page during line-selection


 Triggered for each secondary list

 To create different page headers for each secondary list you must

program a processing block for each value of SY-LSIND


ABAP Training Interactive Reporting 11

The HIDE Statement


HIDE <f>

stores the contents of <f> in relation to the current output line in


the HIDE area
not necessary for <f> to appear on current line
place the HIDE statement immediately after the output
statement for <f>
user selection of a line for which HIDE fields are available fills
the variables in the program with the values stored
ABAP Training Interactive Reporting 12

Valid Line Selection


HEADER . Hide Area
“SFLIGHT-CARRID “ AA
“SFLIGHT-CARRID” LH

FOOTER

REPORT RSBBB06D.
GET SFLIGHT .
WRITE : SFLIGHT-CARRID, 16 SFLIGHT-CONNID, - - - -.
HIDE SFLIGHT-CARRID , SFLIGHT-CONNID, SFLIGHT-FLDATE. - - -.

END-OF-SELECTION.
CLEAR SFLIGHT-CARRID.
AT LINE-SELECTION.
CHECK NOT SFLIGHT-CARRID IS INITIAL. - - - -

CLEAR SFLIGHT-CARRID.
ABAP Training Interactive Reporting 13

REPORT ZSAPTEST.

GET SPFLI.
WRITE: / SPFLI-CARRID, SPFLI-CONNID
SPFLI-CITYFROM, SPFLI-CITYTO.
HIDE: SPFLI-CARRID, SPFLI-CONNID.

X HIDE Area
CARRID CONNID CITYFROM CITYTO CARRID CONNID
AA 0016 New York Denver AA 0016
LH 0400 Frankfurt New York LH 0400
LH 0357 Rome Frankfurt LH 0357
: :
ABAP Training Interactive Reporting 14

AT Events Processing
 At line-selection
 Processed when user double clicks on a valid line
 At user-command
 Processed when user

 Presses a function key in the list

 Makes an entry in the command field

 Function code stored in system field SY-UCOMM

 AT pf<nn>
 Processed when user presses a function key with code pf<nn> (in

the range 0 to 99)


ABAP Training Interactive Reporting 15

AT LINE-SELECTION

AT LINE-SELECTION AT LINE-SELECTION.
determine what action to CASE SY-LSIND.
take by checking the current WHEN ‘1’.
list level in the report
Select * from Sflight
code the appropriate action
Where Carrid …
WHEN ‘2’.
Select * from Sbook
Where…
ENDCASE.
ABAP Training Interactive Reporting 16

AT USER-COMMAND

AT USER-COMMAND AT USER-COMMAND.
determine what action to CASE SY-UCOMM.
take by checking the current WHEN ‘SORT’.
function code value stored in
Perform Sort_List.
SY-UCOMM
code the appropriate action WHEN ‘DELE’.
Perform Del_Record.
ENDCASE.
ABAP Training Interactive Reporting 17

System Fields & Interactive Reports


 SY-CUROW  SY-LSIND
 Cursor position (line)  Index of the displayed list

 SY-CUCOL level
 Cursor position (column)  SY-LISEL
 SY-CPAGE  Contents of the selected line

 Number of current page


ABAP Training Interactive Reporting 18

Overview of User Messages


REPORT REDEMO00 MESSAGE - ID AT.
----

MESSAGE E027

Table T100

S ID No. Message text .


D AT 001 Record &1 &2 does not exist
- -- -- --
D AT 011 Error when updating
- -- -- --
D AT 001 Not authorized

E027 Not authorized


ABAP Training Interactive Reporting 19

Overview of User Messages

REPORT < report name > MESSAGE - ID <message - id > .


--
--
Annn
Xnnn
MESSAGE Ennn WITH < field1 > < field2 > < field3 > < field4 >.
Wnnn
Innn
Snnn
ABAP Training Interactive Reporting 20

Classification of Dialog Messages


Abend Error Warning Information Success

Function Function Function Function Function


call call call call call

New Input required

New Input possible


Restart

Seletion Seletion Seletion Seletion Seletion


Screen Screen Screen Screen Screen

A message E message W message I message


X message

Lists Lists Lists


ABAP Training Interactive Reporting 21

Example of Dialog Message

REPORT RSAAA11B MESSAGE-ID AT.


TABLES SPFLI.
PARAMETERS : P_CARRID LIKE SPFLI-CARRID.
AT SELECTION-SCREEN.
AUTHORITY-CHECK OBJECT ‘S_CARRID’
ID ‘CARRID’ FIELD P_CARRID
ID ‘ACTVT’ FIELD ‘03’.
IF SY-SUBRC NE 0.
MESSAGE E045 WITH P_CARRID.
ENDIF.

START-OF-SELECTION.
SELECT * FROM SPFLI WHERE CARRID = P_CARRID.
---.
ENDSELECT.
ABAP Training Interactive Reporting 22

Summary
 You can use the interactive reporting functionality to provide the user
with additional clearly structured information in secondary lists or
windows.
 To generate secondary lists or windows, various special events are
available that can be triggered by activating a function key or via mouse
click.
 Besides the basic list, up to twenty secondary lists may exist. The
system field SY-LSIND contains the index of the list that is being
generated by the report.
 To save data for the secondary list, use the statement HIDE. The system
stores field names and field contents per line. When an interactive event
is triggered, the values stored in the HIDE area are placed back into
original fields.
 Page headings for secondary lists are defined in connection with the
event TOP-OF-PAGE DURING LINE-SELECTION.
ABAP Training Interactive Reporting 23

Conclusion
 Interactive reporting
 Non-static view of data for the user

 User selectively retrieves and displays data

 Additional clearly structured information can be presented

to the user in secondary lists or windows


 Up to 20 secondary lists may exist

 Secondary lists generated by special events

 AT LINE-SELECTION, AT USER-COMMAND, AT pf<nn>

 SY-LSIND contains index of current list level


ABAP Training Interactive Reporting 24

Conclusion

 Interactive lists
 To save data for the secondary list use HIDE

 System stores field names and field contents per line

(SY-LISEL)
 At an interactive event the values stored in HIDE area

are placed back into the original fields


 Generally better performance through interactive lists

 Only lines relevant to the user are selected and displayed

as they are required


ABAP Training

Graphical User Interfaces for Lists


ABAP Training Interactive Reporting 26

Objectives

 To introduce the
 The purpose and function of GUI’s for lists

 Aspects of graphical user interface for lists including

 Defining a GUI status with the menu painter

 Modifying the standard toolbar

 Defining the application toolbar

 Working with multiple GUI status’s

 At user-command

 Displaying a list in a window

 Cursor position and hidden information


ABAP Training Interactive Reporting 27

Purpose & Function

 Interactive reports
 Basic list provides coarse grained information

 Report provides facilities to allow user to navigate (drill down)

to more detailed information


 Double click on a line

 Pushbuttons and function keys

 Menus and menu functions

 Secondary lists can be presented in full screen or window mode


ABAP Training Interactive Reporting 28

Purpose & Function

 Event driven nature of ABAP allows the creation of reports that


react to user actions
 At line-selection

 At user-command

 AT pf<nn>

 Response within each of this event can be based on current

cursor position
 Get cursor ...
ABAP Training Interactive Reporting 29

GUI Interface - Definition


 GUI status
 The set of menus, menu functions, toolbar buttons and pushbuttons

with which the user interacts


 GUI interface
 The set of GUI status’s for each of the basic and secondary lists of

the report
ABAP Training Interactive Reporting 30

Elements of a GUI Status

 Screen title
 titlebar of the window in which the list is displayed

 Set seperately and independently of the GUI status

 Menu bar
 Opens pull down menus

 Application toolbar
 Program functions assigned to pushbuttons

 Standard toolbar
 Scroll bars
 Vertical & horizontal provided by the system
Elements of a GUI Status
Standard Application
Menu Bar Toolbar Title Bar
Toolbar
ABAP Training Interactive Reporting 32

Defining a GUI Status

 Menu painter
 Tool used to define status elements

 Starting the menu painter


 Choose Menu Painter on the development workbench

 Enter transaction code SE41 in the command field

 In the ABAP editor

 Position the cursor on SET PF-STATUS <statusname>

 Double click or press F2

 (Same applies for SET TITLEBAR)


ABAP Training Interactive Reporting 33

Create Status Screen


ABAP Training Interactive Reporting 34

GUI Status Types


 On line status
 Used for module pool or call screen

 Full screen with menu bar, pushbuttons and input/output boxes

 Dialog box
 Does not have a menu bar and only a few pushbuttons

 List status
 Used for lists

 Full screen with menus and pushbuttons

 List in the dialog box


 Used for lists that appear in pop up windows
ABAP Training Interactive Reporting 36

Menu Painter Icons


 The menu painter tool allows you to define basically all the elements of
a status. These elements include:
 I) the status title (defined through the short text definition in
the opening screen);
 Ii) the menus and items on each menu;
 Iii) the standard toolbar icons that are to be displayed as active;

 Iv) the icons/pushbuttons on the application toolbar; And

 V) the function key definitions.

 The display standards pushbutton telle the menu painter to create the
SAP standards for the menu bar. This includes menus for list, edit, go to
as well as system and help. (The system and help menus are part of
every SAP screen. They will not appear on the surface of the menu
painter tool but will appear on the menu bar in your program.)
ABAP Training Interactive Reporting 37

Status Provides ...


 Menus
 Up to 8 menus possible (each with submenus)

 Up to 15 items per menu

 System provides system and help menus

 Application toolbar
 Up to 20 pushbutton icons

 Up to 48 function keys

 Include in function key menu so user can see the definition when
they click the alternate mouse button
Defining Menu Bar Attributes

Menu Bar
Standards

Menu Bar
Function Codes

Menu Items
Defining the Standard Toolbar
Create Application Toolbar Item
ABAP Training Interactive Reporting 41

Assigning a Status

SET PF-STATUS <statusname>.

sets status to <statusname>


a status name can be up to 20 characters and must be
capitalised
system default status is SPACE
currently active status stored in SY-PFKEY
once a status is set it remains active until you choose a
different status
ABAP Training Interactive Reporting 42

Assigning a Status
SET TITLEBAR <titlename>.

sets title of the current status to <titlename>


<titlename> can be up to 20 characters and must be capitalised
ABAP Training Interactive Reporting 43

Assigning a Status
START-OF-SELECTION.
SET PF-STATUS ‘BASE’.
SET TITLEBAR ‘BAS’.

In the program editor double click on either of the above code lines to
go to
menu painter
text elements maintenance
ABAP Training Interactive Reporting 44

Event AT USER-COMMAND

 Occurs in a report if the user


activates a function
AT USER-COMMAND.
 By clicking a pushbutton,
CASE SY-UCOMM.
pressing a function key or WHEN ‘CARR’.
selecting from menu
<statements>
 SY-UCOMM stores the assigned
function WHEN ‘CONN’.
<statements>
ENDCASE.
ABAP Training Interactive Reporting 45

Popup Windows
 WINDOW STARTING AT c1 r1
 [ENDING AT c2 r2]

output (WRITE etc) appears in the window


windows are nothing more than a secondary list with a frame
supports all list processing functions
HIDE, scrolling, line selection, SET TITLEBAR
if you do not specify ENDING AT the bottom of the window
corresponds to the coordinates of the lower edge of the current
screen
ABAP Training Interactive Reporting 46

Popup Windows
REPORT ZSAPTEST.
WINDOW STARTING AT 10 15
ENDING AT 77 22.
WRITE: / ...
10 77
X
Page Heading 1
15

22
ABAP Training Interactive Reporting 47

Setting a Status to a Window


Set pf-status ‘win’.
Window starting at 10 10
Ending at 60 15.
Write: / …..

Defining a status as a ‘List in Dialog Box’ or ‘Dialog Box’


does not define the dimensions of the window
ABAP Training Interactive Reporting 48

Get Cursor
Get cursor field FNAME [value FVALUE]

Used to interactively retrieve


name of the current cursor field
stored in FNAME (type character string)
value of the current cursor field
stored in FVALUE (type character string)
Return Code, SY-SUBRC
0 means cursor was positioned on a field
4 means cursor was outside a field
ABAP Training Interactive Reporting 49

Get Cursor ….
Data: fred(20) value ‘Fred Flintsone’,
Barney(20) value ‘barney rubble’,
fname(10), fvalue(20).
Write: /10 fred, 40 barney.

At line-selection.
Get cursor field fname value fvalue.
If sy-subrc = 0.
Write: / ‘cursor on ‘, fname,
‘Which holds ‘, fvalue.
Else.
Write: / ‘cursor not on a field’.
endif.
ABAP Training Interactive Reporting 50

Example of Get Cursor 1

Fred Flintsone Barney Rubble

Cursor on FRED which holds Fred Flintstone

Example of Get Cursor 1

Fred Flintsone Barney Rubble

Cursor not on a field


ABAP Training Interactive Reporting 51

Sorting an Internal Table by a Selected Field


 in the following code
 itab is an internal table without a header line

 the subroutine write_itab will use a loop to

 read itab rows into the work area variable wa


 display the wa fields in the list output

 in the AT… event

 the current cursor field is read

 the case statement determines an action based on the value

returned by GET CURSOR


ABAP Training Interactive Reporting 52

Sorting an Internal Table by a Selected Field


data: wa like sflight, itab like sflight occurs 0,
fname(10).

perform write_itab.
...
at …
get cursor field fname.
case fname.
when ‘WA-CARRID’. sort itab by carrid.
when ‘WA-CONNID’. sort itab by connid.
...
endcase.
perform write_itab.
ABAP Training Interactive Reporting 53

Sorting an Internal Table by a Selected


Field

 note that
GET CURSOR FIELD FNAME.
SORT ITAB BY FNAME.

will return an error


‘ITAB does not contain a field called FNAME’
ABAP Training Interactive Reporting 54

Conclusion

 Examined various aspects of GUI interfaces for lists


 Purpose & function of GUI interface

 Definition of GUI status’s and interface

 Defining a GUI status using the menu painter

 Using AT events to maintain multiple GUI status’s within a

single list
 Displaying lists in popup windows

 Interactive list processing using GET CURSOR

Anda mungkin juga menyukai