- ABAP modularization technique Subroutines
- ABAP Steps to Create Function Module
- ABAP modularization technique Function Modules
- ABAP Function Groups
- ABAP modularization technique Include Programs
- ABAP modularization technique Macros
It’s a good practice to keep ABAP program modularized. An ABAP program written as a single unit is difficult to maintain as well as have poor readability. Also it may contain repeated blocks of code.
Modularization involves placing repeated code in a logical reusable block also known as a module or processing block and call the block as and when required. Modularized ABAP programs are easy to read, easy to maintain and well organized.
You can modularize source code as well as encapsulate a function to be re-used several times. The ABAP program gets sub-divided into function oriented modularization blocks.
Any change required in logic will involve change only in the modularization unit will affect all instances where the module unit is called.
The ABAP Modularization techniques are:
- INCLUDE programs
- Macros
- Subroutines
- Function Modules
- Methods of Local class
- Methods of Global class
Local Modularization for ABAP Programs
In Local program modularization, the modules are defined and implemented in the same program.
- Subroutines
- Methods of Local Classes
- Macros
Global Modularization for ABAP Programs
Defined globally and available throughout the SAP system. These modularization units are stored in a central Repository and loaded when called into the context of the calling program.
- Function Modules
- Methods of Global Class
- INCLUDES
Kinds of processing blocks
- those that can be called by ABAP statements in ABAP programs.
- and those that are called from outside a program by the ABAP runtime systems
Processing blocks that are called from ABAP programs are called procedures.
- subroutines called by statement PERFORM
- function modules called by statement CALL FUNCTION
- methods of classes called by statement CALL METHOD
Processing blocks that are called using the ABAP runtime system are event blocks and dialog modules.
- event blocks INITIALIZATION, AT SELECTION-SCREEN, START-OF-SELECTION, END-OF-SELECTION
- dialog modules ex PROCESS BEFORE OUTPUT (PBO), PROCESS AFTER INPUT(PAI)
Splitting up ABAP programs into event blocks and dialog modules is designed to help the general flow of the programs.
Source code modularization
Include Programs and Macros are considered source code modularization. Include programs are used to structure large programs, whereas macros are used to recycle individual parts of programs.
- Include Programs – created globally in SAP system
- Macros – local to ABAP program
Subroutines, Function Modules, and Methods of Classes is considered functional modularization.
- Subroutines
- Function Module
- Methods ( involves OO ABAP )