Structure of an ABAP Program

The Structure of an ABAP Program should include the following:

  1. An Introductory part
  2. A Global declaration part
  3. Processing blocks – which consist of functions including procedures, event blocks, and dialog modules.

Introductory Program Part

All ABAP programs start with a statement like REPORT, PROGRAM, or FUNCTION-POOL at the beginning. All ABAP programs have a type associated with them. This could an executable program, module pool program, or function group program. How an ABAP program begins depends on its type. Each of the types of an ABAP program is described below.

#REPORT: – Represents an executable program.

#PROGRAM: – Represents a module pool program and subroutines.

#FUNCTION-POOL: – Represents a function group.

#CLASS-POOL: – Represents a class pool program.

#INTERFACE-POOL: – Represents an interface pool program.

#TYPE-POOL: – Defines the type group.

On creating the program, SAP on its own relates the program to the most suitable introductory statement for it. This usually depends on the type of the program being created and should be assigned manually to each of the program types that we have described above.

 

Global Declaration Part

The declaration part is done keeping in mind the Global Data, Class Definitions, and Selection Screens. In SAP, we must always declare global data, classes or selection screens after the introductory part of an ABAP program. The declaration part may include the following:

  1. Global data: – Global data should be defined in an ABAP program. To define the global data, we should have the following declaration statements – TYPES, TABLES, and DATA. The global data which is defined in an ABAP program can be seen in every internal processing block of the program.
  2. Selection screens This refers to the special screens that are created through the use of ABAP statements rather than Screen Painter. Selection screens make it possible for you to enter just one value for one or more fields or use a wider selection criterion.
  3. Local class definitions— These include definitions of local classes in an ABAP program and are generated using the CLASS DEFINITION statement. These local classes are an integral part of ABAP Objects, which are nothing but object-oriented extensions of ABAP. 

Structure of an ABAP Program

Processing Blocks

After the introductory program part and declaration of global data, we have the processing blocks in the ABAP program structure. A processing block is defined as “a set of ABAP statements that represents a module of an ABAP program.”

The purpose of ABAP programs is to process the data using the dialog steps of an application. ABAP programs are hence broken into several different sections, that are interlinked in the application and each section is assigned to its own dialog steps. What that means is that ABAP programs are modular programs or have a modular structure and each module of the ABAP program is related to a processing block.

There are quite a few types of processing blocks in an ABAP program such as, Dialog modules, Event blocks, and Procedures- which include methods, subroutines, and functional modules.

All Dialog modules and procedures are compulsorily enclosed inside ABAP statements like as MODULE…ENDMODULE and FUNCTION…ENDFUNCTION.

Event blocks are processed on the triggering of certain events when certain user actions are performed on selection screens and lists or because of the running environment of ABAP. An event block is initialized using ABAP statements, namely START-OF-SELECTION and AT USER-COMMAND and created within a processing block. This processing block starts with an ABAP statement, like WRITE and NEW-PAGE. As soon as a new processing block begins, the event is terminated implicitly. Any ABAP statement, other than a declarative statement, is a part of a processing block. All ABAP statements that are within the declaration of global data and a processing block fall under the START-OF-SELECTION processing block.

It is also possible to call a processing block from outside the ABAP program by using a dialog module or event block, or by making use of ABAP commands like CALL METHOD, CALL TRANSACTION, SUBMIT, or LEAVE TO, as long as these statements are used in an ABAP program.