Sunteți pe pagina 1din 50

INTERACTIVE REPORTS

2009 Wipro Ltd - Confidential

Agenda
1 General Introduction
2 Types of Reports
3 Classical Report
4 Interactive Report
5 Example

2009 Wipro Ltd - Confidential

GENERAL INTRODUCTION

2009 Wipro Ltd - Confidential

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.

Generally two screens are involved in Reports.


Selection Screen
List Screen

2009 Wipro Ltd - Confidential

Screens of a Report

2009 Wipro Ltd - Confidential

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.

2009 Wipro Ltd - Confidential

Selection Screen
User can enter the criteria for selection
PARAMETERS
SELECT-OPTIONS

Sign
Option
Low
High

2009 Wipro Ltd - Confidential

Processing of Selection Screens


Events used to process the selection screens
At Selection Screen Output
At Selection Screen

On <field>
On Block <Blk>
On Radio button Group
On Help-Request
On Value-Request

2009 Wipro Ltd - Confidential

Output Screen
Contains the data to be displayed
Write Statement

Different types of formatting options are there

Colors
Display either Foreground or Background Colors
Inverse Off (Background Color) (Default)
Intensified On (Intensive Background Color)
Intensified Off (Weak Background Color)

Inverse On (Foreground Color)

2009 Wipro Ltd - Confidential

Output using Colors


Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level

10

2009 Wipro Ltd - Confidential

Output Screen
Other Formatting Options
Positioning the Output

11

Write:/5(10) Example, to understand position.


Skip
ULINE
New-Line
New-Page
Set Blank Lines
Reserve

2009 Wipro Ltd - Confidential

Set Blank Lines On - Example

12

WRITE:/ 'BEFORE SET BLANK LINES ON'.


Write:/ '
test',
/'
',
/'
test'.
SET BLANK LINES ON.
WRITE:/ 'AFTER SET BLANK LINES ON'.
Write:/ '
test',
/'
',
/'
test'.

2009 Wipro Ltd - Confidential

Types of Reports
Classical Report

Interactive Report
ALV (ABAP List Viewer)

13

2009 Wipro Ltd - Confidential

Classical Report

14

2009 Wipro Ltd - Confidential

Classical Report
These are the most simple reports. Programmers learn this one first.

It is just an output of data using the Write statement inside a loop.


Classical reports are normal reports. These reports are not having
any sub reports.
IT IS HAVING ONLY ONE SCREEN/LIST FOR OUTPUT
Write Statement

15

2009 Wipro Ltd - Confidential

Example
TYPES: BEGIN OF Z_T_MAT,
MATNR TYPE MATNR,
MTART TYPE MTART,
MBRSH TYPE MBRSH,
MATKL TYPE MATKL,
END OF Z_T_MAT.

DATA: Z_I_MAT TYPE STANDARD TABLE OF Z_T_MAT,


Z_WA_Z_I_MAT TYPE Z_T_MAT.

SELECT-OPTIONS: Z_S_MTNR FOR Z_WA_Z_I_MAT-MATNR.

16

2009 Wipro Ltd - Confidential

Example
SELECT MATNR MTART MBRSH MATKL INTO TABLE Z_I_MAT F
ROM MARA WHERE MATNR IN Z_S_MTNR.

LOOP AT Z_I_MAT INTO Z_WA_Z_I_MAT.


WRITE:/5 Z_WA_Z_I_MAT-MATNR,
Z_WA_Z_I_MAT-MTART,
Z_WA_Z_I_MAT-MBRSH,
Z_WA_Z_I_MAT-MATKL.
ENDLOOP.

17

2009 Wipro Ltd - Confidential

Output
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level

18

2009 Wipro Ltd - Confidential

Standard Page Heading


Goto -> Text Elements -> List Headings

19

2009 Wipro Ltd - Confidential

Output
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level

20

2009 Wipro Ltd - Confidential

Introducing Events
The events used are:
Initialization
Start-of-Selection
End-of-Selection
Top-of-Page
End-of-Page

21

2009 Wipro Ltd - Confidential

Initialization
It is the first event that is triggered in the flow of the program

What is the need of the Initialization Event?


Used to initialize the values

22

2009 Wipro Ltd - Confidential

Significance of Initialization
PARAMETERS: z_p_dat TYPE sy-datum.

Suppose if we want to give a value to this parameter as the current date on


application server,
PARAMETERS: z_p_dat TYPE sy-datum DEFAULT sy-datum.

Suppose if we want to give a value to this parameter as the tomorrows date


on application server,
We will go for the Initialization Event

23

2009 Wipro Ltd - Confidential

Start-of-Selection

Every Report contains this event either explicitly or implicitly.

In an executable program, all statements that are not declarations


and that are listed before the first explicit processing block, or if the
program does not contain any explicit processing blocks, then all
functional statements of the program, are assigned to an implicit
event block START-OF-SELECTION
The execution of the program starts from this event

24

2009 Wipro Ltd - Confidential

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.

2009 Wipro Ltd - Confidential

Top-of-Page
Event used to create the Page Headings for your report.

This event is triggered


When the first Write statement is encountered
At the beginning of a new page

26

2009 Wipro Ltd - Confidential

End-of-Page
Event used to create the Page footer for your report.

This event is triggered


At the end of a page

27

First we have to reserve the lines for the footer

It is done in the Report Statement

2009 Wipro Ltd - Confidential

Example

SELECT-OPTIONS: z_s_dat FOR z_v_dat


OBLIGATORY DEFAULT '20080101' TO '20081101'.
TOP-OF-PAGE.
WRITE:/10 text-31a. "PURCHASE ORDERS GROUPED BY MATERIAL GROUP.
WRITE:/10 text-32a. "DOCUMENT CATEGORY - PURCHASE ORDER(F).
WRITE:/10 text-33a. "DOCUMENT TYPE - PURCHASE REQUISITION(NB).
WRITE:/10 text-34a. "STATUS - ENJOY PURCHASE ORDER(9).
WRITE:/10 text-35a, z_s_dat-low, text-36a, z_s_dat-high. "FROM: "TO:
WRITE:/4(154) sy-uline.
WRITE:/4 sy-vline NO-GAP, text-01a NO-GAP,
"Srl.
9 sy-vline NO-GAP, 10 text-02a NO-GAP, "Material
19 sy-vline NO-GAP, 20 text-03a NO-GAP, "Purchase
30 sy-vline NO-GAP, 31 text-04a NO-GAP, "Vendor
41 sy-vline NO-GAP, 42 text-03a NO-GAP, "Purchase
54 sy-vline NO-GAP, 55 text-06a NO-GAP, "Payment
62 sy-vline NO-GAP, 63 text-07a NO-GAP, "
Payment Term
93 sy-vline NO-GAP, 94 text-02a NO-GAP, "Material
112 sy-vline NO-GAP, 113 text-08a NO-GAP, " Ordered
130 sy-vline NO-GAP, 131 text-09a NO-GAP, "Net Value
147 sy-vline NO-GAP, 148 text-10a NO-GAP, "UOM
151 sy-vline NO-GAP, 152 text-12a NO-GAP, "CUKY
157 sy-vline NO-GAP.

28

2009 Wipro Ltd - Confidential

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

2009 Wipro Ltd - Confidential

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

2009 Wipro Ltd - Confidential

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

2009 Wipro Ltd - Confidential

Output
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level

33

2009 Wipro Ltd - Confidential

Interactive Report

34

2009 Wipro Ltd - Confidential

Introduction
when the user wants to interact with the report

Suppose if the user wants to display the Purchase Orders in the


Basic List and when he double clicks on the vendor Number, display
the Vendor Information in the secondary list
1 Basic List and 20 Secondary Lists
Hide Statement
Used to hold the values

35

2009 Wipro Ltd - Confidential

System Fields During List Creation


System
Field

Meaning

sypagno

Page number of the current page of the current list. Counting starts at 1.

sy-linno

Number of the current row on the current page. Counting starts at 1.

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

Current number of rows in the display window. Counting starts at 1.

sy-scols

Current number of columns in the display window. Counting starts at 1.

36

2009 Wipro Ltd - Confidential

System Fields After List Events

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

Absolute number of a selected row in the displayed list. Counting starts at 1.

sy-listi

List level of the displayed list.

sy-lisel

Content of the selected row.

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

Number of the displayed page of the displayed list. Counting starts at 1.

sy-staro

Number of the row of the displayed list. Counting starts at 1, the rows of the page header are included.

sy-staco

Number of the displayed column of the displayed list. Counting starts at 1.

syucomm

Function code that triggered the event on the displayed list.

sy-pfkey

GUI status of the displayed list.


2009 Wipro Ltd - Confidential

Events used

The events used are:


AT LINE-SELECTION
AT USER-COMMAND
AT PF<nn>

38

2009 Wipro Ltd - Confidential

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

2009 Wipro Ltd - Confidential

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

2009 Wipro Ltd - Confidential

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

Call a context menu

%EX

Exit

%PC

Save to file

%PRI

Print

%SC

Search for ...

%SC+

Find next

%SL

Search in office

%ST

Save to report tree

2009 Wipro Ltd - Confidential

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

2009 Wipro Ltd - Confidential

Heading on the Detail Lists


Standard Page heading is not Effective with respect to the
secondary lists
The Top-of-Page event is also not effective for the detail lists.
The heading in the detail lists can be displayed using the event Topof-Page During Line-Selection

43

2009 Wipro Ltd - Confidential

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.

2009 Wipro Ltd - Confidential

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

2009 Wipro Ltd - Confidential

Output
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level

46

2009 Wipro Ltd - Confidential

Output
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level

47

2009 Wipro Ltd - Confidential

Other Commands used in List-Processing

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

2009 Wipro Ltd - Confidential

Example

MODULE call_list OUTPUT.


SET PF-STATUS space.
WRITE 'Basic List'.
LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 0.
LEAVE SCREEN.
ENDMODULE.
TOP-OF-PAGE.
WRITE 'Header' COLOR COL_HEADING.
ULINE.
TOP-OF-PAGE DURING LINE-SELECTION.
WRITE sy-lsind COLOR COL_HEADING.
ULINE.
AT LINE-SELECTION.
WRITE 'Secondary List'.
IF sy-lsind = 20.
LEAVE LIST-PROCESSING.
ENDIF.

49

2009 Wipro Ltd - Confidential

Thank You

2009 Wipro Ltd - Confidential

S-ar putea să vă placă și