Friday, August 10, 2007

Event in ABAP Report

Event in ABAP report determine process flow of a program. The events are triggered depended on the way the output is generated. They begin after event keyword and end when the next event reached.

Event keyword:
INITIALIZATION.
Occurs when report initialized.
We can use it to check user authorization or prepare output for selection screen.



AT SELECTION-SCREEN OUTPUT :
Occurs each time selection screen about to generated.
We can use it to modify selection screen, for example hide / unhide parameter.

AT SELECTION-SCREEN.
Occurs each user command in selection screen. we can use it to perform checking on user input.

START-OF-SELECTION
Occurs after the standard selection screen has been processed.,
data is read in this event.

END-OF-SELECTION
Occurs after start-of-selection.

TOP-OF-PAGE
Occurs when a new page starts.
Use it for write report header.

END-OF-PAGE
Occurs when a page ends.
Use it for write report footer.

AT LINE-SELECTION
Occurs when the user double-click on report.

AT USER-COMMAND
Occurs when the user push toolbar button.

This is program to demonstrate how to use event properly.


REPORT ZAALGAL0008
LINE-COUNT 10(1).

*http://abap-gallery.blogspot.com

TABLES: sflight.

DATA: BEGIN OF t_report OCCURS 3,
carrid LIKE sflight-carrid,
connid LIKE sflight-connid,
END OF t_report.

*begin selection screen
PARAMETERS p_datum LIKE sy-datum.
PARAMETERS p_check AS CHECKBOX.
*end selection screen

INITIALIZATION.
*begin initialization
MOVE sy-datum TO p_datum.
*end initialization

AT SELECTION-SCREEN.
*begin at selection-screen
MESSAGE I888(sabapdocu) WITH 'At selection-screen'.
IF p_check = 'X'.
MESSAGE E888(sabapdocu) WITH 'Clear checkbox'.
ENDIF.
*end at selection-screen

AT SELECTION-SCREEN OUTPUT.
*begin at selection-screen output
MESSAGE I888(sabapdocu) WITH 'At selection-screen output'.
*end at selection-screen output

START-OF-SELECTION.
*begin start-of-selection.
MESSAGE I888(sabapdocu) WITH 'start-of-selection'.
SELECT * FROM sflight.
MOVE sflight-carrid TO t_report-carrid.
MOVE sflight-connid TO t_report-connid.
APPEND t_report.
ENDSELECT.
*end start-of-selection.

END-OF-SELECTION.
*begin end-of-selection.
MESSAGE I888(sabapdocu) WITH 'end-of-selection'.
FORMAT COLOR col_normal.
DO 30 TIMES.
LOOP AT t_report.
WRITE / t_report-carrid.
WRITE t_report-connid.
ENDLOOP.
ENDDO.
*end end-of-selection.

TOP-OF-PAGE.
FORMAT COLOR col_heading.
WRITE 'This is header'.

END-OF-PAGE.
FORMAT COLOR col_total.
WRITE 'This is footer'.

AT LINE-SELECTION.
WRITE: / 'Cursor Row:', sy-curow.
WRITE: / 'Cursor Col:', sy-cucol.

14 comments:

Unknown said...

Hi! Alionzo, I really liked the way you explained the events esp. the at selection screen output and at selection screen, the diff. is very clear to me now. I think that the example could have been better, it will more clearly explain the difference.Anyways, thanks a lot and keep up the good job.

suji said...
This comment has been removed by the author.
abaper said...

dear alionzo,
i really like ur post for binary search (performance tunning), ur way to serve knowledge is quite simple and that is priceless

Anonymous said...

Hi,
The events are nicely explained here. Now events are clear in my mind.
Thanks

Anonymous said...

Nice way of explaining so much difficult thing. Really Helpful

Anonymous said...

Great site. Thank you. Keep continue.

lavanya said...

best online training institute for sap abap online training- ecorptrainings

lavanya said...

sap abap online training



we are provide best online training for sap abap

yektek training said...

thanx for this post dear swathi

Simmyjessure said...

very informative blog for ABAP Course .Thanks for Sharing This Type of knowledgeable blog

jj china restaurant
Mr Dumpling
Chili's Grill & Bar
Five Guys
Sushi Thai
bawarchi morrisville
Gulli boys
Cary Crab House

ravi said...

thanks for sharing nice blog keep posting if like read more visit it https://snowflakemasters.in/

Abhi said...

Informative blog post

Anonymous said...

hanks for sharing nice blog keep posting if like read more visit it: https://www.mylearnnest.com/best-sap-training-in-hyderabad/

digitalbadi said...

digital marketing course in hyderabad
digital marketing course in telugu

word press training in hyderabad
video editing course in hyderabad

seo training in hyderabad