2 Interactive Report

37
ABAP Programming Basics of Interactive Reporting Selection Screens

description

2 Interactive Report

Transcript of 2 Interactive Report

Page 1: 2 Interactive Report

ABAP Programming

Basics of Interactive Reporting

Selection Screens

Page 2: 2 Interactive Report

Interactive Reporting

Page 3: 2 Interactive Report

Non-Interactive Reporting

Page 4: 2 Interactive Report

Interactive Reporting

InteractiveList

SecondaryList

Report

Transaction

Page 5: 2 Interactive Report

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

Page 6: 2 Interactive Report

Interactive Reports are Event Driven

REPORT ZSAPTEST.REPORT ZSAPTEST.*Basic ListSTART-OF-SELECTION.START-OF-SELECTION.

GET …GET …

END-OF-SELECTION.END-OF-SELECTION.

TOP-OF-PAGE.TOP-OF-PAGE.

END-OF-PAGE.END-OF-PAGE.

*Secondary Lists

AT LINE-SELECTION.AT LINE-SELECTION.

AT USER-COMMAND.AT USER-COMMAND.

AT PF<nn>.AT PF<nn>.

TOP-OF-PAGE DURING TOP-OF-PAGE DURING LINE-SELECTION.LINE-SELECTION.

Page 7: 2 Interactive Report

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

Page 8: 2 Interactive Report

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

Page 9: 2 Interactive Report

BasicList

SY-LSIND = 0

1. SecondaryList

SY-LSIND = 1

2. SecondaryList

SY-LSIND = 2

3. SecondaryList

SY-LSIND = 2

choosechoose

choosechoose

choosechoose

REPORT ZSAPTEST.

WRITE: / ‘Basic List’.

AT LINE-SELECTION. CASE SY-LSIND. WHEN ‘1’. :

WHEN ‘2’. :

WHEN ‘3’. SY-LSIND = SY-LSIND-1. :

Page 10: 2 Interactive Report

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

Page 11: 2 Interactive Report

The HIDE StatementHIDE <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 lineplace 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

Page 12: 2 Interactive Report

X

CARRID CONNID CITYFROM CITYTO

AA 0016 New York DenverLH 0400 Frankfurt New YorkLH 0357 Rome Frankfurt :

CARRID CONNID

AA 0016LH 0400LH 0357 :

HIDE Area

REPORT ZSAPTEST.

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

Page 13: 2 Interactive Report

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)

Page 14: 2 Interactive Report

AT LINE-SELECTION

AT LINE-SELECTIONdetermine what action to take by checking the current list level in the reportcode the appropriate action

AT LINE-SELECTION. CASE SY-LSIND. WHEN ‘1’. Select * from Sflight Where Carrid … WHEN ‘2’. Select * from Sbook Where… ENDCASE.

Page 15: 2 Interactive Report

AT USER-COMMAND

AT USER-COMMANDdetermine what action to take by checking the current function code value stored in SY-UCOMMcode the appropriate action

AT USER-COMMAND. CASE SY-UCOMM. WHEN ‘SORT’. Perform Sort_List. WHEN ‘DELE’. Perform Del_Record. ENDCASE.

Page 16: 2 Interactive Report

System Fields & Interactive Reports

SY-CUROW cursor position

(line) SY-CUCOL

cursor position (column)

SY-CPAGE number of current

page

SY-LSIND index of the

displayed list level SY-LISEL

contents of the selected line

Page 17: 2 Interactive Report

Selection Screens

Page 18: 2 Interactive Report

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

determine selection criteria for database fields

single values, range of values, sets of values, ... with the SELECT-OPTIONS statement

Page 19: 2 Interactive Report

The parameters Keyword

PARAMETERS: P1 TYPE P, P2(6) TYPE C DEFAULT ‘ITB255’.

PARAMETERS <field> TYPE <type> [DEFAULT <value>].PARAMETERS <field> TYPE <type> [DEFAULT <value>].

P1

P2 ITB255

Selection Screen

X

Page 20: 2 Interactive Report

Basic Form of select-options

SELECT-OPTIONS <seltab> FOR <f>.

creates a selection table <seltab> which is attached to database column or internal table field <f>.

the name <seltab>, like variable names, can be up to 8 characters only<f> cannot be of type f (floating point)

Page 21: 2 Interactive Report

REPORT ZSAPTEST.REPORT ZSAPTEST.TABLES: SFLIGHT.TABLES: SFLIGHT.SELECT-OPTIONS: AIRLINE SELECT-OPTIONS: AIRLINE FOR SFLIGHT-CARRIDFOR SFLIGHT-CARRID,, CONN CONN FOR SFLIGHT-CONNIDFOR SFLIGHT-CONNID..

multiple selection screen

Page 22: 2 Interactive Report

Multiple Selection Screen

Page 23: 2 Interactive Report

Multiple Selection Screen

icon on the main screen takes the user to the multiple selection screen

allows creation of more complex selection criteria pushbutton saves an extended selection

the arrow icon on the main screen turns to green indicating that the selection criteria is more complex than shown in the To and From fields

pushbutton allows the user to enter selection criteria that can be excluded from the resulting set

Page 24: 2 Interactive Report

<seltab> <seltab> is an internal table with 4 fields

SIGN OPTION LOW HIGHSIGN OPTION LOW HIGH

I EQE NE LT GT LE GE BT NB CP NP

Page 25: 2 Interactive Report

<seltab> and Database Selections

If the <seltab> contains more than one line form the union of sets defined on the lines that

have SIGN = I subtract the union of sets defines on the lines that

have SIGN = E select the resulting set

If <seltab> contains only lines with SIGN = E select all data outside the set specified in these

lines

Page 26: 2 Interactive Report

Assigning Default Values to Selection Criteria

SELECT-OPTIONS <seltab> FOR <f> DEFAULT <g> [TO <h>] OPTION <op> SIGN <s>.

<g> and <h> may be literals (enclosed in single quotes)names of fields whose contents should be used as default values

<op> may be one ofEQ,NE,GE,LE,GT,LT,CP,NP for single selectionsBT,NB for interval selections

<s> may be either I or E

Page 27: 2 Interactive Report

REPORT ZSAPTEST.REPORT ZSAPTEST.TABLES: SFLIGHT.TABLES: SFLIGHT.SELECT-OPTIONS: AIRLINE FOR SFLIGHT-CARRIDSELECT-OPTIONS: AIRLINE FOR SFLIGHT-CARRID DEFAULT ‘AA’ TO ‘LH’DEFAULT ‘AA’ TO ‘LH’ OPTION NBOPTION NB SIGN I.SIGN I.

Page 28: 2 Interactive Report

Assigning Default Values to Selection Criteria

REPORT ZSAPTEST.TABLES: SPFLI, SFLIGHT, SBOOK.SELECT-OPTIONS:AIRLINE FOR SPFLI-CARRID,

CONN FOR SPFLI-CONNID.INITIALIZATION. MOVE ‘LH’ TO AIRLINE-LOW. MOVE ‘UA’ TO AIRLINE-HIGH. MOVE ‘I’ TO AIRLINE-SIGN. MOVE ‘BT’ TO AIRLINE-OPTION. APPEND AIRLINE. CLEAR AIRLINE. MOVE ‘0400’ TO CONN-LOW. MOVE ‘I’ TO CONN-SIGN. MOVE ‘EQ’ TO CONN-OPTION. APPEND CONN.

Page 29: 2 Interactive Report
Page 30: 2 Interactive Report

Running a Report With a Variant

Execute the report Click on the 'Get Variant' button of the selection

screen Select a variant from the next dialog box

Page 31: 2 Interactive Report

Running a Report With a Variant

System … Services … Reporting Click on select a variant from the next dialog box

Page 32: 2 Interactive Report

Running a Report With a Variant

SUBMIT <reportname> USING SELECTION-SET <variantname>

Page 33: 2 Interactive Report

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

Page 34: 2 Interactive Report

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

Page 35: 2 Interactive Report

Conclusion

This lecture examined methods of providing the user with some measure of control over database selections via the provision of a selection screen

PARAMETERS statement defines a variable which can hold a single

value AS CHECKBOX

provides a yes/no type selection RADIOBUTTON GROUP

provides a one of the following type selection

Page 36: 2 Interactive Report

Conclusion SELECT-OPTIONS

defines an internal table which holds selection conditions

internal table has 4 attributes SIGN, OPTION, LOW, HIGH

rows of the internal table can be specified via the DEFAULT clause in the program (one row) via the INITIALIZATION event in the program (many rows) dynamically at runtime

Page 37: 2 Interactive Report

Conclusion selection screen can be formatted with

lines, comments, frames selection text can be maintained

through the Text Attributes screen variants provide a method of storing

commonly used selection conditions reports can be executed with a variant

from the workbench or from a program