ABAP MODULARIZATION
In sap abap, modularization means, breaking the abap program into small modular units, also known as
logical units and placing our abap code into that block, Instead of writing the complete code into the main
program and we can call the required module as per the sequence we required.
Report ZABAP_MODULARIZATION.
Include ZABAP_MODULARIZATION_HEADER.
Include ZABAP_MODULARIZATION_TOP. “data declaration
Include ZABAP_MODULARIZATION_SC. “selection screen
Start-of-selection.
Perform get_data.
Perform display_data.
End-of-selection.
FORM GET_DATA.
ENDFORM.
FORM DISPLAY_DATA.
ENDFORM.
Need of modularization
Easy to read the code
Easy to maintain the code
Make reuse of code either locally or globally
Avoid redundancy.
Modularization Techniques
Include Programs
Subroutines
Function Modules
Macros
Include Programs: Include program we can create with SE38 and SE80, it can be used in different main
program, it allow us to use the same source code in different programs.
Syntax: include <include program name>.
Subroutines: Subroutines are the procedures, that we define in a abap program and generally call internally
i.e with same program but also possible to call externally through other abap program.
Syntax :
FORM <subroutine name> <parameters option>
Code block.
ENDFORM.
ABAP MODULARIZATION
Function Modules: Function modules are created in Function Builder with transaction code SE37, there are
1000s of FM provided by sap, that we can use directly in our program or we can create our own Function
module with SE37 and the FM we have to call in our program.
Syntax to call a FM
CALL FUNCTION 'ISP_CONVERT_FIRSTCHARS_TOUPPER'
EXPORTING
INPUT_STRING = gv_input_string
SEPARATORS = ' -.,;:'
IMPORTING
OUTPUT_STRING = gv_output_string.
Macros: If we want to reuse same set of statements multiple times in a program, we can include them in
macro. A macro can be called only in the same program in which it is define. Macro definition should be
before in the program , then the actual macro used.
We can also use parameters inside the macro.