Vous êtes sur la page 1sur 8

Reporting

· Report is displaying the application data in the required format.


Data Input --> Data Processing -> Data Output
(Selection Screen) (SELECT statements) (write, ulin
e,vline to o/p data)
· Reports helps to analyze the current situation and also for decision making.
· Reports read and calculate data from database tables, without actually changing
it.

Types Of Reports
Reports are of two types-
1. Classical Reports
2. Interactive Reports

Classical Reports
Displaying whole data in one list.
Interactive Reports
Display the summarized information as the first list and display the detailed in
formation as secondary list.

Selection screen-
· In both classical & interactive reports input is provided through selection scre
ens only.
· For defining selection screen-
PARAMETERS
SELECT-OPTIONS
· PARAMETERS – Used for simple queries of single value only.
PARAMETERS <NAME>[<LENGHT>] TYPE <type> / LIKE <VARIABLE> [DECIMAL <NO>].
1. To Define parameters as mandatory use OBLIGATORY Keyword.
Ex:- PARAMETERS P_CARRID TYPE SFLIGHT-CARRID
OBLIGATORY.
2. To check a user entry against a check table or against fixed values in
the ABAP Dictionary use VALUE CHECK Keyword.
Ex:- PARAMETERS P_CARRID TYPE SFLIGHT-CARRID VALUE
CHECK.
3. To Define a check box :-
Ex:- PARAMETERS <NAME> AS CHECKBOX..
4. To Define radio buttons :-
Ex :- PARAMETERS <NAME> RADIOBUTTON GROUP <G1>.

· SELECT OPTIONS :- Used to accept range of inputs on the selection screen.


SYNTAX :- SELECT-OPTIONS <NAME> FOR <VARIABLE>.

· When we create a select options an internal table(Selection table ) is created w


ith header line by the system with the name of the select options and the row ty
pe of the selection table is a structure that consists of four components : SIGN
, OPTIONS , LOW , HIGH .
SIGN – Possible values are I and E
I -Stands for INCLUSIVE
E-Stands for EXCLUSIVE
OPTIONS - Possible Operators (Ex:- EQ , NE , GT , LE , LT , CP , N
P , BT ,
NB)
· For providing default values use :
SELECT-OPTIONS S_CARRID FOR V_CARRID DEFAULT ‘AA’ TO ‘AZ’
OPTION ‘BT’ SIGN I..

· To restrict entry to one row :


SELECT-OPTIONS S_CARRID FOR V_CARRID NO-EXTENSION.
· To restrict entry to single field :
SELECT-OPTIONS S_CARRID FOR V_CARRID NO INTERVALS.
Events of Classical Reporting –
· INITIALIZATION
· AT SELECTION-SCREEN OUTPUT
· AT SELECTION-SCREEN ON <FNAME>
· AT SELECTION-SCREEN
· START-OF-SELECTION
· END-OF-SELECTION
· TOP-OF-PAGE
· END-OF-PAGE

Events of Classical Reporting –


· AT LINE-SELECTION
· AT USER-COMMAND
· TOP-OF-PAGE DURING LINE-SELECTION

STEPS FOR CLASSICAL REPORTING-


· Writing the code in SE-38 (ABAP) Editor.

Sample Program for classical reporting-

REPORT Z_CLASSICAL_REPORT NO STANDARD PAGE HEADING LINE-COUNT 12(2).


PARAMETERS : P_CARRID LIKE SFLIGHT-CARRID ,
P_CONNID LIKE SFLIGHT-CONNID.
DATA : IT_SFLIGHT TYPE TABLE OF SFLIGHT ,
WA_SFLIGHT TYPE SFLIGHT.
DATA : WA_SPFLI TYPE SPFLI ,
WA_SCARR TYPE SCARR.

INITIALIZATION.
P_CONNID = 0017 .
LOAD-OF-PROGRAM.
P_CARRID = AA .

AT SELECTION-SCREEN ON P_CARRID.
SELECT SINGLE * FROM SCARR INTO WA_SCARR WHERE CARRID EQ P_CARRID.
IF SY-SUBRC NE 0.
MESSAGE INVALID CARRID TYPE E .
ENDIF.
AT SELECTION-SCREEN.
SELECT SINGLE * FROM SPFLI INTO WA_SPFLI WHERE CARRID EQ P_CARRID
AND CONNID EQ P_CONNID.
IF SY-SUBRC NE 0.
MESSAGE INVALID DATA TYPE E .
ENDIF.

START-OF-SELECTION.
SELECT * FROM SFLIGHT INTO TABLE IT_SFLIGHT WHERE CARRID EQ P_CARRID
AND CONNID EQ P_CONNID.
END-OF-SELECTION.
LOOP AT IT_SFLIGHT INTO WA_sFLIGHT.
WRITE : / WA_SFLIGHT-CARRID ,
WA_SFLIGHT-CONNID ,
WA_SFLIGHT-FLDATE ,
WA_SFLIGHT-PRICE.

ENDLOOP.
TOP-OF-PAGE.
WRITE : / THIS IS THE TOP OF PAGE .
ULINE.
END-OF-PAGE.
ULINE.
WRITE : / THIS IS THE END OF PAGE .

Output Of the Program-

When we further press F8 we get a detailed output-


STEPS FOR INTERACTIVE REPORTING –

Sample Program for interactive reporting-

REPORT Z_INTERACTIVE_REPORT.

DATA : IT_SCARR TYPE TABLE OF SCARR ,


WA_SCARR TYPE SCARR.
DATA : IT_SFLIGHT TYPE TABLE OF SFLIGHT ,
WA_SFLIGHT TYPE SFLIGHT.
DATA : WA_SPFLI TYPE SPFLI.
DATA : G_CARRID LIKE SFLIGHT-CARRID.
DATA : G_FNAME(20) TYPE C.
SELECT-OPTIONS : S_CARRID FOR WA_SCARR-CARRID.
INITIALIZATION.
S_CARRID-SIGN = I .
S_CARRID-OPTION = BT .
S_CARRID-LOW = AA .
S_CARRID-HIGH = ZZ .
APPEND S_CARRID.
START-OF-SELECTION.
SELECT * FROM SCARR INTO TABLE IT_SCARR WHERE CARRID IN S_CARRID.
END-OF-SELECTION.
LOOP AT IT_SCARR INTO WA_SCARR.
WRITE : /2 WA_SCARR-CARRID HOTSPOT ON,
WA_SCARR-CARRNAME.
*HIDE WA_SCARR-CARRID.
ENDLOOP.
AT LINE-SELECTION.
*WRITE : / THIS IS LIST NUMBER :- , SY-LSIND.
CASE SY-LSIND.
WHEN 1.

* G_CARRID = SY-LISEL+0(2).
GET CURSOR FIELD G_FNAME VALUE G_CARRID.
IF G_FNAME EQ WA_SCARR-CARRID .
SELECT * FROM SFLIGHT INTO TABLE IT_SFLIGHT WHERE CARRID EQ G_CARRID."WA_SCARR-C
ARRID.
IF SY-SUBRC EQ 0.
LOOP AT IT_SFLIGHT INTO WA_SFLIGHT.
READ TABLE IT_SCARR INTO WA_SCARR WITH KEY CARRID = WA_SFLIGHT-CARRID.
WRITE : / WA_SFLIGHT-CARRID HOTSPOT ON,
WA_SFLIGHT-CONNID HOTSPOT ON,
WA_SFLIGHT-FLDATE ,
WA_SFLIGHT-PRICE ,
WA_SCARR-CARRNAME.
HIDE : WA_SFLIGHT-CARRID , WA_SFLIGHT-CONNID.
ENDLOOP.
ENDIF.
ENDIF.

WHEN 2.
SELECT SINGLE * FROM SPFLI INTO WA_SPFLI WHERE CARRID EQ WA_SFLIGHT-CARRID
AND CONNID EQ WA_SFLIGHT-CONNID.
IF SY-SUBRC EQ 0.
WRITE : / FLIGHT ID : , WA_SPFLI-CARRID ,
/ FLIGHT CONNECTION NO : , WA_SPFLI-CONNID ,
/ CITYFROM : , WA_SPFLI-CITYFROM ,
/ CITYTO : , WA_SPFLI-CITYTO.

ELSE.
MESSAGE NO VALUE FOUND!!! TYPE E .
ENDIF.
ENDCASE.
Output Of the Program –

After pressing F8(Execute) we get the final screen –

Vous aimerez peut-être aussi