Вы находитесь на странице: 1из 25

Slide

1 of
27

Lesson Purpose

The purpose of this lesson is to examine report writer features and the relationship
between an ABAP/4 query and a report.
Slide
4 of
27

Overview of Reporting

• An ABAP/4 report is a program which reads data from the database, sorts the data
according to certain criteria and outputs the data in form of a list on the screen.
• To generate a list, you can create a query with ABAP/4 Query or write your own
ABAP/4 report.
• ABAP/4 Query is a user-friendly tool which allows you to define the layout of a list
without any programming knowledge.
• When programming an ABAP/4 report, you can use all the facilities available in the
programming language to evaluate complex data.
Slide 5 of 27

Structure of a Logical Database

• The structure of a logical database takes into account that data retrieval is similar for
different reports. Since the access paths differ from task to task, there are different logical
databases. Logical databases allow you to include database tables which are defined in
the ABAP/4 Dictionary and which are known in the system. You give the tables their
ABAP/4 Dictionary names and declare them in the report using the TABLES statement.
• The report RSDBST00 provides information about each logical database.
• To display the structure of a logical database, choose Utilities >>> Help on... in the
Editor (PC mode) and choose Logical database in the following dialog box. To display a
list of the available logical databases, click on the possible entries pushbutton of the
Logical database field.
• The above figure shows the structure of the logical database F1S (BC: planned flights,
flights and bookings).

To view the Display Table Fields for each of the relations, click the name of the relation in
the main slide image. To examine the Table/Structure screen, click the desired selection
below.

Table/Structure: Display Fields: SPFLI


Table/Structure: Display Fields: SFLIGHT
Table/Structure: Display Fields: SBOOK
Slide
6 of
27

Reading Data

• Basically, there are two ways you can read data:


1. Program the read in the relevant program using the SELECT statement (report-
driven data retrieval).
For performance reasons, it is better to use SELECT ... FOR ALL ENTRIES IN
<itab> WHERE <cond> than nested SELECT statements.
2. Use a special read program - known as a logical database - to read the required
data and make it available to your program in the correct sequence. In this case,
you only have to program the statements which process the data.

• You can use report-driven data retrieval and logical databases side by side
in the same report.

• In a report, the connection between the report processing and the logical database lies in
the event key word GET. This event is triggered by the logical database after the database
has read a particular data record and stored it in the report’s work area. The report itself
does not read the record because it is already available for processing.
Slide
7 of
27


• GET Statement
• The most important event for report programs with an attached logical database is the
moment at which the logical database program has read a line from a database table. The
GET statement is used to start a processing block at the event of reading a line from a
database table.
• After the GET statement, you can work with the current line of the database table
<table>. The data is provided in the table work area <table>.
• Performance can be much better for tables that are designated for field selection in the
logical database used with the GET statement.
Slide
8 of
27


• GET Statement Report
• The output of the report produced with the GET statements is organized as a report
heading with the data for the selected From and To cities and with a second level heading
for a change in the carrid and the connid. This is one method of producing a report with
these break-on report organization arrangements.
Slide
9 of
27

Events I

• ABAP/4 is an event-driven programming language. Reports which are linked to logical


databases are not processed sequentially. Besides the GET event, the report can use a
number of other event key words to perform processing. These events are triggered by
the ABAP/4 processor which determines the sequence of events. If processing is
scheduled in the logical database for these events, it is executed before the event in the
report is triggered. The processing block defined for a event key word is executed
procedurally and concludes when the next event occurs.
• The START-OF-SELECTION event is executed before the logical database starts
reading the data. This event is set by default.
Slide
10 of
27


• Events II
• You can define interactive events in ABAP/4 reports. These events are
triggered when the user presses a particular function key or pushbutton. They
allow for the creation of secondary lists which display detailed information.
Slide
11 of
27

Interactive Reporting: Overview

Interactive reporting allows you to create secondary lists and windows. To call these and display
them on the screen, you use function keys. You can thus distribute all the information returned
by the report across several screens, gradually outputting more and more detailed information.

Using function keys, the user can also branch to:

• a transaction
• another report
Slide
12 of
27


• Line Selection I
• To enable the user to choose a line in a list and display detailed
information for this line in a secondary list, you can use the AT LINE-
SELECTION event.
• This event is processed when the user selects a valid line in the list with
the cursor and activates the function key assigned to the PICK function in the
interface definition. If there is no interface defined, the event is triggered by
pressing F2 or by double-clicking.
Slide
13 of
27


• The HIDE Area
• By default, the data of the basic list is not available when you are in the
secondary list.
• However, the HIDE statement allows you to store field contents for a
particular list line in a special area. For each field, the system stores the field
name and the value.
• The HIDE command must immediately follow the WRITE statement since
the information is stored for each output line. You can also use the HIDE area to
store fields which do not appear in the list.
Slide
14 of
27


• Line Selection II
• As soon as the user selects a line by double-clicking or positioning the
cursor, and triggers an interactive event (in this case AT LINE-SELECTION) by
pressing a function key or pushbutton, the system passes the values stored for this
line in the HIDE area to the corresponding work area.
Slide
15 of
27


• Valid Line Selection
Slide
16 of
27

User Messages: Overview

If the user has entered inconsistent values or has selected values without having the appropriate
authorization, you output a dialog message with the key word MESSAGE.

• Dialog messages are stored in table T100. They are classified by language, two-character
ID and three-character name.
• Messages can contain up to four variables represented in the message text with an & for
each variable. The &s are filled from the variables positionally.
• If you want to output & in a message it does not represent a variable, you must enter it
twice. For example: 'This is a message with an &&'.
• You can create your own messages using an ID which starts either with Y (head office)
or Z (branch).
Slide
17 of
27

Syntax: MESSAGE Statement

• You output messages with the MESSAGE statement. Here, the language used for table
T100 is the logon language. You specify the message ID after the MESSAGE-ID
parameter of the REPORT statement. This message ID applies to the entire report. You
specify the message number in the MESSAGE statement.
• Immediately before the three-digit number, you specify the message type which
determines how the user is meant to react to the message (see next page).
• After the WITH parameter, you enter the values for the variables (up to four). You can
also specify fields or literals here. The i-th field replaces the variable &i in the message.
If the variables in the message are only represented by & or $, these placeholders are
supplied with the values of the fields in the MESSAGE statement according to their
position.
• Unlike the message ID in the REPORT statement, you can enter a message ID in the
MESSAGE statement yourself by specifying the ID immediately after the message
number in parentheses. However, this ID applies only to the current message. For
example: MESSAGE E004(UD).
• If you want to send a dynamic message, you can use the following syntax:
MESSAGE ID <mid> TYPE <mtype> NUMBER <mno.> WITH <filed1> <field2>
<field3> <field4>.
• The system fields SY-MSGID, SY-MSGTY and SY-MSGNO contain the message ID,
the message type and the message number respectively, while the system fields SY-
MSGV1 through SY-MSGV4 contain the fields for the placeholders.

Slide
18 of
27

Classification of Dialog Messages

• There are six message types:

A Abend Processing terminates and the user has to restart the transaction.
X Exit As message type A, but with short dump MESSAGE_TYPE_X
E Error Processing is interrupted and the user must enter a new value.
Processing is interrupted and the user can either enter a new value
W Warning (effect as with E messages) or just press ENTER to confirm the
values (effect as with I messages).
Processing is interrupted and the system resumes processing after the
I Information
user has pressed ENTER.
S Success Information is displayed on the next screen.
• To make the selection screen ready for input again when E and W messages occur, you
output these messages in the AT SELECTION-SCREEN event. In one of the subsequent
events (e.g. START-OF-SELECTION, GET or END-OF-SELECTION), these message
types behave like A messages.

Slide
19 of
27

Example of Dialog Message

If the user specifies an airline carrier as a parameter, an authorization check is performed in the
event AT SELECTION-SCREEN. As a result, the input has to be corrected before the reports
starts the data selection process.

• Advantages:
o There is no negative authorization check for any the records read from the
database.
o Authorization checks only have to be performed once for each airline carrier.
o Users learn whether or not they are authorized at the selection stage.

Slide
20 of
27

Conventional Reporting vs. ABAP/4 Query

• When you create a list with a report, the data is usually retrieved via a logical database,
processed by the report and then output as a list.
• When you create a query, you first assign a functional area which is basically a special
view of a logical database. You choose the fields you require from this functional area
and define the formatting and type of processing.
• When the query is started, an internal report generator creates a report in accordance with
the list definition and then reads, processes and outputs the data
Slide
21 of
27

ABAP/4 Query

ABAP/4 Query allows you to generate non-standard ABAP/4 reports in R/3. It is primarily
intended for users with no programming knowledge in ABAP/4.

• The queries are assigned to a user group. Any user belonging to this user group can
access these queries.
• A functional area can be assigned to several user groups.
• Several functional areas can be assigned to one user group.
• The queries of a user group are shared by all the users in that user group.
• A query is always created with reference to a particular functional area. This functional
area must be assigned to the user group.
• In general, you can access all the queries assigned to your user group.
• The advantage of a query with several partial lists is that data is read only once and
afterwards rearranged according to different aspects.
• QUERY lists:
o Basic list - presents data in the order defined by the Functional Area.
o Statistic - shows statistical figures calculated from the basic data.
o Ranked list - a specialization of a statistic, for example, the top ten customers of a
travel agency.

Вам также может понравиться