100% found this document useful (1 vote)
492 views

Reports Complete Notes

The document discusses various types of reports in ABAP including simple reports, hierarchical reports, control break reports, interactive classical reports, logical database reporting, and ALV reports. It also describes concepts like joins, select options, ranges, and classical interactive reporting. Hierarchical reports display data in a parent-child format linking two tables. Control break reports use events like AT FIRST, AT NEW, AT END OF, and AT LAST to generate headings, subheadings, subtotals, and footers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
492 views

Reports Complete Notes

The document discusses various types of reports in ABAP including simple reports, hierarchical reports, control break reports, interactive classical reports, logical database reporting, and ALV reports. It also describes concepts like joins, select options, ranges, and classical interactive reporting. Hierarchical reports display data in a parent-child format linking two tables. Control break reports use events like AT FIRST, AT NEW, AT END OF, and AT LAST to generate headings, subheadings, subtotals, and footers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 19

CORE ABAP FROM GENSOFT TECHNOLOGIES

POWERED BY Mr. Sridhar Sunkari

Reports:

It is a process of retrieving the data from the database based on the


user input, processing the retrieved data and displaying it in
summarized format so that the user can analyze the data.

Types of Reports:

1. Simple Report  Single / Multiple Tables (Joins)

2. Hierarchical Report

3. Control Break Report

4. Interactive Classical Report

5. Logical Database reporting (Hr-ABAP)

6. ALV Reports (OOPS-ABAP)

Hierarchical Reports:

In this, the data is displayed in the form of parent and child.

VBAK (Sales Document Header Data) -> vbeln , erdat , erzet , ernam.

VBAP (Sales Document Item Data) -> vbeln , posnr , matnr .

Each sales document of VBAK table can contain one or more sales items
in VBAP table.

Whenever we retrieve the data using select statement into an internal


table which is already containing data, then the existing contents of
the internal table will be over written with the latest retrieved
data. We can avoid this by using ‘appending corresponding fields into
table’ (or) ‘appending table’ keyword as part of select statement.
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari

FOR ALL ENTRIES:

Using Select statements inside loop-endloop will degrade the


performance because the no. of select statements execution depends on
no. Of times the loop is iterated.

This can be avoided by using ‘for all entries’ keyword as part of


select statement. To use ‘FOR ALL ENTRIES’ in select queries there
should be one logically related field between the target DB table and
source internal table and this field should be compared using where
clause as part of select query using ‘for all entries’.

Before using ‘for all entries’, check whether source internal table
contains at least one entry.

Select..EndSelect: is a open SQL statement used for retrieving


multiple records from the database. It is a looping statement, where
in, for each select statement execution, it retrieves single record,
and the no. of times the select query execution depends on the no. of
records satisfying the condition. If there are more select queries, it
increases network traffic and thereby decreases performance. Because
of this reason, it is recommended to minimize the usage of
select..endselect and instead use ‘select into table’ statement and
retrieve the required no. of records into internal table using only
one select statement execution.

Order by clause: in select query retrieves the data from database in


sorted order of the specified field. Using Order by clause in select
query decreases performance as it increases load on database server.
We can avoid this by using sorting the data on internal table after
retrieval.

Controls break reports:


CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari

As part of this we use control break events which are also called as
“AT” events. These events are used only in loop- endloop.

At first: This event is triggered when we are processing the 1 st row of


the internal table. This event can be handled to provide heading for
the report before displaying the data.

Syntax:

At first.

Statements.

Endat.

At new:

This event is triggered at the beginning of a first row combination


whenever a unique value is encountered for the specified field. This
event can be handled to generate sub heading at the beginning of every
unique value.

Syntax:

At new <field name>.

Statements.

Endat.

At end of :-

This event is triggered at the end of the last row combination of


every unique value for the specified field. This event can be handled
to generate subtotals at the end of every unique value.

Syntax:

At end of <field name>.


CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari

Statements.

Endat.

At last:

This event is triggered at the end of the last row of the


internal table. This event can be handled to generate footer for the
report like grand total.

Syntax:

At last .

Statement.

Endat.

Sum statement:

Sum statement can be used as part of “at end of” and “at last” event.
This statement will do the sum of numeric fields of the corresponding
rows and stores the sum value with in the same field. This sum value
can be accessed within the same events. i.e. the sum value will be
destroyed once a control comes out of the event.

Onchange of:

It is similar to “at new “event, but “on change of” event can be used
in any of the looping statements like while – endwhile., do enddo,
select – endselect, loop-endloop whereas ‘at new’ can be used only
inside loop-endloop.

Note: The field specified in ‘at new’ and ‘at end of’ event should be
at the beginning of the internal table otherwise, these 2 events are
triggered for every record of the internal table.
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari

Select-options:

It generates a selection-screen for reading range of input values. It


is an internal table created in the run time based on the field.
It contains following structure:

a) Sign  Possible values are ‘I’ (Inclusive) / ‘E’ (exclusive)

Default value is ‘I’

 ‘I’  considers values from lower limit to upper limit

 ‘E’  considers values before lower limit and after


upper limit

b) Option  Possible values are ‘BT’(between), <, >,<=,>=

 Default value is ‘BT’

c) Low  holds lower limit of the range

d) High  holds upper limit of the range

Syntax for declaring select-option:

Select-options <variable> for <target field>.

Note: In the above syntax, if the target field is referring to


dictionary structure field, then target dictionary structure should be
declared explicitly using ‘tables’ keyword. ‘Tables’ KEYWORD will
create work area with all the fields of the dictionary structure which
is a performance issue. Because of this reason, it is recommended not
to declare select-option referring to dictionary structure. The
Recommended declaration is to declare a local variable referring to
dictionary structure field and then declare the select-options
referring to local variable. We can use the addition ‘no-extension’ as
part of select-option declaration to restrict the user to enter only
single range on the selection screen.

Ranges:
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari

It is used for holding range of values. It is an internal table


created in the run time based on the field. It contains same
structure as that of select-options:

e) Sign  Possible values are ‘I’ (Inclusive) / ‘E’ (exclusive)

f) Option  Possible values are ‘BT’(between), <, >,<=,>=

g) Low  holds lower limit of the range

h) High  holds upper limit of the range

Syntax for declaring Range:

Ranges <variable> for <target field>.

Joins:

Joins are used for retrieving data from multiple database tables using
a single select query.

Joins are of two types:

i. Inner join

ii. Left outer join

For retrieving data from multiple tables using joins, there should be
at-least one logically related field between the two tables and this
field should be compared by using ‘ON’ statement as part of Select
Query. The compared field/s between two tables must have the same
property i.e. data types and size must be same. The field names need
not be same.

i. Inner join:

In this, the left hand side table is compared with right hand side
table.

As part of this comparison, the value of the compared field from the
left hand side row will be compared with all the rows of the right
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari

hand side table. If any matching row is found in the right hand side
table, it picks the corresponding rows from left hand side and right
hand side tables. If no matching row is found in the right hand side
table, SAP even ignores the left hand side row also.

ii. left outer join:

It is similar to inner join, but instead of ignoring the deficiency


row, it picks the row from the left hand side table and the right hand
side table row fields is filled with 0’s and nulls(space) according to
data type.

Note: Using Joins in select query degrades the performance, SO


Instead of using joins in the select statement, it is recommended to
create the views on the corresponding tables and specify the view name
as part of the select query.

By default the database view follows inner join.

By default the help view follows left outer join.

Note: Line-size is the option as used as part of report statement to


control the no. of characters per line.

Classical interactive reporting:

This is generated based on the user interaction in the runtime.

In classical interactive reporting: we can generate up to 21 lists.


The first list is called as basic list and the remaining 20 are called
as secondary list.

“SY-LSIND” is the system field which stores the index OF NEXT LIST
(secondary list). For the basic list, index is zero and the secondary
lists indexes ranges from 1 to 20.

As part of this we use following events.

1. At line-selection: This event is triggered when the user double


clicks on a list value or a single click on a hotspot list
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari

value. In this case, the line content where the user has done
the interaction is captured in the system field “SY-LISEL” and
the line number is captured in “SY-LINNO”.

2. Top-of-page: This event is triggered in the basic list and it


can be handled to generate the heading for the basic list.

3. Top-of-page during line-selection: This event is triggered in


the secondary lists and it can be handled to generate the
heading for secondary list.

4. End-of-page: This event might be triggered in every list


whenever the end of page is reached. This event can be handled
to generate the footer for the list pages.

Note: End-of-page event is triggered only when the end of page is


reached, for this, we need to control the number of lines per page.
This is done by using line-count option as part of report statement.

Note: If the no. of lines reserved for the page is consumed by ‘TOP-
OF-PAGE’ event or ‘TOP-OF-PAGE DURING LINE-SELECTION’ event itself, it
leads to runtime error ‘list page overflow’ as the content cannot be
fitted on the page.

No standard page heading: is the option used as part of report keyword


which suppresses the default page heading.

SY-LISEL - stores entire line content where the user has done the
interaction.

Hotspot on: is an option used as part of write statement to display a


column value as hotspot (link to other).

Hide statement:

It is used after the write statement and it writes the value of a


variable to the hide memory area (invisible memory area). This hide
memory area gets refreshed whenever the ‘at line-selection’ event is
triggered and it maintains only one value where the user has done the
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari

interaction. Based on this value, we can get the content for the next
list.

Get cursor field: It is used for identifying the field name and field
value on the list where the user has done the interaction..

Set parameter id: It is used for setting the value of a parameter id


in the global SAP memory. This value can be retrieved by using ‘get
parameter id’ statement.

Sequence of events execution in Selection Screen:

1. Initialization, at selection-screen output  Before selection


screen is displayed for first time

2. After User interaction in the runtime

Case 1: Enter key in input field  at selection-screen on


<field>,at selection-screen, at selection-screen output

Case 2: Clicking a button  at selection-screen, at selection-


screen output

Case 3: Selecting/Deselecting a checkbox  at selection-screen,


at selection-screen output

Case 4: Selecting a radio button in radio button group  at


selection-screen on radio button group <group name>, at
selection-screen, at selection-screen output

Sequence of events execution in L.P.S (List Processing screen):

Scenario 1: No selection-screen available

1. Load-of-program  used for initializing global variables

2. Top-of-page (if available)  used for generating heading for


basic list

3. Initialization (if available)  used for initializing


selection screen fields
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari

4. Start-of-selection  indicates starting point of program


execution

5. End-of-selection  last event to be executed and can be used


for clearing the variables, work areas, internal tables and
all closing activities (closing the file, closing the session
object….)

Scenario 2: selection-screen available

1. Load-of-program

2. Top-of-page

3. Initialization

4. At selection-screen output  Selection screen displayed

On click of execute button of selection screen appl.toolbar

1. At selection-screen

2. Start-of-selection

3. End-of-selection

On interaction of selection screen elements like button

1. At selection-screen

2. At selection-screen output

Note: We can use ‘stop’ statement for exiting the control from the
current event in execution.

Sequence of events execution in Module Pool:

1. PBO

2. After User interaction in the runtime (enter key in input


field, clicking a button, selecting/deselecting a checkbox,
selecting a radio button, selecting a value in the dropdown)
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari

a) PAI

b) PBO

3. Runtime --> f4 key in input field ---> POV

3. Runtime --> f1 key on screen element --> POH

Logical Databases: (HR-ABAP)

In Hr Module, we retrieve the data from HR tables using Logical


databases. There are many standard logical databases provided by SAP
itself. Eg: PAP, PNP, PNPCE…. These standard logical databases can be
used as part of Hr-ABAP when we want to read data from HR tables.

To develop custom logical databases, we use logical database builder


(SE36). A Logical database is a collection of nodes. Each node can be
associated with a DB table. A Logical database automatically generates
2 programs.

1. Selection program (Include Program)  contains statements


responsible for generating selection screen (parameters, select-
options…)

2. Database program (Report Program)  contains select queries to


retrieve data from database tables.

Once a logical database is available, it can be associated with any


no. of executable programs. This can be done as part of Report
attributes.

Once a logical database is attached to a report program, we can invoke


the logical database by using ‘GET’ statement.
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari

Click on selections button on appl. Toolbar (opens selection program)


CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari

Foreground execution of reports:

1. Execute --> displays selection screen --> input values --> execute

2. Output in the form of List

Background scheduling of reports:

Advantages:

1. Automatic execution without user interaction

2. Should be executed automatically on a periodic basis

Procedure:
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari

1. Identify the program name (Report) which needs to be scheduled in


the background.

2. Check whether the program contains selection screen, if it


contains selection screen, create one or more variants

Variant is an object which is associated with input values of


selection screen.

1. Create the Background job (SM36)

a) job name --> JB1

b) job classification (priority) --> A

c) start condition --> IMMEDIATE

d) define step

i) program name --> ZREPORT18

ii) variant name --> VAR1

e) save the job --> job gets released

Note: Once the job is released, job gets executed depending on the job
start condition

2. Check the job execution status (SM37)

Note: Once the job is executed, the output associated with the job
will be stored as a spool request which can be viewed through
'SP01' / Business workplace

Spool request is an object which is associated with output list

Note: We can schedule the background jobs to be executed after


triggering a background event. For this, we need to create the
background event in ‘SM62’ and then raise the event in any of the
executable programs whenever a certain condition is satisfied. To
raise the background event, we need to use the F.M. ‘BP_EVENT_RAISE’.
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari

To schedule the job dynamically, 3 F.M's are used

1. job_open

2. job_submit

3. job_close

You might also like