Quick Contact

    SAP Tutorial
    Sap FI

    Modularization Techniques

    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.
    • Function Modules.
    • Sub-routines.
    • Classes.
    • MACRO`s ( Use in HR ABAP only ).

    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 < include name>.

    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.< br>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 < SUBROUTINE NAME> USING < AV1>< AV2>
            CHANGING < CHANGING1>< CHANGING2>
            TABLES < TABLE1>< TABLE2>.
    **IMPLEMENTING SUBROUTINE
    FORM < SUBROUTINE NAME> USING < FV1>< FV2>
            CHANGING < CHANGING1>< CHANGING2>
            TABLES < TABLE1>< TABLE2>.
    
    ENDFORM.
    
    
    **IN THE ABOVE SYNTAX < AV1> AND < AV2> ARE ACTUAL PARAMETERS AND < FV1>< FV2> 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.


     

    Apply now for Advanced SAP Course

    Copyright 1999- Ducat Creative, All rights reserved.

    Anda bisa mendapatkan server slot online resmi dan terpercaya tentu saja di sini. Sebagai salah satu provider yang menyediakan banyak pilihan permainan.