Vous êtes sur la page 1sur 43

Hi, Guest

1 Log On ᄃ
2 Join Us ᄃ
3 Getting Started ᄃ
4 Newsletters ᄃ
5 Store ᄃ
Search for:
6 Products
7 Services & Support
8 About SCN
9 Downloads ᄃ
10 Industries
11 Training & Education
12 Partnership
13 Developer Center ᄃ
14 Lines of Business
15 University Alliances ᄃ
16 Events & Webinars
17 Innovation
18 Activity ᄃ
19 Communications ᄃ
20 Actions ᄃ
21 Browse ᄃ More ᄃ
More discussions ᄃ in ABAP Development ᄃ Where is this place located?ᄃ

19 Replies Latest reply ᄃ: Jan 2, 2007 7:39 AM by shyam babu ᄃ

inShare ᄃ

EVENTS OF A REPORT ᄃ
This question is Assumed Answered.

PJᄃ
Jul 25, 2006 8:04 AMMAY ANY ONE OF U SUGGEST ME THE
SEQUENCIAL FLOW OF EVENTS FOR REPORTS ALONG WITH A SAMPLE
REPORT .

WAITING FOR REPLY


22 2712 Views
23 Topics: abap ᄃ
Average User Rating

(0 ratings)
Re: EVENTS OF A REPORT ᄃ

kishan negi ᄃ Jul 25, 2006 8:12 AM (in response to P J ᄃ)refer...
http://www.sap-img.com/abap/events- related-to-reporting.htm ᄃ
1 Alert Moderator ᄃ
2
3 Like (0 ᄃ)

Re: EVENTS OF A REPORT ᄃ



Ankur Garg ᄃ Jul 25, 2006 8:14 AM (in response to P J ᄃ)Hi Pawan,
There are Following events are trigerd when a report runs:

1.Initialization
2. at-selection-screen
3. start-of-selection
4.end-of-selection
5.top-of-page
6. end-of-page.
Regards.
Ankur Garg.

Message was edited by: Ankur Garg

4 Alert Moderator ᄃ
5
6 Like (0 ᄃ)

Re: EVENTS OF A REPORT ᄃ



Sudha Mohan ᄃ Jul 25, 2006 8:13 AM (in response to P J ᄃ)This thread should
have all the info you need:

Re: Events ᄃ

Hope this helps.

Sudha
7 Alert Moderator ᄃ
8
9 Like (0 ᄃ)

Re: EVENTS OF A REPORT ᄃ



Manoj Gupta ᄃ Jul 25, 2006 11:21 AM (in response to P J ᄃ)Events in report &
sequence of execution.

1) INITIALIZATION.
2) AT SELECTION-SCREEN.
3) START-OF-SELECTION.
4) END-OF-SELECTION.
5) TOP-OF-PAGE.
6) END-OF-PAGE.

<b>
Keyword Link </b>
http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/ᄃ

<b>Please Reward Points & Mark Helpful Answers</b>

To mark Helpful Answers ;click radio Button next to the post.

RadioButtons
<b>o</b> Helpful Answer
<b>o</b> Very helpful Answer
<b>o</b> Problem Solved.

Click any of the above button next to the post; as per the anwers

<b>To close the thread; Click Probelm solved Radio Button next to the post , which u
feel is best possible answers</b>
10 Alert Moderator ᄃ
11
12 Like (0 ᄃ)

Re: EVENTS OF A REPORT ᄃ



Sreedhar Kanchanapalli ᄃ Jul 25, 2006 8:22 AM (in response to P J ᄃ)Hi,
The order is below...

INITIALIZATION -> before the selection-screen appears


AT SELECTION-SCREEN events
START-OF-SELCTION. -> used for selecting data from database
END-OF-SELECTION. -> used for processing data
TOP-OF-PAGE. -> Fires On the first occurance of write statement
END-OF-PAGE.

For Interactive Reporting 3 more r added:

AT LINE-SELECTION. -> FOR DOUBLE CLICK OR F2 IS PRESSED


AT USER-COMMAND. -> Any application tool bar button pressed
TOP-OF-PAGE DURING LINE-SELECTION.

Sample report:

REPORT y_m_rept_po_dtls NO STANDARD PAGE HEADING


LINE-SIZE 132 LINE-COUNT 26(3) MESSAGE-ID y_msg.

----


Tables Declaration *
----

TABLES : ekko, " Purchasing doc Header data


ekpo, " Purchasing doc item data
lfa1. " Vendor Master(General Section)

----


Internal Tables Declaration *
----

DATA : BEGIN OF it_ekko OCCURS 0,

ebeln LIKE ekko-ebeln, " Purcahse Order no.


ekorg LIKE ekko-ekorg, " Purchase Organization
lifnr LIKE ekko-lifnr, " Vendor no.
waers LIKE ekko-waers, " Currency Key
name1 LIKE lfa1-name1, " Vendor's Name

END OF it_ekko.

DATA : BEGIN OF it_ekpo OCCURS 0,

ebeln LIKE ekpo-ebeln, " Purcahse Order No.


ebelp LIKE ekpo-ebelp, " Purchase Item No.
matnr LIKE ekpo-matnr, " Material no.
netwr LIKE ekpo-netwr, " Net Price of Purchase Order

END OF it_ekpo.

----

24


Variables Declaration *
----

DATA : v_grd_netwr LIKE ekpo-netwr, " For Grand totals of net price
v_sub_netwr LIKE ekpo-netwr, " For Sub totals of net price
fg_no_data, " NO DATA flag
v_ekorg LIKE ekko-ekorg. " For Purchase Organiztion validation

----

Selection Screen *
----


SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME.

SELECT-OPTIONS : s_bukrs FOR ekko-bukrs. " For Company Codes

PARAMETERS : p_ekorg LIKE ekko-ekorg. " For Purchase Organization

SELECTION-SCREEN END OF BLOCK blk1.

----


Initialization *
----

INITIALIZATION.

PERFORM initialize. " Initializing values

----


at selection screen *
----

AT SELECTION-SCREEN.

PERFORM sel_scr_vald. " Selection Screen validations

----


start of selection *
----

START-OF-SELECTION.
PERFORM retrieve_data. " Select the data from database

----


end of selection *
----

END-OF-SELECTION.

PERFORM list_data. " List the selected data

----


top of page *
----

TOP-OF-PAGE.

PERFORM disp_header. " Page Header


PERFORM disp_col_header. " Column Header
PERFORM draw_vline. " Generates Vertical Lines

----


end of page *
----

END-OF-PAGE.

PERFORM disp_footer. " Page Footer


----


SUB ROUTINEES *
----

&----


*& Form disp_header
&----


text
----


--> p1 text
<-- p2 text
----


FORM disp_header.

WRITE : /40 'Intelligroup Asia Pvt. Ltd.'(001),


/47 'Hyderabad'(002).

SKIP 1.

WRITE : /43 'Purchase Orders List'(012) COLOR 5 INVERSE ON.

ENDFORM. " disp_header

&----


*& Form disp_footer
&----


text
----

--> p1 text
<-- p2 text
----


FORM disp_footer.

IF fg_no_data = 'X'.

EXIT.

ELSE.

SKIP 1.

WRITE : /89 'PAGE NO. : '(003),


(4) sy-pagno COLOR 2 INTENSIFIED OFF.

ENDIF.

ENDFORM. " disp_footer

&----


*& Form initialize
&----


text
----


--> p1 text
<-- p2 text
----


FORM initialize.

p_ekorg = '1000'.

s_bukrs-low = '1000'.
APPEND s_bukrs.
ENDFORM. " initialize

&----


*& Form sel_scr_vald
&----


text
----


--> p1 text
<-- p2 text
----


FORM sel_scr_vald.

*This Select statement validates the supplied Purchase Org. Value.

SELECT SINGLE ekorg


INTO v_ekorg
FROM ekko
WHERE ekorg = p_ekorg.

IF sy-subrc <> 0.

MESSAGE e000 WITH p_ekorg 'Purchase Org.does not exists'.

ENDIF.

*This Select statement validates the supplied Company Code Values.

SELECT SINGLE bukrs


INTO s_bukrs-low
FROM ekko
WHERE bukrs IN s_bukrs.

IF sy-subrc <> 0.

MESSAGE e000 WITH s_bukrs 'Company Code does not exists'.


ENDIF.

ENDFORM. " sel_scr_vald

&----


*& Form retrieve_data
&----


text
----


--> p1 text
<-- p2 text
----


FORM retrieve_data.

*This select statement retrieves the P.O header data based on


*Company Code and Purchase Organization supplied

SELECT v1~ebeln " Purcahse Order no


v1~ekorg " Purchase Organization
v1~lifnr " Vendor no
v1~waers " Currency Key
v2~name1 " Vendor's Name
INTO TABLE it_ekko
FROM ekko as v1 join
lfa1 as v2 on
v1lifnr = v2lifnr
WHERE ekorg = p_ekorg
AND bukrs IN s_bukrs
AND bsart = 'NB'
AND loekz = space.

IF sy-subrc <> 0.

fg_no_data = 'X'.
MESSAGE i000 WITH 'No Data for this Selection Criteria'.
STOP.
ENDIF.

*The following select statement retrieves the item data


*for each P.O retrieved

IF NOT it_ekko[] IS INITIAL.

SELECT ebeln " P.O No.


ebelp " Itm No.
matnr " Mat No.
netwr " Net Pr.
INTO TABLE it_ekpo
FROM ekpo FOR ALL ENTRIES IN it_ekko
WHERE ebeln = it_ekko-ebeln.

ENDIF.

ENDFORM. " retrieve_data

&----


*& Form list_data
&----


text
----


--> p1 text
<-- p2 text
----


FORM list_data.

SORT it_ekko BY ebeln.


SORT it_ekpo BY ebeln ebelp.

LOOP AT it_ekpo.

AT NEW ebeln.
READ TABLE it_ekko WITH KEY ebeln = it_ekpo-ebeln.

IF sy-subrc = 0.

WRITE : /3 it_ekko-ebeln COLOR 2,


15 it_ekko-ekorg COLOR 2,
21 it_ekko-lifnr COLOR 2,
33 it_ekko-waers COLOR 2,
83 it_ekko-name1+0(20) COLOR 2.

ENDIF.

PERFORM draw_vline.

ENDAT.

WRITE : /42 it_ekpo-ebelp COLOR 1 INTENSIFIED OFF,


47 it_ekpo-matnr COLOR 5 INTENSIFIED OFF,
67 it_ekpo-netwr LEFT-JUSTIFIED COLOR 3 INTENSIFIED OFF.

PERFORM draw_vline.

v_sub_netwr = v_sub_netwr + it_ekpo-netwr.


v_grd_netwr = v_grd_netwr + it_ekpo-netwr.

AT END OF ebeln.

ULINE AT /47(35).
PERFORM draw_vline.
WRITE : /53 'Doc.Value : '(010) COLOR 3 INVERSE ON,
v_sub_netwr LEFT-JUSTIFIED COLOR 3.
CLEAR v_sub_netwr.
PERFORM draw_vline.
ULINE AT /2(104).

ENDAT.

AT LAST.

WRITE : /52 'Grand Value :'(011) COLOR 7 INVERSE ON,


v_grd_netwr LEFT-JUSTIFIED COLOR 7 INTENSIFIED OFF.
CLEAR v_grd_netwr.

ENDAT.
ENDLOOP.

ENDFORM. " list_data

&----


*& Form disp_col_header
&----


text
----


--> p1 text
<-- p2 text
----


FORM disp_col_header.

SKIP 1.

ULINE AT /2(104).

WRITE : /3(11) 'P.O No.'(003) COLOR COL_HEADING,


15(6) 'P.Org'(004) COLOR COL_HEADING,
21(12) 'Vendor No'(005) COLOR COL_HEADING,
33(8)'Curr.Key'(006) COLOR COL_HEADING,
42(4) 'Item No'(007) COLOR COL_HEADING,
47(19) 'Material No.'(008) COLOR COL_HEADING,
67(15) 'Net Price'(009) COLOR COL_HEADING,
83(22) 'Vendor Name'(013) COLOR COL_HEADING.

PERFORM draw_vline.

ULINE AT /2(104).

ENDFORM. " disp_col_header

&----


*& Form draw_vline
&----


text
----


--> p1 text
<-- p2 text
----


FORM draw_vline.

WRITE : 2 sy-vline,
14 sy-vline,
20 sy-vline,
32 sy-vline,
41 sy-vline,
46 sy-vline,
66 sy-vline,
82 sy-vline,
105 sy-vline .

ENDFORM. " draw_vline

Sreedhar
1 Alert Moderator ᄃ
2
3 Like (0 ᄃ)

Re: EVENTS OF A REPORT ᄃ



shyam babu ᄃ Dec 29, 2006 4:52 AM (in response to Sreedhar Kanchanapalli
ᄃ)Report:display the data from data base table......!

Events in Reports::::
1)initialization:-This event will give default values in selection screen.
2)at selection screen:-This event will do the validation checks.
3)start-of-selection:This event will retrieve data from the data base table and put into
internal table.
4)end-of-selection:-This event will populate out put list.
5)top-of-page:-will maintain the header in the out put list.
6)end-of-page:- maintain the footer in the bottom of page..
1 Alert Moderator ᄃ
2
3 Like (0 ᄃ)

Re: EVENTS OF A REPORT ᄃ



shyam babu ᄃ Dec 29, 2006 5:05 AM (in response to shyam babu ᄃ)may i know
differance between initialization and at selection-------????????. already i
mentioned above if any mistake -


!

Thanx & Regards.....


shyam.k
1 Alert Moderator ᄃ
2
3 Like (0 ᄃ)

Re: EVENTS OF A REPORT ᄃ



shyam babu ᄃ Jan 2, 2007 7:39 AM (in response to shyam babu ᄃ)what is
difference between clasical Reporting and interactive reporting??

1.<b>Classical Reporting</b>:-In Classical Reporting, based up on the selection screen


user can have only one out put List.

<u><b>Events in clascial Reporting:</b></u>

a.Initialization
b.At selection-screen
c.Start-of-selection
d.End-of-selection.
e.Top-of-page
f. End-of-page.

<u>2.<b>Interactive Reporting</b>:</u> In interactive reporting end user can navigate


up to 1 Basic List and 20 Secondary Lists.
<b>Events in Interactive Reporting:</b>
a.Initialization
b.At selection-screen
c.Start-of-selection
d.End-of-selection
e.Top-of-page
f.End-of-page
g.At-line selection
h.At-user command.
Regards
1 Alert Moderator ᄃ
2
3 Like (0 ᄃ)

Re: EVENTS OF A REPORT ᄃ



Narasimha Rao Bandla ᄃ Jul 25, 2006 8:14 AM (in response to P J ᄃ)Hi,

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.

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

cheers,

Simha.
4 Alert Moderator ᄃ
5
6 Like (0 ᄃ)

Re: EVENTS OF A REPORT ᄃ



sumit kumar ᄃ Jul 25, 2006 8:15 AM (in response to P J ᄃ)Hi,

These are th flow for reports.

• INITIALIZATION
• AT SELECTION-SCREEN
• GET (pay attention to the order of the nodes of the logical database. The event GET
LATE has to be used as final statement.)
• END-OF-SELECTION
• AT events
• TOP-OF-PAGE
• END-OF-PAGE

Regards,
Sumit.
7 Alert Moderator ᄃ
8
9 Like (0 ᄃ)

Re: EVENTS OF A REPORT ᄃ



Abhishek Purwar ᄃ Jul 25, 2006 8:24 AM (in response to P J ᄃ)Events.........

1) INITIALIZATION.
2) AT SELECTION-SCREEN.
3) START-OF-SELECTION.
4) END-OF-SELECTION.
5) TOP-OF-PAGE.
6) END-OF-PAGE.
10 Alert Moderator ᄃ
11
12 Like (0 ᄃ)

Re: EVENTS OF A REPORT ᄃ



Harini Somaysula ᄃ Jul 25, 2006 8:26 AM (in response to P J ᄃ)Hi pawan,

The events are trigerred in this way...


1.Initialization
2. at-selection-screen
3. start-of-selection
4.end-of-selection
5.top-of-page
6. end-of-page.

Example for the report...

&----


*& Report ZCLASSICAL_REP *
*& *
&----


*& *
*& *
&----

REPORT ZCLASSICAL_REP1 MESSAGE-ID ZHARINI LINE-COUNT 15(2).

TABLES: MARA.

SELECT-OPTIONS: SMATNR FOR MARA-MATNR.

************************************************************************
INITIALIZATION.
************************************************************************

SMATNR-LOW = '500'.
SMATNR-HIGH = '1200'.
SMATNR-OPTION = 'BT'.
SMATNR-SIGN = 'I'.

APPEND SMATNR.

************************************************************************
AT SELECTION-SCREEN.
************************************************************************
IF SMATNR EQ ''.
MESSAGE I001.

ENDIF.

************************************************************************
START-OF-SELECTION.
************************************************************************

SELECT * FROM MARA WHERE MATNR IN SMATNR.

WRITE:/3 MARA-MATNR.

ENDSELECT.

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

TOP-OF-PAGE.
************************************************************************

WRITE:/3 'MATERIAL NO'.


ULINE.

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

END-OF-PAGE.
************************************************************************

WRITE:/ SY-PAGNO.

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

END-OF-SELECTION.
************************************************************************

WRITE:/35 ' LANCO GLOBAL SYSTEMS LTD.,'.

Reward points for the same.

Regards,
Harini
13 Alert Moderator ᄃ
14
15 Like (0 ᄃ)
25
Re: EVENTS OF A REPORT ᄃ

Seema Chand ᄃ Jul 25, 2006 8:34 AM (in response to P J ᄃ)Hi Pawan,
This is the flow-
1. Initialization
2. Selection-screen
3. at-selection-screen output
4. at-selection-screen
5. top-of-page
6. start-of-selection
7. end-of-page.
8. end-of-selection

Hope this helps u.


Regards,
Seema.
1 Alert Moderator ᄃ
2
3 Like (0 ᄃ)

Re: EVENTS OF A REPORT ᄃ



Tanuja Sarraju ᄃ Jul 25, 2006 8:58 AM (in response to P J ᄃ)Hi Pawan,

<b>The following events occur when you run a typical executable program with a logical
database:</b>

INITIALIZATION: Before the standard selection screen is displayed

AT SELECTION-SCREEN:
After user input on a selection screen has been processed, but while the selection screen
is still active

START-OF-SELECTION:
After the standard selection screen has been processed, before data is read from the
logical database

GET <table>: After the logical database has read an entry from the node <table>

GET <table> LATE:


After all of the nodes of the logical database have been
processed that are below <table> in the database hierarchy

END-OF-SELECTION:
After all data has been read by the logical database

<b>List processor events:</b>

TOP-OF-PAGE: In list processing when a new page starts


END-OF-PAGE: In list processing when a page ends
AT LINE-SELECTION: When the user triggers the predefined function code PICK
AT PF<nn>: When the user triggers the predefined function code PF<nn>
AT USER-COMMAND: When the user triggers a function code defined in the program

Reward points if you find the answer helpful and close this thread.

Regards,
Tanuja.
4 Alert Moderator ᄃ
5
6 Like (0 ᄃ)

Re: EVENTS OF A REPORT ᄃ



Sreenivasulu Ponnadi ᄃ Jul 25, 2006 10:43 AM (in response to P J ᄃ)Hai
Pavan

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
&----

26

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
Sreeni
1 Alert Moderator ᄃ
2
3 Like (0 ᄃ)

Re: EVENTS OF A REPORT ᄃ



Rahul Kavuri ᄃ Jul 25, 2006 10:46 AM (in response to P J ᄃ)Events associated
with classical report are as follows and each one will be discussed in detail.

• INITIALIZATION
• AT SELECTION-SCREEN
• AT SELECTION-SCREEN ON <field>
• START-OF-SELECTION
• TOP-OF-PAGE
• END-OF-PAGE
• END-OF-SELECTION

In this case first three events are associated with selection screen. Rest of the events are
associated with your list.

• INITIALIZATION

in many cases you need to calculate the value and then put it in selection criteria. For
example, say, you are accepting date from user and you need to fill in the default value
for lower range as sy-datum – 30 days and sy-datum for higher range. In this case you are
calculating lower range and then filling the criteria. This can be done in
INITIALIZATION event. Piece of code to do the above task would look like the
following:
Tables: Sflight.
Select-options: fldate1 for sflight-fldate.
INITIALIZATION.
Data: date1 like SY-DATUM.
Date1 = sy-datum – 30.
Fldate1-low = date1.
Fldate1-high = sy-datum.
Append fldate1.
Here appending is required because fldate1 is int’ table
This event is triggered when you execute your program for the first time i.e., before
selection screen is displayed.

• AT SELECTION-SCREEN

When user enters the values in the fields of selection screen and clicks on execute button,
this event gets triggered. This event is basically for checking the values entered by the
user for the fields of the selection screen i.e., data validity checking. This event is for
entire selection screen. For example:

You are accepting carrid, connid, fldate from user and you don’t want to proceed if user
enters no value for carrid and fldate. Using AT SELECTION-SCREEN can do this.

Select-options: carrid1 for sflight-carrid,


Connid1 for sflight-connid,
F1date1 for sflight-f1date.

AT SELECTION-SCREEN.
If carrid1-low ne ‘ ’ and fldate1-low = ‘ ’.
Error message.
Endif.

In this case, if both the fields are entered blank, then the user gets error message.
Basically, this event is for many fields on selection screen. Usually, it is for the fields
which are logically related.

• AT SELECTION-SCREEN ON <field>

When you want to check for specific value of a field. For example, carrid should be in the
range of ‘LH’ and ‘SQ’. This can be done in this event. Basically, this event is for
checking individual fields. You can have many AT selection-screen events in your
program (i.e., for each field specified in the Select-Options).

Select-Options carrid1 for sflight-carrid.


AT SELECTION-SCREEN.
If carrid1-low ne ‘LH’ and carrid1-high ne ‘SQ’.
Error message.
Endif.
Here the system will not proceed on entering wrong values.

• START-OF-SELECTION

This is the first event for your list. Once all the events are triggered for selection screen,
the data is retrieved from database. Data declaration, select statements are done in this
event. Consider the following example:

START-OF-SELECTION.
Data: mtype i.
Tables: sflight.
Select * from sflight where carrid = ‘LH’.
Write: / sflight-carrid,sflight-connid.
Endselect.

• TOP-OF-PAGE

This event is triggered with first WRITE statement or whenever new page is triggered.
Advantage of using this event is that, whatever you write under this event, is applicable to
all the pages. If you don’t have any write statement before TOP-OF-PAGE or in START-
OF-SELECTION, this event is not triggered at all. For example, if you want the name of
company and column headers for all the pages, it can be written in this event.

TOP-OF-PAGE
Write: / ‘INTELLIGROUP ASIA PVT. LTD.’
Write : / 10 ‘carrid’, 20 ‘connid’, 30 ‘fldate’.

• END-OF-PAGE

This event is triggered at the end of page.

End-of-page.
Write : / ‘page number’, sy-pagno.

In this case page number will be written on every page.

<b>Award points if sounf helpful</b>


4 Alert Moderator ᄃ
5
6 Like (0 ᄃ)

Re: EVENTS OF A REPORT ᄃ



k c ᄃ Jul 25, 2006 11:13 AM (in response to P J ᄃ)hi,

order of EVENTS IN CLASSICAL REPORTS


-


1.INITIALIZATION.
2.AT SELECTION-SCREEN.
3.TOP-OF-PAGE.
4.START-OF-SELECTION.
5.END-OF-SELECTION.
6.END-OF-PAGE.
-


even you give in different order in ABAP editor,
they will execute in the same order,try for it,

best of luck,
regards,
kcc
7 Alert Moderator ᄃ
8
9 Like (0 ᄃ)

Re: EVENTS OF A REPORT ᄃ



Manju Nagendra beedam ᄃ Nov 29, 2006 10:05 AM (in response to P J ᄃ)Hi,

hi,
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

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

Cheers,
Manju
10 Alert Moderator ᄃ
11
12 Like (0 ᄃ)

Re: EVENTS OF A REPORT ᄃ



deepak rathore ᄃ Dec 29, 2006 3:35 PM (in response to P J ᄃ)hi

seq of event in
a)classical report
1) INITIALIZATION.
2) AT SELECTION-SCREEN.
3) START-OF-SELECTION.
4) END-OF-SELECTION.
5) TOP-OF-PAGE.
6) END-OF-PAGE.

b) in interactive report

1) INITIALIZATION.
2) AT SELECTION-SCREEN.
3) START-OF-SELECTION.
4)AT LINE-SELECTION
5) END-OF-SELECTION.
5) TOP-OF-PAGE DURING LINE-SELECTION
6) END-OF-PAGE.
7)AT PFN
8) AT USER_COMMAND.

REGARD
DEEPAK
13 Alert Moderator ᄃ
14
15 Like (0 ᄃ)

Go to original post ᄃ

FOllowing are the events

INITIALIZATION: ( Executed only once before the any other event).

SELECTION-SCREEN AT OUTPUT: (PBO of report programs selection screens)


Executed before the screen output.

AT SELECTION-SCREEN: PAI of the selection screen, processed only when there is any
user action like click of a button etc.

START-OF-SELECTION: Program processing.

AT LINE SELECTION: Generally process when an event occurs on the reports output
LIST.

TOP-OF-PAGE: event that happens for evry new page of LIST OUTPUT.

(Result of WRITE statements create a LIST).


IF you dont write any event section in your program everything goes in to START-OF-
SELECTION Event, this is the default event you need not put this in the program.

END-OF-SELECTION is only useful for Logical database reports. Normal reports does
not have any affect for this event.
Regards,
Sesh

Message was edited by:


Seshatalpasai Madala
1 Alert Moderator ᄃ
2
3 Like (0 ᄃ)

Helpful AnswerRe: Hi About Events of a report ᄃ



Priyanka Neelam ᄃ Jun 7, 2007 11:22 AM (in response to uday kumar ᄃ)Hi,

The program then follows this sequence of steps:

It triggers the initialization event, causing the code belonging to initialization to be


executed. If you have not coded an initialization event in your program, the driver
program skips this step.
It shows the selection screen for your program. (A selection screen is the screen that
contains the input fields for your parameter statements.) If your program doesn't have a
selection screen, it skips this step.
It triggers the start-of-selection event, causing the code belonging to that event to be
executed. If you have not coded a start-of-selection event in your program, it skips this
step.
It triggers the end-of-selection event in your program, executing all of the code belonging
to it. If you haven't coded an end-of-selection, it skips this step.
It shows the output list to the user.
The order of execution for events is determined by the driver program, not by your
program. Therefore, you can code the events in any order and the execution order will
still be the same. The order of events in your program doesn't matter; they will always be
triggered in the same sequence by the driver program.

There will be different types of events in ABAP.


So be clear what events you need ind etail.

Some related to Classical reports, some to Interactive reports and some related to Module
Pool Programming(Dialog)

Events in Dialog Program


PBO - Process Before Output
PAI - Process After Input
POH - Process on Help
POV - Process on Valure Request.

Events in ABAP Programming


INITIALIZATION
AT SELECTION-SCREEN OUTPUT
AT SELECTION-SCREEN
START-OF–SELECTION.
TOP OF PAGE
END OF PAGE
END-OF-SELECTION.

Control Break events related to Internal Tables:


AT NEW FIELD
AT END OF FIELD
AT FIRST
AT LAST

Events in Interactive Report


AT USER-COMMAND.
AT LINE-SELECTION
AT PF-FUNCTION KEY

http://www.sap-img.com/abap/events-related-to-reporting.htm ᄃ

Regards,
Priyanka.
4 Alert Moderator ᄃ
5
6 Like (0 ᄃ)

Re: Hi About Events of a report ᄃ



Sudheer Junnuthula ᄃ Jun 7, 2007 11:31 AM (in response to uday kumar ᄃ)hi,
events of reprt are

initialization. "provide default values to screen fields


at selection-screen output. " change screen fields
at selection-screen. " to perform validations
start-of-selection. " genarates basic list
end-of-selection.

top-of-page. "thses events provide header and footer


end-of-page.

get. "triggered when program reads data from logical database


getlate.

for interactive reports.

at line-selection.
at user-command.

http://www.sap-img.com/abap/events-related-to-reporting.htm ᄃ
http://wiki.ittoolbox.com/index.php/FAQ:How_many_types_of_reports_are_there_in_AB
AP_and_what_is_the_difference_between_them%3F ᄃ

Selection Screen Processing


Selection screens are special screens that are defined with the help of ABAP statements.
As programmers do not have access to the flow logic of selection screens, they cannot
define dialog modules for selection screens. The ABAP runtime environment fully
controls the processing flow of selection screens. To allow programmers to modify the
selection screen before it is called (PBO) and react to user actions on the selection screen
(PAI), the ABAP runtime environment generates a number of special selection screen
events before the selection screen is displayed and after the user has executed actions on
the selection screen. Programmers can
define event blocks in the program to react to these events.
The basic form of the selection screen events is the AT SELECTION-SCREEN
event. This event occurs after the runtime environment has passed all input data
from the selection screen to the ABAP program. The other selection screen
events allow programmers to modify the selection screen before it is sent and
specifically check user input.
Selection screen events occur both during standard and user-defined selection
screen processing. The SY-DYNNR system field contains the number of the active
selection screen and helps you to determine which selection screen is currently
being processed in the event blocks.

Overview of Selection Screen Events


For example, a standard selection screen is defined as follows in the declaration part of an
executable program:

The

following graphic shows the possible selection screen events and their
chronological sequence between the
INITIALIZATION and the START-OF-SELECTION event. If user-defined selection
screens are called, the event sequence is imbedded accordingly in the current program
flow.
Selection
screen
processing
starts after
the
INITIALIZATION event with AT SELECTION SCREEN OUTPUT. The selection screen
is then sent to the screen. User actions on the selection screen result in other
events that are either used for field or possible entries help, or that trigger PAI
processing of the selection screen. During PAI processing,
error messages in the relevant event blocks allow users to return to the selection screen.
Only if the AT SELECTION-SCREEN event is exited properly, that is not through an
error message, are the other events of the executable program triggered, starting with
START-OF-SELECTION.
Choosing multiple selection calls the relevant dialog box. Similarly, events are
triggered during its PAI processing.

Basic FormPBO of the Selection ScreenSingle Field ProcessingBlock


ProcessingProcessing Radio ButtonsProcessing Multiple SelectionsDefining Field
HelpDefining Input Help

ABAP Flow of Events :

1. Load Of Program : When a program is called using SUBMIT or using a transaction


code, then – at every call – a new internal session is opened and the event block is
executed once at every call. You can initialize global data objects of the program here.
The event block must be executed completely; otherwise, a runtime error will
occur.Therefore, no statements are allowed to be executed that leave the event block
without returning.At the first call of an external Procedure (sub-program or function
module), the framework program of the called procedure is loaded into the internal
session of the caller, thus triggering the event LOAD-OF-PROGRAM.

2. Initialization : This event keyword defines an event block whose event is triggered
by the ABAP runtime environment during the flow of an executable program, directly
after LOAD-OF-PROGRAMand before the selection screen processing of any existing
standard selection screen. This gives you the one-time opportunity to initialize the
input fields of the selection screen.

3. At Selection Screen : The event keyword AT SELECTION-SCREEN provides you


with several possibilities to carry out processing blocks while the system is processing
the selection screen. To react on different events, that can occur when the selection
screen is processed, the keyword AT SELECTION-SCREEN has various options. All
the Validation Done on Selection Screen is done through this event. The AT
SELECTION SCREEN event is triggered after the user enters value on the selection
screen and presses enter or Executes it.

4. Start Of Selection : Start Of Selection is triggered after the selection screen is


processed. 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, which is inserted before
any START-OF-SELECTION event blocks.If the program is linked to a logical
database, preparatory tasks can be performed at START-OF-SELECTION before the
logical database imports the data.

5. End Of Selection : END-OF-SELECTION is the last system event to be processed


during the runtime of a report program. It occurs after all logical database records have
been read, and before any user-invoked events. END-OF-SELECTION occurs only
once.

6. Top Of Page : TOP-OF-PAGE is used for page headers on the basic list only. TOP-
OF-PAGE is triggered when the system encounters a WRITE, SKIP, or ULINE
statement on the basic list. TOP-OF-PAGE occurs the moment the first line of the first
page is written to the screen. NEW-PAGE also invokes the TOP-OF-PAGE event. This
occurs when a new page is started – that is, immediately before the first line in a new
page is to be output.

7. End Of Page : The END-OF-PAGE event is used for page footers. This event is
triggered when the system encounters insufficient space on the current output page.
The LINE-COUNT statement within the REPORT statement specifies the size of the
page area. If a LINE-COUNT is not explicitly coded, the END-OF-PAGE event block
will not be processed. So the LINE-COUNT is defined like this if the page contains 50
lines and 3 lines are for the footer then it should be written as LINE-COUNT 50(3).

8 . 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
scren cursor is on a list line and you select a function using the function code PICK.
Through the definition of this event block, the standard list status is automatically
enhanced in such a way that the function code F2 and, with it, the double-click mouse
function is linked up to the function code PICK.

9. 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.

10. At PFn : This statemet 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 PFn. Here n stands for a number
between 01 and 24. In the= standard list status, these function codes are assigned to the
function keys of the input device.

Vous aimerez peut-être aussi