Professional Documents
Culture Documents
Events
The ABAP is an event driven programming language with events are triggered in the particular
order by driver program.
An event start with the event name and ends with the next event beginning.
INITIALIZATION
*Process block
AT SELECTION - SCREEN…….
*Process block
*Process block
NOTE: The Default event for each executable program is START -OF- SELECTION.
Classical Reports
Classical reports are the simple repots to extract the data from the data
and display the process the database table or data base view, process the extracted
data and display the processed final data using the WRITE statements within the loop
statements.
Following are the different types of events of classical reports which are triggered in the
same order.
1. LOAD-OF-PROGRAM
2. INITIALIZATION
B) AT-SELECTION-SCREEN ON VALUE
D) AT SELECTION SCREEEN ON
E) AT-SELECTION-SCREEN
4. START-OF-SELECTION
5. END-OF-SELECTION
6. TOP-OF-PAGE
7. END-OF-PAGE
1. LOAD-OF-PROGRAM:
LOAD-OF-PROGRAM
2. INITIALIZATION:
This event is triggered before the selection screen or input screen is displayed.
2, it can also be used to pass the default values to the selection fields or input fields and data
variables.
INITIALIZATION
*Default values
ENDFORM
3. AT-SELECTION-SCREEN Event:
They are triggered while performing any action in the selection screen.
They can also be triggered after input value or data is provided in the selection screen.
The AT -SELECTION- SCREEN events are used to format the selection-screen dynamically
and validate or check the input data.
a) AT SELECTION-SCREEN OUTPUT
b) AT SELECTION-SCREEN ON HELP-REQUEST FOR
c) AT SELECTION-SCREEN ON VALUE HELP-REQUEST FOR
d) AT SELECTION-SCREEN ON
It can also be triggered while performing any action in the selection screen.
SYNTAX:
AT SELECTION-SCREEN OUTPUT
MODIFY SCREEN.
ENDIF
ENDLOOP
ENDFORM
This structure is field with all the attributes or the properties of all selection field or the input
field in the selection screen.
It behaves like an internal table since it holds each selection field properties at run-time.
FIELD DESCRIPTION
1->Mandatory
0-> Optional
1->output
1->appear
2-> hide.
NOTE:
SYNTAX: :
AT-SELECTION-SCREEN-ONVALUE-REQUEST FOR<S_FIELD-LOW/S_FIELD-HIGH/P_FIELD>.
PERFORM <F_SEARCH_HELP>.
FORM <F_SEARCH_HELP>.
EXPORTING
: RETURN
SELECT <F1>,
<F2>,
EXPORTING
: ret_field = <s_field-low/…………..>.
: value_org = ‘s’.
TABLES
ENDFORM.
This event is triggered when the function key F1 (or) help icon is pressed. It is used to provide
The transaction code ‘SE61’ (or) ‘SO72’ is used to maintain the help documentation as per
The specification.
SYNTAX: :
PERFORM <F_HELP_DOCU>…..
FORM <F_HELP_DOC>.
(OR)
ENDFORM.
AT-SELECTION-SCREEN-ON:
This event is triggered after the input values provided in the selection screen .
SYNTAX: :
AT-SELECTION-SCREEN ON <S_FIELD/P_FIELD>.
PERFORM <F_VALIDATE_FIELD>;
FORM <F_VALIDATE_FIELD>.
SELECT……………
Into ………………..
(or)
<f2> = p_field.
IF SY-SUBRC NE 0.
*Give message*
ENDIF.
START-OF-SELECTION:
It is the default event and mandatory event to execute any executable program (or) report.
This event is triggered after all the selection screen events are processed.
SYNTAX : :
START-OF-SELECTION.
PERFORM <F_GET_DATA>.
FORM<F_GET_DATA>.
SELECT <f1>
<f2>
From <dbtab>
<condition2>……..
NOTE: If no one event is used in the executable program, the entire program will be triggered
END-OF-SELECTION:
SYNTAX: :
END-OF-SELECTION.
PERFORM<F_PROCESS_DATA>.
FORM<F_PROCESS_DATA>.
*read table*
IF SY-SUBRC = 0.
ENDLOOP.
TOP-OF-PAGE:
This event is triggered with the first ULINE (or) WRITE statement in the program.
SYNTAX: :
ULINE/WRITE………..
TOP-OF-PAGE.
PERFORM<F_POP_HEADER>.
FORM<F_POP_HEADER>.
ENDFORM.
END-OF-PAGE:
This event is triggered after the current page is ended before the new page is
displayed.
The report addition LINE COUNT must be specified to trigger this event.
NOTE:
This event can also be triggered with an ABAP statement ‘NEW PAGE’.
The output list should have more than 67 records (or) lines to trigger this event.
SYNTAX: :
* triggers after the current page is ended before the new page is displayed*
END-OF-PAGE.
PERFORM<F_FOOTER_DATA>.
FORM<F_FOOTER_DATA>.
WRITE’<footer data>’.
INCLUDE<ZREP-NAME>-TOP.
INCLUDE<ZREP-NAME>-SEL.
INCLUDE<ZREP-NAME>-FORMS.
INITIALIZATION.
PERFORM<F_CLASS_REFRESH>.
AT SELECTION-SCREEN OUTPUT.
PERFORM<F_FORMAL_SCREEN>.
AT SELECTION-SCREEN ON <S_FIELD/P_FIELD>.
PERFORM<F_VALIDATE_INPUT>.
START-OF-SELECTION.
END-OF-SELECTION.
PERFORM<F_PROCESS_DATA>.
NOTE:
1. Up to END-OF-SELECTION events are common for any type of report (or) migration.
2. Display data in the first basic list and TOP-OF-PAGE and END-OF-PAGE events are
TOP-OF-PAGE.
PERFORM<F_DISPLAY_DATA>.
END-OF-PAGE.
PERFORM<F_DISPLAY_FOOTER>.
INNER JOINS:
It is used to extract the data from the multiple tables by joining them.
NOTE:
<a~f2>
<b~g1>
<b~g>
<b~g1> in <s-g2>
Here ‘<a>’ is an alias name for the first database table <dbtab1>.
NOTE: The database name can also be used instead of alias name.
<dbtab1~f2>
<dbtab2~g1>
<dbtab2~g2>
This statement is used to extract the data from the database table based on the entries of the
base internal table. It is advisable instead of joining more than two tables.
2. The SELECT statement extracts all the data without considering ‘FOR ALL ENTRIES’.
SYNTAX: :
SELECT <h1>
<h2>
From <dbtab3>
<f2> IN <s-f2>………..
ENDIF.
NOTE: The ‘FOR ALL ENTRIES’ statements can also be used by inner join.
SYNTAX:
SELECT <a~f1>
<a~f2>
<b~g1>
<b~g1> IN <s_g2>
ENDIF.
NOTE:
Use ‘READ TABLE’ statement within the base internal table loop.
SYNTAX:
(OR)
IF SY-SUBRC = 0.
ENDLOOP.
*Display data - - - - -- *
WRITE: / <gs_final-f1>,
CLEAR : <gs_final>.
ENDLOOP.
DESCRIBE TABLE:
SYNTAX:
NOTE:
The statement field sy-dbcnt holds the total no of extracted records from the
database tables (or) database views.
INTERACTIVE REPORTS
They are used to provide the detailed drill down list based on the current output list.
Up to 20 Secondary (or) drill down lists can only be provided including basic list, the total
no. of lists are 21.
Note:-
The program goes to runtime error (or) short dump in case of more than 20 Secondary
lists are provided.
The system field SY-LSIND holds the index of next drill down list.
1. AT LINE-SELECTION.
2. TOP-OF-PAGE-DURING LINE-SELECTION.
3. AT USER-COMMAND.
4. AT PF.
AT LINE-SELECTION :-
This event is triggered when the record (or) list line is selected (click (or) double click)
in the current list.
The system field SY-LSIND holds the index of the next drill down list of the current list.
SYNTAX: - :
WRITE: _ _ _ _ _ _ _ _ .
CASE SY-LSIND.
WHEN '1'.
WRITE: _ _ _ _ _ _ _ _ _ _ .
ENDLOOP.
HIDE STATEMENT :-
The statement is used to hide the selected field / row value which can be passed to the
corresponding drill down list to filter the unwanted records.
SYNTAX :- :
:
BY MR. BABU (OASIS TECHNOLOGIES)
BY MR. BABU (OASIS TECHNOLOGIES)
AT LINE-SELECTION.
CASE SY-LSIND.
WHEN '1'.
PERFORM <f_display_first>.
FORM <f_display_first>.
ENDLOOP.
This event is triggered with First "WRITE" (or) "Value" statement of the detailed
lists (or) drill down list.
It is used to provide the column headings for the drill down list (or) secondary
list.
SYNTAX :-
WRITE / ULINE.
* Triggers when the record (or) field is selected in the current list.
AT LINE-SELECTION.
CASE SY-LSIND.
WHEN '1'.
WHEN '1'.
ENDFORM.
AT PF :-
This event is triggered when the menu item (function key) is pressed.
This event is used to provide the additional functionality based of the selected menu
item.
The system field SY-PFKEY holds the selected function key of the menu.
SYNTAX :-
AT PF.
CASE SY-PFKEY
* Additional functionality
WHEN '<CRT>'.
WHEN '<DEL>'.
ENDCASE.
SET PF-STATEMENT :-
SYNTAX :-
Here <zmenu_status> is the custom menu status name '(Should be mentioned in uppet case)'.
- - - - EXCLUDING addition :-
NOTE :-
AT USER COMMAND :-
This event is used to provide the additional functionality based on the selected push
button.
The system field SY-UCOMM holds the function code of (FCT code) the selected push
button.
SYNTAX :-
AT USER COMMAND.
CASE SY-UCOMM.
WHEN '<DELT>'.
* Delete functionality
ENDCASE.
NOTE :-
The additional functionality can be provide using only the system fields SY-PFKEY or SY-
UCOMM without using Events 'AT PF and AT USER COMMAND.
Contents ......................................................................................................................................................
REPORTS-ABAP Queries .......................................................................................................................
Programming in ABAP Editor .........................................................................................................................
Different types of ABAP Programs ..............................................................................................................
REPORT Statement ......................................................................................................................................
Some useful additions to REPORT Statement .............................................................................................
Comments ...................................................................................................................................................
WRITE Statement ........................................................................................................................................
Some useful additions to WRITE Statement ..............................................................................................
Data Types...................................................................................................................................................
Pretty Printer...............................................................................................................................................
Elementary Data Types ...............................................................................................................................
Mathematical Operations ...........................................................................................................................
DATA Statement..........................................................................................................................................
TYPE and LIKE Statements...........................................................................................................................
MOVE Statement ........................................................................................................................................
CLEAR Statement ........................................................................................................................................
ULINE Statement .........................................................................................................................................
ABAPDOCU Transaction Code .....................................................................................................................
PARAMETERS Statement.............................................................................................................................
Some useful additions to PARAMETERS Statement ...................................................................................
Mathematical Functions .............................................................................................................................
String Operators ..........................................................................................................................................
Condition or Control Statements ................................................................................................................
Numeric Comparison Operators .................................................................................................................
String Comparison Operators .....................................................................................................................
Loop Statements .........................................................................................................................................