ABAP is a programming language created and used by SAP for the development of application programs, including: Reports, Module Pool Programming, Interfaces, Data conversions, User Exits & BADI.
All of R/3s applications and even parts of its basis system were developed in ABAP. ABAP is an event-driven programming language. User actions and system events control the execution of an application. ABAP used to be called ABAP/4. The “4” stood for “fourth generation language”.
ABAP Workbench
The ABAP Workbench is used by SAP for the development of standard and custom application software. The ABAP Workbench is also used to create dictionary objects. It consists of the following components:
All of R/3s applications and even parts of its basis system were developed in ABAP. ABAP is an event-driven programming language. User actions and system events control the execution of an application. ABAP used to be called ABAP/4. The “4” stood for “fourth generation language”.
ABAP Workbench
The ABAP Workbench is used by SAP for the development of standard and custom application software. The ABAP Workbench is also used to create dictionary objects. It consists of the following components:
- ABAP Editor is used to maintain programs.
- ABAP Dictionary is used to maintain Dictionary objects.
- Repository Browser is used to display a hierarchical structure of the components in a package.
- Menu Painter is used to develop graphical user interfaces, including menubars and toolbars.
- Screen Painter is used to maintain screen components for an online program.
- Repository Information System contains information about development and runtime objects, such as data models, dictionary types and table structures, programs, and functions.
- Test and Analysis Tools, such as the Syntax Check and the Debugger.
- Function Builder, which allows you to create and maintain function groups and function modules.
- Data Modeler, a tool which supports graphical modeling.
- Workbench Organizer, which maintains multiple development projects and manages their distribution.
Reporting
Report programs produce lists and can be divided into conventional reports and interactive reports. Conventional reports do not allow interaction by the user; therefore, the basic list contains extensive information that the user must often sort through to find the relevant data.
Interactive reports allow interaction by the user; therefore, the user can produce secondary, detailed lists off of the basic list by choosing the relevant data and requesting more information.
Module Pool Programming
Module pool programming (or online programming) involves the creation of a module pool (a collection of ABAP modules) and one or more screens. The modules are called by the screen processor during program execution.
Batch input processing is used to ensure the safe transfer of data into the SAP system. This process is an automatic, protected data transfer to the SAP system which uses SAP transactions to validate data as it populates the SAP database. ABAP contains statements which conform to CPI-C standards (Common Program Interface - Communications). These are used for programming communications programs. ABAP can read and write sequential data sets.
Report programs produce lists and can be divided into conventional reports and interactive reports. Conventional reports do not allow interaction by the user; therefore, the basic list contains extensive information that the user must often sort through to find the relevant data.
Interactive reports allow interaction by the user; therefore, the user can produce secondary, detailed lists off of the basic list by choosing the relevant data and requesting more information.
Module Pool Programming
Module pool programming (or online programming) involves the creation of a module pool (a collection of ABAP modules) and one or more screens. The modules are called by the screen processor during program execution.
Batch input processing is used to ensure the safe transfer of data into the SAP system. This process is an automatic, protected data transfer to the SAP system which uses SAP transactions to validate data as it populates the SAP database. ABAP contains statements which conform to CPI-C standards (Common Program Interface - Communications). These are used for programming communications programs. ABAP can read and write sequential data sets.
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 execution. However, they do not have to be coded in a sequential order. Within an ABAP Processing Block, statements are processed sequentially (top to bottom).
Finally, the code in the END-OF-SELECTION processing block is executed.
All ABAP statements that are not written as part of a processing block (after an event keyword) or a FORM-ENDFORM block are automatically part of the Start-of Selection processing block if they are coded above all other event keywords or subroutines.
Following are the system-triggered events which occur during the run time of a report program . These events are presented in the order in which they are processed. These are called run time events.
Run time Event: Initialization
If a report has a selection screen defined (either explicitly or by default through the use of a logical database), the ABAP processor processes the selection screen first. A programmer can execute another block of code before the selection screen by using the event keyword INITIALIZATION. This processing block can be used to define characteristics of the selection screen. Examples include : setting default values on selection fields, setting a title bar, assigning text to push buttons, etc.
Run time Event: AT SELECTION-SCREEN
AT SELECTION-SCREEN occurs when the user triggers a function code on the selection screen (i.e., by clicking on push-button, hitting a function key, etc.). Checks can be made on selection screen fields and appropriate messages sent back to the user (error, confirmation, warning messages), or the program can be terminated. After the user enters new information, AT SELECTION-SCREEN is triggered again.
Run time Event: START-OF-SELECTION
START-OF-SELECTION is triggered after the selection screen is processed, and before any GET events or any other event processing blocks. If no event keywords are coded in a report program, the report statement automatically starts START-OF-SELECTION processing (it can be explicitly coded, but need not be). All ABAP statements that are not part of a processing block (after an event keyword) or a FORM-ENDFORM block are automatically part of the START-OF-SELECTION processing block if they are coded above all other event keywords or subroutines. The Syntax Check will offer a warning if it detects that a line of code is inaccessible due to being severed from an event processing block.
START-OF-SELECTION can be used to set default values of program-defined variables, or to code WRITE statements to be output to the screen.
Run time Event: GET and GET LATE
GET <table> events can only be used for the basic list in an interactive report. The GET 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 GET event keyword can only be coded once for any one table in the logical database program.
The GET <table> LATE event, if coded, occurs just before the next row (record) of the table specified in the GET event is selected from the database. It also occurs after any other GET or GET LATE events for tables lower in the hierarchy of the logical database program.
GET event processing requires that the logical database be specified as an attribute of the report program (while in the ABAP Editor, use the menu path Go to -> Attributes).
Run time Event: 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.
The other set of events that occur occur while the ABAP processor is processing the output list of a report program are called output events.
Output Event: 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.
TOP-OF-PAGE DURING LINE-SELECTION allows a programmer to display headers for detail lists (other than the basic list).
TOP-OF-PAGE DURING LINE-SELECTION is triggered with a WRITE, SKIP or ULINE statement on a detail list.
Output Event: 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.
Proper usage of LINE-COUNT is to include the number of lines per page, as well as how many lines are reserved for the footer.
For example, the following statement will display 50 lines of output, and then 3 lines of footer information.
REPORT YPROG LINE-COUNT 53(3).
There are some events that are invoked by the user when the system is displaying an output list from a report program. These are called "User Events"
User Event: AT PF##
The AT PF## event is triggered by when the system detects a PF## function code. This function code can be assigned to a function key, push-button, or menu item.
Most often, programmers assign a PF## function code to a function key on the keyboard, where ## corresponds to the number of the function key.
To use function keys above 12, (13-24), the user must hold down the shift key on the keyboard. For example, to initiate AT PF14, the user holds down the shift key and presses F2.
User Event: AT LINE-SELECTION
The event AT LINE-SELECTION is triggered when the user selects a line and invokes the PICK function code. This can occur when the user:
User Event: AT PF##
The AT PF## event is triggered by when the system detects a PF## function code. This function code can be assigned to a function key, push-button, or menu item.
Most often, programmers assign a PF## function code to a function key on the keyboard, where ## corresponds to the number of the function key.
To use function keys above 12, (13-24), the user must hold down the shift key on the keyboard. For example, to initiate AT PF14, the user holds down the shift key and presses F2.
User Event: AT LINE-SELECTION
The event AT LINE-SELECTION is triggered when the user selects a line and invokes the PICK function code. This can occur when the user:
- Double-clicks on a line
- Single clicks on a line and presses F2
- Single clicks on a line and presses a PICK push-button on the list
The AT USER-COMMAND event is triggered when the user invokes any function code except PICK and PF##.
The function code can be up to 20 characters long. This function code can be assigned to a push-button, menu item, or function key on the keyboard.
These user events will be explained in the further chapters in detail as these will be used by the ABAP programmers more frequently.
For example, the following function codes are matched with their corresponding function keys : PF05 through PF09 and PF13, PF14, PF16, PF17, PF18, PF19 are matched with function keys F5 through F9 with shift key pressed.
This means that these function codes are preset, ready for you to use with their corresponding AT PF## events.
Here’s a simple example:
START-OF-SELECTION
WRITE :/ 'Hi'.
AT PF06.
Write :/ 'User Pressed F6 Key'.
AT PF07.
Write :/ 'User Pressed F7 Key'.
If you want to write AT PF## events for function keys 13 through 24, the user will have to hold down the shift key on the keyboard. For example, to initiate the AT PF14 event the user must hold down the shift + F2 keys.
AT PF## events for function keys 1 through 12 do not require the user to hold down any additional keys.
The ABAP processor reserves some function keys. The slide above contains a chart that shows the SAP reserved function keys..
As a programmer, you are capable of writing code that reacts to virtually all of the function keys. However some function keys are reserved for ABAP functions. This is done to maintain a certain level of consistency.
Example: F1 will always be used by the end-user to initiate the online help system.
Remember: Event processing blocks end when:
- Another event key word is encountered
- A subroutine (i.e., a FORM statement) is encountered
- The program ends
Example: WINDOW STARTING AT 10 4 ENDING AT 77 12.
The above statement will create a new window starting at 10 4 and will end at 77 12. This statement is used to create new windows to open detail lists.
Your program can have up to 20 detail lists open at one time.
To maintain the number of additional lists that are created by the user we use the system field SY-LSIND. SY-LSIND contains an index that increments whenever a user event (event which occurs during
the list display) is triggered. SY-LSIND is incremented before the event processing block is executed.
A detail list is created whenever a WRITE, SKIP, or ULINE statement is encountered in a user event.
If no WRITE, SKIP, or ULINE statement is encountered in a user event (and therefore no detail
list created), SY-LSIND automatically decrements back to the previous level.