You are on page 1of 13

ABAP Stands for Advanced Business Application Programming.

ABAP is a programming language created and used by SAP for the development of application programs,including: Reports, Screens, Interfaces & Data conversions. All of SAP 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 Overview The Advanced Business Application Programming / 4GL (ABAP/4, commonly referred to as ABAP) is SAPs proprietary language. More than 80% of SAP R/3 is developed using ABAP. The ABAP Program code is generated into Byte-code at the time of Activation of the program and is processed by the ABAP Processor which is part of the Kernel and Basis Services (a set of core programs developed in C) at the time of execution. Any ABAP Program, because it requires the BASIS modules, can run only within an SAP environment. Many features of the programming language and ABAP editor environment resemble the COBOL / IBM Mainframe environment although much of it has been scaled down somewhat to give the language a modern look. The language is case-insensitive and each statement terminates with a period. ABAP programs are event-driven to an extent though the event handling capabilities are not similar to full-fledged object-oriented languages such as Java or even Visual Basic. ABAP objects or classes can be defined and implemented using the Class Builder for use in report and dialog programs. Reporting Report programs produce lists and can be classified as 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 allows for interaction (and drilldown) with the user;therefore the user can produce secondary, detailed lists off of the basic list by choosing the relevant data and requesting more information. ALV Reports also allows interaction by the user, it can display large amount of data at one short in the form of excel sheet. Components of ABAP Program

An ABAP program contains the following components: Source code : containing the ABAP statements Screens : Consist of the screen layout and associated flow logic. You normally create the layout of a screen using the Screen Painter However, there are special kinds of screens, called selection screens and lists, whose layout and flow logic are designed exclusively using ABAP statements. Interface : contains all of the entries in the menus, the standard toolbar, the application toolbar, and function key settings. It contains titles and statuses. A status is a collection of function key settings and menus. Text elements: are language-specific. They can be translated either directly from the text element maintenance tool, or using a special translation tool. Documentation : is also language-specific. Always write documentation from the users point of view. If you want to document the programming techniques you have used, use comments in the program code instead. Variants : allow you to predefine the values of input fields on the selection screen of a program.

Structure of ABAP Program

ABAP is an event-driven programming language, and as such is suited to processing user dialogs. The source code of an ABAP program consists of two parts: Declarations: Declarations include the statements for global data types and objects, selection screens, and (in ABAP Objects) local classes and interfaces within the program. Processing Blocks (indivisible program units) Each processing block must be programmed as a single entity. There are two basic kinds of processing blocks: Event Blocks: Event blocks are introduced by an event keyword. They are not concluded explicitly, but end when the next processing block starts. Dialog Modules and Procedures: Dialog modules and procedures are introduced and concluded using keywords. The contents of all processing blocks form the processing logic. When you generate the program, these parts are compiled to form the load version. This is interpreted at run time. ABAP Terms to Remember

A Program is a series of structured ABAP statements. It could be an Executable program or a Dialog Program. A Report is normally an ABAP Program which outputs a list. Some people refer to the List as the Report and to the ABAP report as a report program. A Module Pool is a non-executable program which contains modules that control dialog processing. A List is an output of an ABAP Report program. There are Programs of other types such as Include (a non-executable block of code that can be included into a main program), Subroutine Pool (a pool of subroutines or FORMs which can be executed from another executable block), a function pool which contains a group of related functions, and so on. ABAP Editor

The ABAP Editor is used to create ,maintain, and execute ABAP programs. You could navigate to the ABAP Editor through the SAP menu for ABAP Workbench or by typing in the transaction code SE38 in the command input field. More details about the features of the ABAP editor is covered later. Some methods for executing ABAP programs include: The ABAP Editor: Tools -> ABAP Workbench ->ABAP Editor (pushbutton) The Reporting function: System->Services->Reporting ABAP programs that you create must start with a Y or A Z and can be up to 30 characters in length. The editor combines a character based text entry capability with graphical icons and menu options to perform many of the functions necessary to build complex ABAP applications.The ABAP development environment provides a wide variety of tools required by the programmer for developing and testing of applications. Pictured above is the online debugging tool which enables the programmer to step into the program line by line. The online debugging tool provides the programmer with the capability to designate watch variables. These variables once chosen can be viewed as their values change from statement to statement while the program executes. The programmer can even change their values to simulate different processing scenarios.

The ABAP program editor provides many functions through the use of graphical pushbuttons. Among these functions are:

Toggle from display mode to edit mode Syntax check with limited auto correction Activation activates the program. Execution- Executes the program Where used list- to find the tables, statements, data elements used in the programs. Find and repeat find. ABAP help. ABAP Programming Execution

The individual processing blocks are called in a predetermined sequence at runtime, regardless of the position in which they occur in the program. Once a processing block has been called, the statements within it are processed seqeuentially. Event block

If the system program or a user triggers an event for which the corresponding event block has been written in the processing logic, that event block is processed. The program flow is controlled either by the system or the user. Modularization unit When the system encounters a modularization unit call within a processing block, it calls the corresponding processing block. In this case, the program flow is controlled by the programmer. Assigning transaction codes To allow a module pool to be executed, you must assign a transaction code to it. You can (but do not have to) assign a transaction code to an executable (type 1) program. Basic ABAP Program Syntax

An ABAP program is comprised of a series of individual ABAP statements Each statement must end with a period.( full stop) Key words are always the first word in a statement. Words must be separated by at least one blank. ABAP statements can be indented and extend over several lines. ABAP Program Structure

ABAP programs must start with either the PROGRAM or REPORT statement.

This statement is produced automatically when the program is created through the Repository Browser. The REPORT statement is used for ABAP reports programs. The PROGRAM statement is used for general ABAP programs( for example, module pool programs). All global data declarations must be grouped together at the beginning of the program in a declaration section. The statement section can consist of various processing blocks.This subject is dealt with in the remaining chapters of this course. Always Adhere to ABAP program naming standards dictated by the client. Chaining Statements in ABAP

To avoid repeating key words,ABAP allows you to chain statements together if these statements begin with the same key word. The key word is followed by a colon. Each chained statement component is separated by a comma. Blanks can be inserted before and after the separators (which may be colons,commas or periods). Comments

Comments are inserted into the program in two ways:


By placing an asterisk(*) in column 1,the complete line is designated as a comment line. By placing a double quotation mark() within a line the remainder of the line is considered a comment. ABAP Program Attributes

One way to create a new program is:


Go into the program menu from the ABAP Editor: Initial Screen. Select the Create menu option or use the Create function key. You can also create , maintain ,and execute programs from the Repository Browser ( this is the recommended method for creating programs). The program attributes must be maintained

before proceeding. ABAP programs must be assigned to a development class or ,if applicable, identified as a local ,private object. (This is a requirement of SAPs Correction and Transport System.) The application, class and type attributes are used for the management of ABAP programs. The application, title, status and type attributes are used for the management of ABAP programs. The application,title,status and type attributes are required. Other attributes are optional requirements. F1 and F4 are help keys which allow you to search for the significance of the attributes or a list of allowed input values. The ABAP editors Execute functionis used to start an ABAP program directly from the editor. An ABAP module pool program is executed using transaction codes.

You can navigate to the ABAP Editor through the Menu. You can also create favorites for certain transactions and put it into your custom menu. You can type SE38 from anywhere in the SAP environment to redirect you to the ABAP editor (must come out to a Area Menu or prefix transaction code with /n). Tools such as the Function Builder, Data Dictionary, Screen Painter and Menu Painter are integrated to the ABAP editor and you can navigate to the Editor and load the corresponding program by double-clicking on a program name on a Program field. The ABAP Editor can be used to create Programs of different types (Module Pool, Report, Include, Subroutine Pool, etc.)

Steps to create a Program in SAP ABAP


Creating Program Step 1

As indicated before, the ABAP Editor can be used to create Module Pool (Dialog Programs), Report Programs (which output lists or reports by accessing the database), Includes (non executable programs which can be

included into a main program), Subroutine Pool (a collection of subroutines which can be reused) and several other types of programs. On the ABAP Editor: Initial Screen, a program name should be given and Create push button needs to be pressed. A Developer Key maybe required for the specific user to create/edit programs. This is supplied by SAP. All custom programs should begin with Z or Y if they are report programs. There are other specific conventions that need to be used for creation of custom Module Pools (SAPMZxxxxx), custom Subroutine Pools (SAPFZxxxxx), etc. which are covered in later topics.

Creating Program Step 2

Enter the Title (a description), Type (such as Executable Program, Module Pool, etc. Right now enter Executable Program) Choose an Application and a Status for the Program (these are all informational attributes) The checkbox for Fixed Point Arithmetic is mostly checked. This is to indicate that Fixed point arithmetic will be used to perform all calculations. If it is not checked, packed numbers (Decimals in ABAP) will be treated as integers when used in assignments and calculations.

By checking the Editor Lock checkbox, one could prevent other users from making changes to the program. Once all the attributes have been filled, press the Save Button.

Creating Program Step 3

Enter the development class in this dialog box. A Development class groups together a set of related ABAP workbench objects. Programs, Tables, Structures, Menus, Screens, Messages, and even data can be assigned a development class.

A Development class is particularly useful when transporting Objects from one SAP Instance (R/3 system) to another. You could create a new development class from the Object Navigator (also called the Repository Browser). An object can be created as a Local Object which would be specific to the user. A development class $TMP is assigned to such local objects.

Local Objects cannot be transported to other SAP Instances.

Creating Program Step 4

If a valid development class had been assigned in the previous step (NOT appli cable for Local Objects), then the system asks for a transport request. A transport request is used to track the changes and can be used to: Group related changes to a request number Pull back changes made against a certain request number Transport objects to another SAP Instance Transports are managed in a Correction and Transportation System (CTS) which can be accessed by the transactions SE01, SE09 and SE10.

Creating Program Step 5

The program now appears in the editor. ABAP code can be incorporated into the program after the REPORT statement. If a check syntax is run on the program, any syntax errors are thrown on the same window on the bottom portion. Clicking on a syntax error takes you to the appropriate line. Correct the errors (if any). Activate the program (Ctrl+F3 can be used as a shortcut) before executing it. All programs need to be activated before executing.

You might also like