Professional Documents
Culture Documents
Agenda
1 General Introduction
2 Types of Reports
3 Classical Report
4 Interactive Report
5 Example
GENERAL INTRODUCTION
What is a Report?
It is a way of presenting data to the user.
The purpose of a report is to read data from the database
and display it in a required format.
Screens of a Report
Screens of a Report
Selection Screen: It contains input fields allowing the user to
enter criteria for the report.
Output (List) Screen: It contains the output data in the required
format.
Selection Screen
User can enter the criteria for selection
PARAMETERS
SELECT-OPTIONS
Sign
Option
Low
High
On <field>
On Block <Blk>
On Radio button Group
On Help-Request
On Value-Request
Output Screen
Contains the data to be displayed
Write Statement
Colors
Display either Foreground or Background Colors
Inverse Off (Background Color) (Default)
Intensified On (Intensive Background Color)
Intensified Off (Weak Background Color)
10
Output Screen
Other Formatting Options
Positioning the Output
11
12
Types of Reports
Classical Report
Interactive Report
ALV (ABAP List Viewer)
13
Classical Report
14
Classical Report
These are the most simple reports. Programmers learn this one first.
15
Example
TYPES: BEGIN OF Z_T_MAT,
MATNR TYPE MATNR,
MTART TYPE MTART,
MBRSH TYPE MBRSH,
MATKL TYPE MATKL,
END OF Z_T_MAT.
16
Example
SELECT MATNR MTART MBRSH MATKL INTO TABLE Z_I_MAT F
ROM MARA WHERE MATNR IN Z_S_MTNR.
17
Output
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
18
19
Output
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
20
Introducing Events
The events used are:
Initialization
Start-of-Selection
End-of-Selection
Top-of-Page
End-of-Page
21
Initialization
It is the first event that is triggered in the flow of the program
22
Significance of Initialization
PARAMETERS: z_p_dat TYPE sy-datum.
23
Start-of-Selection
24
End-of selection
This event will cut the link between the Logical database (LDB) and
the Program when we use LDB.
25
It is a best practice to use this event after writing all the Select
Queries.
Top-of-Page
Event used to create the Page Headings for your report.
26
End-of-Page
Event used to create the Page footer for your report.
27
Example
28
Example Contd..
WRITE:/4 sy-vline NO-GAP, text-01b NO-GAP,
"No.
9 sy-vline NO-GAP, 10 text-02b NO-GAP, "Group
19 sy-vline NO-GAP, 20 text-03b NO-GAP, "Order No.
30 sy-vline NO-GAP, 31 text-01b NO-GAP, "No.
41 sy-vline NO-GAP, 42 text-05b NO-GAP, "Organization
54 sy-vline NO-GAP, 55 text-06b NO-GAP, "Term
62 sy-vline NO-GAP, 63 text-07b NO-GAP, "
(Text)
93 sy-vline NO-GAP, 94 text-01b NO-GAP, "No.
112 sy-vline NO-GAP, 113 text-08b NO-GAP, "Quantity
130 sy-vline NO-GAP, 147 sy-vline NO-GAP,
151 sy-vline NO-GAP, 157 sy-vline NO-GAP.
WRITE:/4(154) sy-uline.
29
Example Contd..
START-OF-SELECTION.
SELECT ekpo~matkl ekpo~meins ekko~waers ekko~ebeln ekko~lifnr ekko~ekorg ekko~zterm ekpo~matnr ekpo~menge
ekpo~netwr INTO TABLE z_i_po FROM ekko JOIN ekpo ON ekko~ebeln = ekpo~ebeln
WHERE ekko~bstyp = 'F' AND ekko~bsart = 'NB' AND ekko~statu = '9' AND ekko~aedat IN z_s_dat.
IF sy-subrc = 0.
"CHECKS WHETHER THERE IS ANY ENTRY
MOVE z_i_po TO z_i_drve.
SORT z_i_drve BY zterm.
DELETE ADJACENT DUPLICATES FROM z_i_drve COMPARING zterm.
IF z_i_drve IS NOT INITIAL.
SELECT zterm vtext FROM tvzbt INTO TABLE z_i_pterm FOR ALL ENTRIES IN z_i_drve
WHERE zterm = z_i_drvezterm AND spras = 'E'. "SELECTS THE PAYMENT TERM TEXT CORRESPONDING TO PAYMENTTERMS.
ENDIF.
* TO SELECT FIELDS FOR DISPLAYING THE VENDOR INFORMATION FOR THE 'LIFNR' ENTRIES IN PO TABLE
MOVE z_i_po TO z_i_drve.
SORT z_i_drve BY lifnr.
DELETE ADJACENT DUPLICATES FROM z_i_drve COMPARING lifnr.
IF z_i_drve IS NOT INITIAL.
SELECT lifnr name1 stras adrnr pstl2 ort01 regio pstlz FROM lfa1 INTO TABLE z_i_vend
FOR ALL ENTRIES IN z_i_drve WHERE lifnr = z_i_drve-lifnr.
ENDIF.
SORT z_i_po BY matkl meins waers. "TO GROUP THE PURCHASE ORDERS BY MATERIAL GROUP
ELSE.
LEAVE PROGRAM.
ENDIF.
30
31
END-OF-SELECTION.
LOOP AT z_i_po INTO z_wa_z_i_po.
z_v_meins = z_wa_z_i_po-meins.
z_v_waers = z_wa_z_i_po-waers.
WRITE:/4 sy-vline NO-GAP, (4) sy-tabix NO-GAP,
sy-vline NO-GAP, z_wa_z_i_po-matkl NO-GAP,
sy-vline NO-GAP, z_wa_z_i_po-ebeln NO-GAP,
sy-vline NO-GAP, z_wa_z_i_po-lifnr NO-GAP,
sy-vline NO-GAP, (12) z_wa_z_i_po-ekorg NO-GAP,
sy-vline NO-GAP, (7) z_wa_z_i_po-zterm NO-GAP.
SORT z_i_pterm BY zterm.
READ TABLE z_i_pterm WITH KEY zterm = z_wa_z_i_po-zterm INTO z_wa_z_i_pterm BINARY SEARCH.
IF sy-subrc <> 0 OR z_wa_z_i_pterm-vtext IS INITIAL.
z_wa_z_i_pterm-vtext = '
-------'.
ENDIF.
WRITE:sy-vline NO-GAP, z_wa_z_i_pterm-vtext NO-GAP,
sy-vline NO-GAP, z_wa_z_i_po-matnr NO-GAP,
sy-vline NO-GAP, z_wa_z_i_po-menge NO-GAP UNIT z_wa_z_i_po-meins,
sy-vline NO-GAP, z_wa_z_i_po-netwr NO-GAP CURRENCY z_wa_z_i_po-waers,
sy-vline NO-GAP, z_v_meins NO-GAP USING NO EDIT MASK,
sy-vline NO-GAP, z_v_waers NO-GAP,
sy-vline NO-GAP.
HIDE z_wa_z_i_po-lifnr.
AT END OF waers.
SUM. " TO SUM THE NET VALUE BY MATERIAL GROUP
WRITE:/4(154) sy-uline.
WRITE:/4 sy-vline NO-GAP, 95 text-11a, "z_wa_z_i_po-matkl,
112 sy-vline NO-GAP, 113 z_wa_z_i_po-menge NO-GAP UNIT z_v_meins, sy-vline NO-GAP,
z_wa_z_i_po-netwr NO-GAP CURRENCY z_v_waers, sy-vline NO-GAP, z_v_meins NO-GAP
USING NO EDIT MASK, sy-vline NO-GAP, z_v_waers NO-GAP, sy-vline NO-GAP.
WRITE:/4(154) sy-uline.
ENDAT.
ENDLOOP.
2009 Wipro Ltd - Confidential
Output
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
32
Output
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
33
Interactive Report
34
Introduction
when the user wants to interact with the report
35
Meaning
sypagno
Page number of the current page of the current list. Counting starts at 1.
sy-linno
sy-colno
Number of the column on which the cursor is positioned on the current list. Counting starts at 1.
sy-linct
Number of rows per page of the current list, if it was specified by the LINE-COUNT addition of the statement
REPORT or NEW-PAGE. Otherwise, sy-linct has the value zero.
sy-linsz
Row width of the current list. Set by the LINE-SIZE addition of the REPORT or NEW-PAGE statement.
sy-title
List title. Set in the text elements of a program or with SET TITLEBAR.
sy-srows
sy-scols
36
37
System
Field
Meaning
sy-lsind
List level of the current list; (basic list: 0, first secondary list: 1, ..., 20th secondary list: 20). sy-lsind can be
set in the program to replace the current list with the list of the set level.
sy-lilli
sy-listi
sy-lisel
sycurow
Number of the row in the window, on which the cursor of the displayed list was positioned. Counting starts
at 1.
sy-cucol
Number of the column in the window, on which the cursor was positioned on the displayed list. Counting
starts at 2.
sycpage
sy-staro
Number of the row of the displayed list. Counting starts at 1, the rows of the page header are included.
sy-staco
syucomm
sy-pfkey
Events used
38
AT LINE-SELECTION
This statement defines an event block whose event is triggered by
the ABAP runtime environment during the display of a screen list provided the screen cursor is on a list line and you select a function
using the function code PICK.
This event is triggered when the user double clicks on the list since
the standard list status is automatically enhanced in such a way that
the function key F2 and, with it, the double-click mouse function is
linked up to the function code PICK.
39
At User-Command
This statement defines an event block whose event is triggered by
the ABAP runtime environment if, during the display of a screen list,
a function with a self-defined function code was chosen.
Self-defined function codes are all those that include character
combinations.
Some Exceptions are
The function codes PICK and PF<nn>
40
Function Codes
All function codes that start with the character "%" are interpreted as
system functions and do not cause the event AT USER-COMMAND.
The system functions for lists are listed in the table 1.
Table 1
41
Function code
Function
%CTX
%EX
Exit
%PC
Save to file
%PRI
%SC
%SC+
Find next
%SL
Search in office
%ST
At PF<nn>
This statement defines an event block whose event is triggered by
the ABAP runtime environment during list display - provided the
screen cursor is on a list line and a function is selected using the
function code PF<nn>. Here <nn> stands for a number between 01
and 24.
Instead of AT PF<nn> , AT USER-COMMAND should always be
used and special function codes should be assigned to the required
function keys.
42
43
Example
44
AT LINE-SELECTION.
IF sy-lsind = 1.
GET CURSOR FIELD z_v_fld_nam.
IF sy-subrc = 0 AND z_v_fld_nam = 'Z_WA_Z_I_PO-LIFNR'.
SORT z_i_vend.
READ TABLE z_i_vend INTO z_wa_z_i_vend WITH KEY lifnr = z_wa_z_i_po-lifnr BINARY SEARCH.
WRITE:/4 sy-vline NO-GAP, z_wa_z_i_vend-lifnr NO-GAP,
sy-vline NO-GAP, z_wa_z_i_vend-name1 NO-GAP,
sy-vline NO-GAP, z_wa_z_i_vend-stras NO-GAP,
sy-vline NO-GAP, z_wa_z_i_vend-adrnr NO-GAP,
sy-vline NO-GAP, z_wa_z_i_vend-pstl2 NO-GAP,
sy-vline NO-GAP, z_wa_z_i_vend-ort01 NO-GAP,
sy-vline NO-GAP, (5) z_wa_z_i_vend-regio NO-GAP,
sy-vline NO-GAP, z_wa_z_i_vend-pstlz NO-GAP,
sy-vline NO-GAP.
WRITE:/4(159) sy-uline.
ENDIF.
ENDIF.
Example Contd..
TOP-OF-PAGE DURING LINE-SELECTION.
WRITE:/10 text-29a, z_wa_z_i_po-lifnr. "INFORMATION FOR VENDOR NUMBER
WRITE:/4(159) sy-uline.
WRITE:/4 sy-vline NO-GAP, text-21a NO-GAP,
"Vendor No.
15 sy-vline NO-GAP, 16 text-22a NO-GAP, "Vendor Name
51 sy-vline NO-GAP, 52 text-27a NO-GAP, "Street
87 sy-vline NO-GAP, 88 text-23a NO-GAP, "Address No
98 sy-vline NO-GAP, 99 text-28a NO-GAP, "Postal Cd.
109 sy-vline NO-GAP, 110 text-24a NO-GAP, "City
145 sy-vline NO-GAP, 146 text-25a NO-GAP, "State
151 sy-vline NO-GAP, 152 text-26a NO-GAP, "Pin Code
162 sy-vline NO-GAP.
WRITE:/4(159) sy-uline.
45
Output
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
46
Output
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
47
48
READ LINE
MODIFY LINE
SCROLL LIST
DESCRIBE LIST
GET CURSOR
SET CURSOR
SET PF-STATUS
SET TITLEBAR
LEAVE TO LIST-PROCESSING
LEAVE LIST-PROCESSING
Example
49
Thank You