Modularization Techniques

What is a Modularization in SAP ABAP Programming ? Types of Modularization techniques in SAP ABAP programming

+ -
The concept of modularization is dividing the main program into sub-programs for better readability and re-usability. Modularization can be implemented in the following ways.

Include Programs :

  • These are sub-programs which contains a set of re-usable statements .
  • These programs can not be executed directly.
  • These include programs must be embedded inside a main program for execution.
  • These programs dosen`t contain parameter interface, that is no importing and exporting parameters.
Syntax : INCLUDE .  

Example of using include programs :

TYPES : BEGIN OF TY_MARA,
        MATNR TYPE MARA-MATNR,
        MTART TYPE MARA-MTART,
        MEINS TYPE MARA-MEINS,
        MBRSH TYPE MARA-MBRSH,
        END OF TY_MARA.
DATA : IT_MARA TYPE TABLE OF TY_MARA. DATA : WA_MARA TYPE TY_MARA. SELECT MATNR, MTART, MEINS, MBRSH FROM MARA INTO TABLE IT_MATA. LOOP AT IT_MARA INTO WA_MARA . WRITE :/ WA_MARA-MATNR, WA_MARA-MTART, WA_MARA-MEINS, WA_MARA-MTART. ENDLOOP.

To make the above program with includes, follow below steps.

INCLUDE ZDATA_DECLERATIONS .  "DOUBLE CLICK ON ZDATA_DECLERATIONS AND CREATE A INCLUDE AND ADD DATA DECLERATIONS AND ACTIVATE
INCLUDE ZMAIN_LOGIC. " DOUBLE CLICK ON ZMAIN_LOGIC , CREATE A INCLUDE AND ADD THE REMAINING LOGIC (FROM SELECT....TO ....ENDLOOP).

Function Modules

  • These are also sub-programs which contains set of reusable statements for better readability and re-usability .
  • Function modules contains parameter interface, that is importing and exporting parameters.
  • These Function Modules can be executed independently .
  • Function modules contains exceptions to catch certain type of errors.

Examples for Function Modules are : GUI_DOWNLOAD, GUI_UPLOAD.

T-code for Function Module explorer is SE37 .

In our next chapters we will learn how to create and use a function module Creating Function Modules in SAP ABAP

Sub-routines in SAP ABAP.

  • Sub-routines are also sub-programs in SAP ABAP which contains certain re-usable statements.
  • Most of the times we use sub-routines for re-usability inside the program.
  • We may use sub-routines for external re-usability.
  • These sub-routines contains importing and exporting parameters .
Syntax : 
**DEFINING SUBROUTINE
PERFORM  USING  
                          CHANGING  
                          TABLES  .
**IMPLEMENTING SUBROUTINE
FORM  USING   
                       CHANGING  
                       TABLES  .

ENDFORM.


**IN THE ABOVE SYNTAX  AND  ARE ACTUAL PARAMETERS AND   ARE FORMAL PARAMETERS

We will learn creating and using sub-routines in next chapters Using subroutines in SAP ABAP

Using Classes in SAP ABAP

  • Classes are Object Oriented implementations of SAP ABAP.
  • Classes are used for better re-usability.

We will learn Object Oriented ABAP in next course Using Classes in SAP ABAP

Please Sign in to ask a question

Was this lesson helpful to you? Yes No 57 People out of 61 think this lesson helpful


Lesson Navigation

Selection Screen Design using SAP ABAP← Previous Lesson
Next Chapter →