In this topic, we described about the below sections -
What is Modularization?
In some scenarios, the application programs are too big and it’s not easy to maintain or find out issues or debug the issues in the program. The application program in ABAP can be divided into smaller units using the technique called Modularization.
Modularization is a technique used to divide the application program into smaller units to maintain easily and reduce the code redundancy. The identical logic coded in many places (either in the same program or in multiple programs) called as a redundandant code.
To understand the concept clearly, let us discuss with an example of multiplying two numbers. Let us assume the multiplication of two numbers logic coded in many places of the application program.
Modularization supports to reduce the code redundancy by separating the multiplication logic from multiple places into a single modulization unit and calling the separated modulization unit from all the place where it is required.
In the same way if any variables are using in multiple programs, those are coded in modularization unit and use it in the multiple programs where those are required. This technique reduces the code redundancy and increases the readability, reliability and re-usability.
Modularizing source code is set of statements coded in a separate module and the module can be called by any program as required.
- Easy to read and understood
- Easy to maintain
- Easy to debug
- Eliminates code redundancy
- Increases reusability of code
Modularization usage -
Modularization concept implemented in ABAP programs in the following ways -
|Macros||If same set of statements are repeated more than once in the program, those statements can be used to create a macro. The macro only used in the program where it is defined.|
|Subroutines||Subroutines are procedures can define in any ABAP program and call from any ABAP program.
Subroutines are two types - Internal and External.
Subroutines normally contains section code or algorithms code.
|Include programs||If same set of statements (source code) are used more than once in program, those statements can be used to create an include program.
Include programs can use in any other ABAP program.
Include programs are only used to modularize the source code but have no parameter interface.
|Function modules||Function modules are stored in central library.
Function modules are available to the entire system.
RFC (Remote Function Call) enables function modules that can be called from non-SAP system.
|Methods/Classes||Methods/classes used in ABAP object oriented programming.
Methods/Classes implements parameter interface.