Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

REPORT EVENTS

Former Member
0 Likes
3,606

if any body can help me to know the report events and what is the importance of each report event,pls explain in detail

8 REPLIES 8
Read only

Former Member
0 Likes
2,030

Hi

The different events in a report Program are:

Load-of-program

Triggers the associated event in an internal session after loading a program of type 1, M, F, or S. Also runs the associated processing block once and once only for each program and internal session. The processing block LOAD-OF-PROGRAM has roughly the same function for an ABAP program of type 1, M, F or S as a constructor has for classes in ABAP Objects

Initialization.

This event is executed before the selection screen is displayed .

Initialization of all the values.

You can assign different values other than the values defaulted on the selection screen .

You can fill your selection screen with some values at runtime.

At Selection-Screen.

The event is processed when the selection screen has been processed (at the end of PAI ).

Validation & Checks of inputted values happen here

Extras :

…ON VALUE-REQUEST FOR psel_low_high .

The pushbutton for F4 (Possible entries) appears beside the appropriate field.

... ON HELP-REQUEST FOR psel_low_high

. ... OUTPUT

This event is executed at PBO of the selection screen every time the user presses ENTER

Start-of-Selection.

Here the program starts selecting values from tables.

End-of-selection.

After all the data has been selected this event writes the data to the screen.

Interactive Events

Used for interactive reporting. It is used to create a detailed list from a basic list.

Events in an ABAP/4 Report Program

Start-Of-Selection

Processing block is executed after processing the selection screen

All the data is selected in this block.

All the main processing on the data except for interactive reporting is handled in this block.

End-Of-Selection

Data which is selected and has been processed is printed to the screen in this block.

List Processing happens in this block

Top-of-Page.

New-Page.

End-of-Page.

Events during List Processing

Top-of-Page.

Triggered by the first write statement in the program

It is used to have a standard header in the program for all the pages.

TOP-OF-PAGE is only executed before outputting the first line on a new page

New-Page.

Can be used when one wants to display different data on different pages

Terminates the current page and continues output on a new page.

Will not trigger the Top-of-Page or End-of-Page.

End-of-Page.

It is used to have a standard footer for all the pages.

Triggered by the program if the number of records exceed the line-count of the program.

****************************************************

Report Events

This is the order of execution in Classical/Interactive Report Events

Classical Reports

Reports which are properly formatted (header, footer, page numbers etc.,) with the help of one or more external events like top-of-page,end-of-page etc., are called as CLASSICAL REPORTS.

Standard list.

Output of Report program is nothing but Standard list. It consists of one continuous page of 60,000 lines.

To restrict number of lines per page.

Report Zxxxxx line-count 25.

OR

Report Zxxxxx line-count 25(3).

( In this case 3 lines are reserved for footer)

To restrict Output width.

Report Zxxxx line-size 125.

To suppress standard page heading.

Report Zxxxx no standard page heading

Above all at a time:

Report Zxxxx line-count 25(3)

line-size 125

no standard page heading.

Screen Events List Events

Initialization. Start-of-selection

At selection-screen. Top-of-page.

At selection-screen on <field>. End-of-page.

End-of-selection.

We can initialize the selection-screen with calculated default values under this event.

Initialization.

s_date-high = sy-datum.

s_date-low = sy-datum - 15.

Append s_date.

We can validate all the inputs on selection screen fields under this event.

At selection-screen.

If s_carrid-low is initial or

s_connid-low is initial or

s_date is initial.

< ... code for validation... >.

Endif.

We can validate a particular field input on selection screen under this event.

At selection-screen on s_carrid.

If s_carrid-low < > ‘LH’.

<… code for validation…>

Endif.

If any of the other event comes before

‘Select…Endselect.’ statements, then to break

that event, we require this S-O-S event.

Start-of-selection.

Select * from ……

…………

Endselect.

If we need some portion of the output (like

column headings) to appear in all the pages,

then we use this event.

Top-of-page.

Write:/ ‘Carrier’,10 ‘Connection’ 20 ‘Date’.

If there is no external output statement before

‘Top-of-page’ event, then this event will not

work.

Once the cursor reaches the last line of the

page, automatically this event will be triggered.

Report Zxxx line-count 25(3).

In this case line numbers 23, 24 and 25 are

reserved for footer.

Once the cursor reaches 23rd line, this event

will be triggered.

End-of-page.

Write:/ sy-uline(75).

Write:/ ‘This is end of page:’,sy-pagno.

Write:/ sy-uline(75).

This event is used for concluding part of List.

End-of-selection.

Write:/ ‘This is end of the Report’.

Interactive Report

A simple report or even a classical report displays a clustered list with all the requested output at one go.

What ever it is displayed, it is final. That means, the user can not interact with with that list.

A simple report or even a classical report displays a clustered list with all the requested output at one go.

What ever it is displayed, it is final. That means, the user can not interact with with that list.

In the interactive reports, we can create as many as 21 lists.

The first list is called ‘Basic list’ and all the successive lists are called ‘Secondary lists’. Each list is again an interactive.

The Basic list is not deleted when secondary list is created.

A secondary list may either overlay the basic list or appear in an additional dialog window on the same screen.

The system variable associated with list number is ‘SY-LSIND’.

For basic list SY-LSIND = 0 and for secondary lists, SY-LSIND varies from 1 to 20.

User can interact with the list by the following ways.

Double clicking or single click and pressing F2 (function key) or single click with ‘hotspot on’.

OR

Selecting from menu bar or from application tool bar.

All the events used in classical reports can be used in Basic List.

The event ‘End-of-page’ can be used in Secondary Lists also.(the other six events can not be used in secondary lists)

You can not place ‘select-options’ in secondary lists.

The following additional events are

applicable to secondary lists.

Top-of-page during line-selection.

At line-selection.

At user-command.

When you double click on any field in the basic list, you will be navigating to secondary list with detailed information pertaining to clicked field.

As such we need to store the clicked field information at some variable.

‘Hide’ temporarily stores the content of clicked field for later use.

The default title of the out put is the text what we enter during creation of program.

This title can be changed using:

SET TITLEBAR ‘AAA’.

GUI status includes:

Menu bar

Application tool bar and

Activating standard tool bar

GUI status can be created using

SET PF-STATUS ‘BBB’.

You can have 8 menus ( out of which, 2 menus are reserved for ‘System’ and ‘Help’).

Each menu can have 15 menu items.

Each menu item can have 3 levels of submenus.

You can create 35 items in application tool bar.

Example Code

REPORT zs_stockreport3

NO STANDARD PAGE HEADING

LINE-SIZE 255

MESSAGE-ID zz1.

************************************************************************

  • Table Declaration *

************************************************************************

TABLES: mara,

marc,

mard.

************************************************************************

  • Types Declaration *

************************************************************************

TYPES: BEGIN OF typ_mara,

matnr TYPE mara-matnr, "Material Number"

mbrsh TYPE mara-mbrsh, "Industrial Sector"

mtart TYPE mara-mtart, "Material Type"

meins TYPE mara-meins, "Base Unit of Measure"

END OF typ_mara.

TYPES: BEGIN OF typ_makt,

matnr TYPE makt-matnr, "Material Number"

maktx TYPE makt-maktx, "Material Description"

END OF typ_makt.

TYPES: BEGIN OF typ_marc,

matnr TYPE marc-matnr, "Material Number"

werks TYPE marc-werks, "Plant Number"

END OF typ_marc.

TYPES: BEGIN OF typ_mard,

matnr TYPE marc-matnr, "Material Number"

werks TYPE marc-werks, "Plant Number"

lgort TYPE mard-lgort, "Storage Location"

END OF typ_mard.

************************************************************************

  • Intrnal tables Declaration *

************************************************************************

DATA: it_mara TYPE STANDARD TABLE OF typ_mara WITH HEADER LINE.

DATA: it_makt TYPE STANDARD TABLE OF typ_makt WITH HEADER LINE.

DATA: it_marc TYPE STANDARD TABLE OF typ_marc WITH HEADER LINE.

DATA: it_mard TYPE STANDARD TABLE OF typ_mard WITH HEADER LINE.

************************************************************************

  • Variable Declaration *

************************************************************************

DATA: v_count TYPE i.

************************************************************************

  • Selection Screen *

************************************************************************

SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECT-OPTIONS : s_matnr FOR mara-matnr.

SELECTION-SCREEN : SKIP.

PARAMETERS : p_mtart LIKE mara-mtart.

SELECTION-SCREEN : END OF BLOCK b1.

************************************************************************

  • Start Events *

************************************************************************

************************************************************************

  • Initialization *

************************************************************************

INITIALIZATION.

***

PERFORM initial_input.

************************************************************************

  • At Selection-screen *

************************************************************************

AT SELECTION-SCREEN.

***

PERFORM validte_inputdata.

************************************************************************

  • Start of Selection *

************************************************************************

START-OF-SELECTION.

***

SELECT matnr

mbrsh

mtart

meins

INTO TABLE it_mara

FROM mara

WHERE matnr IN s_matnr and

mtart = p_mtart.

if sy-subrc = 0.

sort it_mara by matnr.

else.

MESSAGE e001 WITH 'No data Found' ' For the Given'

'Selection Criteria'(400).

endif.

IF NOT it_mara[] IS INITIAL.

SELECT matnr

maktx

INTO TABLE it_makt FROM makt

FOR ALL ENTRIES IN it_mara

WHERE matnr = it_mara-matnr

AND spras = sy-langu.

if sy-subrc = 0.

sort it_makt by matnr.

endif.

ENDIF.

IF NOT it_mara[] IS INITIAL.

select matnr

werks

from marc

into table it_marc

for all entries in it_mara

where matnr = it_mara-matnr.

if sy-subrc = 0.

sort it_marc by matnr werks.

endif.

endif.

IF NOT it_marc[] IS INITIAL.

select matnr

werks

lgort

from mard

into table it_mard

for all entries in it_marc

where matnr = it_marc-matnr and

werks = it_marc-werks.

if sy-subrc = 0.

sort it_mard by matnr werks lgort.

endif.

endif.

DATA: a TYPE i.

loop at it_mara.

a = sy-tabix MOD 2.

IF a = 1.

FORMAT COLOR 5.

ELSE.

FORMAT COLOR OFF.

ENDIF.

read table it_marc with key matnr = it_mara-matnr

binary search.

if sy-subrc = 0.

read table it_mard with key matnr = it_marc-matnr

werks = it_marc-werks

binary search.

if sy-subrc = 0.

read table it_makt with key matnr = it_mara-matnr

binary search.

if sy-subrc = 0.

WRITE:/ sy-vline.

WRITE: 2 it_mara-matnr,

18 sy-vline, it_mara-mbrsh,

38 sy-vline, it_mara-mtart,

54 sy-vline, it_mara-meins,

78 sy-vline, it_makt-maktx,

120 sy-vline, it_marc-werks,

135 sy-vline, it_mard-lgort, 155 sy-vline.

clear : it_mara.

endif.

clear : it_makt.

endif.

endif.

endloop.

WRITE: /(155) sy-uline.

************************************************************************

  • Top of Page *

************************************************************************

TOP-OF-PAGE.

***

FORMAT COLOR 1.

WRITE: /(155) sy-uline.

WRITE:/ sy-vline.

WRITE: 2 'Material Number',

18 sy-vline, 'Industrial Sector',

38 sy-vline, 'Material Type',

54 sy-vline, 'Base Unit of Measure',

78 sy-vline, 'Material Description',

120 sy-vline, 'Plant',

135 sy-vline, 'Storage Location',155 sy-vline.

WRITE: /(155) sy-uline.

FORMAT RESET.

************************************************************************

  • End of Page *

************************************************************************

&----


*& Form Initial_Input

&----


  • Initailization of Select Option

----


FORM initial_input .

CLEAR s_matnr.

REFRESH s_matnr.

s_matnr-low = '100-100'.

s_matnr-high = '111-111'.

s_matnr-sign = 'I'.

s_matnr-option = 'BT'.

APPEND s_matnr.

p_mtart = 'ROH'.

ENDFORM. " Initial_Input

&----


*& Form Validte_Inputdta

&----


  • Validation of Select Option

----


FORM validte_inputdata .

SELECT SINGLE * FROM mara

WHERE matnr IN s_matnr.

IF sy-subrc <> 0.

MESSAGE e001 WITH 'Material'(002) 'Type'(003) 'Does Not Exit'(400).

ENDIF.

ENDFORM. " Validte_Inputdta

************************************************************************

  • End of Selection *

************************************************************************

Regards

vasu

Read only

Former Member
0 Likes
2,030

hi

good

Event related to reports are not triggered based on any statements in ABAP.

The event are triggered depended on the way the output is generated .

for eg:

Initialization : triggered when the report is loaded in memory.

At selection-screen output : triggered when the selection screen is loaded in memory before being displayed.

At selection-screen / <field> : before leaving the selection screen.

start-of-selection : the first event for displaying the report.

end-of-selection : after the start-of-selection is completed.

classiscal report events.

top-of-page : every time a new page is started in the list.

end-of-page : every time the list data reaches the footer region of the page.

interactive report events.

top of page during line selection : top of page event for secondary list.

at line-selection : evey time user dbl-clicks(F2) on the list data.

at pF<key> : function key from F5 to F12 to perform interactive action on the list.

<b><REMOVED BY MODERATOR></b>

thanks

mrutyun^

Message was edited by:

Alvaro Tejada Galindo

Read only

Former Member
0 Likes
2,030

hi sekhar,

go through this documentation which clarifies your doubt.

Order of Events:

Initialization

at selection screen

start of selection

top of page

end of page

end of selection...

so initialization is used to pass default values to parameters & select-options

End of page is triggered when the content in the list reaches the no of lines specified....in case if it fails then use reserve n lines to explicitly trigger end of page...

Difference between Select-options & Ranges:

Select-options & ranges are basically internal tables...

however ranges have no selection screen whereas select-options do have.....

The main difference between them is in ranges the fields low & high are statically declared whereas in select-options we can dynamically specify the range of selection....

<b>please reward points if helpfull</b>

with regards,

radhika kolluru.

Read only

Former Member
0 Likes
2,030

Hi,

Events in reports

Top-of-page

at selection-screen

start fo selection

at line selection

at user command

end of page

end of selection

Read only

Former Member
0 Likes
2,030

Hi,

Reporting events occur in a predefined sequence and only in executable programs started using SUBMIT. In general, every executable program is implicitly started using SUBMIT. Only when a regular transaction code(Not Reporting-transactions )is used for the start or external calls of their subroutines, SUBMIT is not triggered.

When an executable program is linked with a logical database, the assigned subroutine is executed in the database program before a reporting event is triggered.

Executable programs are only directly executable from the end user's perspective. Whenever an executable program is started using System - Services - Reporting or a report transaction, the SUBMIT statement is executed. Executable programs are the only programs that can be called using SUBMIT.

<u><b>Flow of an Executable Program</b></u>

The SUBMIT statement loads the called program in a separate internal session and starts a series of processes in the ABAP runtime environment that trigger events and actions in the called program in the following order:

Reporting event LOAD-OF-PROGRAM

The start values defined using the DEFAULT addition in the statements PARAMETERS and SELECT-OPTIONS are passed to the relevant data objects. The start values of all other data objects are set before LOAD-OF-PROGRAM.

Reporting event INITIALIZATION

The selection screen specified in selscreen_options is called if it contains at least one input field or button. Complete selection screen processing is performed. Before the first event of the selection screen processing, AT SELECTION-SCREEN OUTPUT, the values specified in selscreen_options are passed.

Reporting event START-OF-SELECTION

Different GET events, if the called program is linked with a logical database.

Reporting event END-OF-SELECTION

The basic list is called.

If the basic list is empty, the program is exited..

If the basic list is a print list, it is sent to the SAP spool system and the program is exited.

If EXPORTING LIST TO MEMORY is specified in list_options, the basic list is stored in the ABAP Memory and the program is exited.

Otherwise, the basic list is a screen list and is displayed on the screen. User actions on a displayed screen list trigger list events. The program is exited when the user exits the list display.

If no selection screen is displayed in step 4, because processing is performed in the background or not at all, the program flow is complete.

If a selection screen id displayed in step 4, the runtime environment calls the called program again after the basic list has been exited. During this new call, the runtime environment supplies the parameters, the selection criteria, and the free selections of the selection screen between the events INITIALIZATION and AT SELECTION-SCREEN OUTPUT with the previous input values. The program call is not complete until the user exits the selection screen processing by choosing Back, Exit, or Cancel.

The called program can be exited in any of these steps by using the LEAVE PROGRAM statement and during list processing by using LEAVE LIST-PROCESSING.

<b>Notes</b>

When the SUBMIT statement is executed, it is implicitly followed by an authorization check for the authorization group specified in the program attributes.

If the called program is linked with a logical database, the system calls the relevant subroutines of the database program for the steps listed above.

Regards,

Bhaskar

Read only

Former Member
0 Likes
2,030

Hi

Read only

Former Member
0 Likes
2,030

Hi Sekhar,

The following events occur at runtime of a typical report program which uses logical databases:

INITIALIZATION

Point before the selection screen is displayed

When you start a program in which a selection screen is defined (either in the program itself or in the linked logical database program), the system normally processes this selection screen first. If you want to execute a processing block before the selection screen is processed, you can assign it to the event keyword INITIALIZATION.

AT SELECTION-SCREEN

Point after processing user input on the selection screen while the selection screen is still active.

START-OF-SELECTION

The event START-OF-SELECTION gives you the possibility of creating a processing block after processing the selection screen and before accessing database tables using a logical database.

GET <table>

Point at which the logical database offers a line of the database table <table>.

GET <table> LATE

Point after processing all tables which are hierarchically subordinate to the database table <table> in the structure of the logical database.

END-OF-SELECTION

To define a processing block after the system has read and processed all database tables of a logical database, use the keyword END-OF-SELECTION.

The following events occur during the processing of the output list of a report program:

TOP-OF-PAGE Point during list processing when a new page is started

END-OF-PAGE Point during list processing when a page is ended

The following events occur during the display of the output list of a report program:

AT LINE-SELECTION Point at which the user selects a line

AT USER-COMMAND Point at which the user presses a function key or enters a command in the command field.

AT PF<nn> Point at which the user presses the function key with the function code PF<n>.

Read only

Former Member
0 Likes
2,030

First event -

Initialization : triggered when the report is loaded in memory.

At selection-screen output : triggered when the selection screen is loaded in memory before being displayed.

At selection-screen : before leaving the selection screen.

start-of-selection : the first event for displaying the report.

This event keyword defines an event block whose event is triggered by the ABAP runtime environment

when calling the executable program selection screen processing of a selection screen.

In an executable program, all statements that are not declarations,

and are listed before the first explicit processing block, are assigned to this event block.

If the program does not contain an explicitly defined event block START-OF-SELECTION,

these statements form the complete event block START-OF-SELECTION.

If a program contains an explicitly defined event block START-OF-SELECTION,

these statements are added to the beginning of the event block.

If the program contains no explicitly defined event blocks,

these statements form the entire event block START-OF-SELECTION.

end-of-selection : after the start-of-selection is completed.

classiscal report events.

top-of-page : every time a new page is started in the list.

end-of-page : every time the list data reaches the footer region of the page.

interactive report events.

top of page during line selection : top of page event for secondary list.

at line-selection : evey time user dbl-clicks(F2) on the list data.

at pF<key> : function key from F5 to F12 to perform interactive action on the list.

at user-command

Please check the order of events at

http://help.sap.com/saphelp_47x200/helpdata/en/9f/db99fa35c111d1829f0000e829fbfe/content.htm

http://help.sap.com/saphelp_47x200/helpdata/en/56/1eb6c705ad11d2952f0000e8353423/content.htm

c) list of interactive events

http://help.sap.com/saphelp_nw04/helpdata/en/9f/dba2eb35c111d1829f0000e829fbfe/content.htm

dilog programming events

PBO event

This event is triggered before the screen is displayed. The processing of screen before the display of screen is done in this event. For example, filling in default values in the screen fields.

PAI event

This event is responsible for processing of screen after the user enters the data and clicks the pushbutton. The processing of screen can include displaying another screen, or just displaying list or quitting the transaction itself and many more things. Usually it is displaying another screen. These operations can be carried out in the PAI event. OKCODE plays an important role in this operation.

POV event

Process on value request is triggered when the user clicks F4 key. You can handle this event when the user presses F4 key by writing code for the same in module pool program. Normally when the user presses F4, list of possible values is displayed. The standard list produced by system is adequate for applications you develop yourself. However, you can also have the option of setting up your own documentation and lists of possible values that are more detailed.

POH event

Normally when the user places the cursor on the field and presses F1 function key, the system displays its own Help for that particular field. You can add your own functionality to the Help button by writing code for the same in the POH event.

http://help.sap.com/saphelp_webas630/helpdata/en/9f/db9cdc35c111d1829f0000e829fbfe/content.htm

http://www.sapdevelopment.co.uk/dialog/dialoghome.htm