You are on page 1of 5

ABAP EVENTS

ABAP is an event-driven programming language. The general flow of an ABAP program is controlled by events. These events are defined in an ABAP program using event keywords. All statements between event keywords or between an event keyword and a FO ! statement form processing blocks. For clarity of reading code" it is good programming practice to code event processing blocks in the order in which they will be triggered during e#ecution. $owever" they do not have to be coded in a se%uential order. Within an ABAP Processing Block" statements are processed se%uentially &top to bottom'.

(f a report has a selection screen defined &either e#plicitly or by default through the use of a logical database'" the ABAP processor processes the selection screen first. A programmer can e#ecute another block of code before the selection screen by using the event keyword INITIA I!ATI"N. AT SE E#TI"N-S#$EEN occurs when the user triggers a function code on the selection screen

STA$T-"%-SE E#TI"N is triggered after the selection screen is processed" and before any )*T events or any other event processing blocks. All ABAP statements that are not written as part of a processing block &after an event keyword' or a FO !+*,-FO ! block are automatically part of the .tart+of .election processing block i& they are coded above all other event keywords or subroutines. 'ET (table/ events can only be used for the basic list in an interactive report. The )*T event is triggered each time a row is read from a logical database table. The data for this record is loaded into the table work area. A )*T event keyword can only be coded once for any one table in the logical database program. The )*T 0table/ 1AT* event" if coded" occurs 2ust before the ne#t row &record' of the table specified in the )*T event is selected from the database. (t also occurs after any other )*T or )*T 1AT* events for tables lower in the hierarchy of the logical database program. )*T event processing re%uires that the logical database be specified as an attribute of the report program

T"P-"%-PA'E is used for page headers on the basic list only. TOP+OF+PA)* is triggered when the system encounters a 3 (T*" .4(P" or 51(,* statement on the basic list. TOP+OF+PA)* occurs the moment the first line of the first page is written to the screen. ,*3+PA)* also invokes the TOP+OF+PA)* event. T"P-"%-PA'E )*$IN' INE-SE E#TI"N allows a programmer to display headers for detail lists &other than the basic list'. TOP+OF+PA)* -5 (,) 1(,*+.*1*6T(O, is triggered with a 3 (T*" .4(P or 51(,* statement on a detail list. The EN)-"%-PA'E event is used for page footers. This event is triggered when the system encounters insufficient space on the current output page. The 1(,*+6O5,T statement within the *PO T statement specifies the si7e of the page area. (f a 1(,*+6O5,T is not e#plicitly coded" the *,-+OF+PA)* event block will not be processed. This function code can be assigned to a function key" push+button" or menu item.

Reporting

Page 1 of 5

The event AT INE-SE E#TI"N is triggered when the user selects a line and invokes the P(64 function code. This can occur when the user8 9 -ouble+clicks on a line 9 .ingle clicks on a line and presses F: 9 .ingle clicks on a line and presses a P(64 push+button on the list The AT *SE$-#"++AN) event is triggered when the user invokes any function code. The function code can be up to :; characters long. This function code can be assigned to a push+button" menu item" or function key on the keyboard. The AT *SE$-#"++AN) event is triggered when the user invokes any function code. The function code can be up to :; characters long. This function code can be assigned to a push+button" menu item" or function key on the keyboard. Basic list8 The basic list is displayed after all system+triggered events that are coded are e#ecuted8 9 (,(T(A1(<AT(O,. 9 AT .*1*6T(O,+.6 **,. 9 .TA T+OF+.*1*6T(O,. 9 )*T 0table/. 9 )*T 0table/ 1AT*. 9 *,-+OF+.*1*6T(O,. 9 TOP+OF+PA)*. 9 *,-+OF+PA)*. -etail list8 A detail list is displayed after a user event is e#ecuted8 9 AT 1(,*+.*1*6T(O,. or 9 AT 5.* +6O!!A,-.

emember8 Events are triggered by &,nction codes. To understand which user event gets triggered at any given time" you must know what function code triggers each user event.

ABAP automatically updates certain internal system fields. 9 S--S*B$# is an e#ample of a system field that you have used 9 To maintain the number of additional lists that are created by the user we use the system field .=+1.(,-. S-- SIN) contains an inde# that increments whenever a user event &event which occurs during the list display' is triggered. 9 .=+1.(,- is incre.ented before the event processing block is e/ec,ted. A detail list is created whenever a 3 (T*" .4(P" or 51(,* statement is encountered in a user event. 9 (f no 3 (T*" .4(P" or 51(,* statement is encountered in a user event &and therefore no detail list created'" .=+1.(,- automatically decrements back to the previous level. (n all programs" the )5( refers to &ive co.ponents8 9 Function key assignments 9 .tandard toolbar 9 Application toolbar

Reporting

Page 2 of 5

9 9

!enubar Titlebar

*ach program has a single )5( that contains the defined &,nction codes. A function code is a twenty+character &ma#imum' identifier that can be assigned to function keys" the standard toolbar" the application toolbar" and the menubar. (t is the function code that you will use to determine which function key the user pressed" which pushbutton the user clicked on" or which menu path the user chose. A )5( is made up of one or many statuses. (t is a '*I stat,s that you will set for a particular list&s'. 9 (t is important to know that a function code created on one )5( status is part of the whole )5(> therefore" it is available in all of the )5(?s statuses. Another aspect of a )5( is the titlebar. =ou can define any number of titlebars for a particular )5(.

The AT INE-SE E#TI"N event occurs when the function code 0PI#12 is invoked. 9 3hen a user do,ble-clicks on a line in the report" @P(64A is invoked. AT 1(,*+.*1*6T(O, is also triggered by8 9 A single click B F: &because the system automatically assigns @P(64A to the CF:? function key' 9 A single click B a pushbutton assigned the @P(64A function code on the )5( status

(f the user selects a line and triggers any user event &e.g. double+clicking triggers AT 1(,*+ .*1*6T(O,'" the system field S-- ISE will automatically be updated with the contents of that line on the report. The 03I)E2 state.ent is critical to interactive reporting . (t facilitates our ability to use only specific fields from the user?s selected line. A $(-* memory area e#ists for each list in an interactive report + even if an e#plicit $(-* statement is not coded for that list. The $(-* memory area becomes populated with data when the system encounters the $(-* statement followed by program fields.

The $(-* statement is" in some ways" very similar to the 3 (T* statement. 9 The @3 (T*A statement writes data from the program work area to the list. The @$(-*A statement writes data from the program work area to a special area in memory. This area in memory is called the @$(-* memory areaA. The inde# numbers in the $(-* memory area correspond to the line numbers on the report.

The EN)-"%-SE E#TI"N event is the last system event to occur &after all )*T and )*T 1AT* events'. That is" this event occurs 2ust before the basic list is displayed. =ou can use the EN)-"%-SE E#TI"N event to clear out or @initialiseA program fields. The $EA) INE ABAP reserved word is capable of reading the contents of the specified line number into the S-- ISE system field.

The INT" part of the %IE ) VA *E addition is only necessary if you want to put the value of the on+screen field into a different field. Therefore" if we utili7e a -O loop and the .=+(,-*D system field" we can loop thro,gh each o& the lines in the report with the &ollowing code8 *A- 1(,* .=+(,-*D F(*1- EA15* 0report field/ (,TO 0program field/.

Reporting

Page 3 of 5

emember to check S--S*B$#. (f you don?t" you could find yourself in an endless 1OOP. 3ith the !O-(F= 1(,* statement" you can modify the value or the format of an on+screen field. 9 +")I%- INE (line4 %IE ) VA *E (report &ield4 %$"+ (variable45 3ith this form of the !O-(F= 1(,* statement" the new value for the 0report field/ will come from the program 0variable/. This 0variable/ can also be a hard+coded literal. (n the case of the F(*1- EA15* addition" you are copying data from a program field and placing it into a report field. 9 +")I%- INE (line4 %IE ) %"$+AT (report &ield4 (&or.at option45 3ith this form of the !O-(F= 1(,* statement" the 0on+screen field?s/ format is changed based on the specified 0format option/. The following 0format options/ are available8 &F' colour 0n/ onGoff" &:' intensified onGoff" &H' inverse onGoff" &I' hotspot onGoff" &J' input onGoff" and &K' reset. 9 +")I%- #*$$ENT INE modifies the line that was last read by the *A- 1(,* statement.

The 'ET #*$S"$ %IE ) (V64 ABAP statement is used to return to a program variable 0EF/ the name of the field that the user selected on the report. There also e#ists the 'ET #*$S"$ VA *E (V74 ABAP statement. )*T 65 .O 0E:/ returns to a data variable 0E:/ the value that the user selected. EA15*

These two options can be combined to retrieve both the field name and field value with the following statement8 9 )*T 65 .O F(*1- 0EF/ EA15* 0E:/. 9 (n addition to the )*T 65 .O statement" there also e#ists a SET #*$S"$ %IE ) (on-screen &ield4 INE (84 and SET #*$S"$ (col,.n4 (line4 statement. 3ith both of the SET #*$S"$ commands" you can position the cursor on the screen" either in an input field or at particular co+ordinates on the screen. .*T 65 .O can first be used to position the cursor" and then )*T 65 .O can be used. The S#$" IST statement allows you to programmatically allow for scrolling in a list. *#tensions to the .6 O11 1(.T statement are shown above. The e#tension IN)E9 (i4 allows you to scroll in other lists. The value 0i/ corresponds to the value of .=+1.(,- when that list is created by a user action. .=+.5B 6 returns the following values8 9 ;8 when scrolling is e#ecuted 9 I8 when list area is e#hausted 9 L8 when list does not e#ist &inde#'. The system field .=+.TA6O contains the value of the column where the list begins on the screen.

(f the report is to be wider than the default FH: characters" it can be overridden by the 1(,*+.(<* parameter in the *PO T statement.

3hen a list is generated8 9 .=+6O1,O +

6urrent column number

Reporting

Page 4 of 5

.=+1(,6T + ,umber of lines from the *PO T statement 9 .=+1(,,O + 6urrent line number 9 .=+1(,.< + 1ine width from the *PO T 9 .=+PA)6T + !a#imum number of pages from the *PO T statement 9 .=+PA),O + 6urrent page number 9 .=+.6O1. + ,umber of columns in the window 9 .=+. O3. + ,umber of lines in the window 9 .=+T(T1* + eport title taken over from the te#t elements or attributes -uring interactive reporting8 9 .=+6PA)* + ,umber of current page 9 .=+656O1 + 6ursor position &column' 9 .=+65 O3 + 6ursor position &line' 9 .=+1(11( + ,umber of the selected list line 9 .=+1(.*1 + 6ontent of the selected list line 9 .=+1(.T( + (nde# of the selected list line 9 .=+1.(,+ (nde# of the displayed list level 9 .=+PF4*= + 6urrent )5( status 9 .=+.TA6O + 1ist displayed from column 9 .=+.TA O + 1ist displayed from line 9 .=+56O!! + Function code invoked by user

statement

Reporting

Page 5 of 5

You might also like