Google

What is the typical structure of an ABAP program?

typical structure of an ABAP program in sap

  • HEADER
  • BODY
  • FOOTER

There are basically two kind of ABAP programs that are Report Programs and Dialog (Module) Programs. Report Programs for, as you can guess, reports and they are naturally read-only program in general. When you write report programs you don’t have to worry about screens, SAP would create screens for you. But when you develop module programs you have to design screens with all details like text, input boxes, radio boxes, check boxes and everything. Even the flow of the program changes.So actually the structure of an ABAP program differs for each report and module programs. Sure you can combine report and module programs together in one program, since both are ABAP programs

The Structure of an Application Program
Let us look at firstly the structure of an application program:
R/3 applications run within the R/3 Basis system the work processes of application servers. This makes them independent of the hardware and operating system that you are using. However, it also means that you cannot run them outside of R/3 system.







An ABAP program consists of two components, each of which has a different task:



Flow Logic: Integration between application programs and user is implemented using screens. Screens are processed by the screen processor of a work process. As well as the input mask, they consist of flow logic. This is coding, written using a special set of keywords called the screen language. The input mask is displayed by the SAPgui, which also transfers the user action on the screen back to the flow logic. In the program flow, screens react to user actions and call program modules. These program modules form the processing logic.

Processing Logic: The components of application programs that are responsible for data processing in the R/3 System are ABAP programs. They receive screen input from the screen processor and send it to screen processor. You access the database using the database interface. ABAP contains a special set of commands OPEN SQL. This allows you to read from and and write to the database regardless of the database you are using. The database interface converts the OPEN SQL commands into commands of the relevant database. You can also use native SQL commands, which are passed to the database without first being converted. There is a range of further interfaces such as memory, sequential files and external interfaces. These provide other means of sending data to and from ABAP programs. When working together with screens, ABAP programs play a more passive role, acting as a container for a set of modules that can be called from the flow logic.


The Structure of an ABAP Program
ABAP processing logic is responsible for processing data in R/3 application programs. ABAP was designed specifically for dialog-oriented database applications.


ABAP programs are responsible for data processing within the individual dialog steps of an application program. This means that the program cannot be constructed as a single sequential unit, but must be divided into sections that can be assigned to the individual steps. To meet this requirement, ABAP programs have a modular structure. Each module is called a processing block. A processing block consists of a set of ABAP statements. When you run a program, you effectively call a series of processing blocks. They cannot be nested.




Each ABAP program consists of the following two parts:


Declaration Part for Global Data, Classes and Selection Screens

  • The first part of an ABAP program is the declaration part for global data, classes, and selection screens. This consists of :
    All declaration statements for global data. Global data is visible in all internal processing blocks. You define it using declarative statements that appear before the first processing block, in dialog modules, or in event blocks. You cannot declare local data in dialog modules or event blocks.
  • All selection screen definitions.
  • All local class definitions (CLASS DEFINITION statement). Local classes are part of ABAP Objects, the object-oriented extension of ABAP.

Declaration statements which occur in procedures (methods, subroutines, function modules) form the declaration part of local data in those processing blocks. This data is only visible within the procedure in which it is declared.


Container for Processing Blocks

The second part of an ABAP program contains all of processing blocks for the program. The following types of processing blocks are allowed:

  • Dialog modules (no local data area)
  • Event blocks (no local data area)
  • Procedures (methods, subroutines and function modules with their own local data area)