MODULARIZATION TECHNIQUES


MODULARIZATION TECHNIQUE


Modularization:

               Modularization is a technique use to divide a large amount of coding into small manageable unit. It can be used when we want to reduce the redundancy of coding in a program.

Advantage of Modularization:

·       Reduce redundancy of coding.
·       Improve readability.
·       Reusable of coding.

·       Easy to debug.

Type of Technique:
Subroutine Types:                                                
Internal (IS)               External (ES)

Subroutine(S):

               Subroutine is a program module. This can be called from other ABAP/4 program (ES) or within the same program (IS)

·       Internal Subroutine(IS):
         The source code of the Internal Subroutine will be in the same ABAP/4 program as the calling procedure. Define at the end of the program.
 Syntax:
      Perform <form_name>

·       External Subroutine(ES):
         The source code of the External Subroutine will be in an ABAP/4 program as other than the calling procedure.
Syntax:
      Perform <form_name> (Type S pgm_name).



          Data can be passed between calling program and subroutine using parameters. There are two different types of parameters, they are as follows,

·       Formal Parameter:
                  Parameters which are define during the definition of subroutine with the form statement.
·       Actual Parameter:
                  Parameters which are specified during the call of subroutine with in perform statement.
       
   Input parameter used to pass the data to subroutine.

  Output parameter used to pass the data from subroutine.


1.     Include program:

Syntax:
Perform <Form name>.
Include (type I program name).
·       Include program can’t call themselves,
·       Include program must have complete statement.
·       We can’t define the Type I program internally, because include programs are global R/3 repository objects.





Subroutine
Include
The Particular form only loaded into memory so no memory wastage.
The Entire program will be loaded into memory suppose we call single parameters so the memories waste.

Different method of passing data:


·       Call by Reference.
·       Call by Value.
·       Call by Value and Result.

Call by Reference:

         During a subroutine call, only the address of actual parameters transferred to formal parameters. Formal parameter has no memory of its own and we work with field of the calling program within the subroutine. Changes made in formal parameter, the field contents of calling program also changed.



Call by Value:



          During a subroutine call, the formal parameters are creates a copy of actual parameter. Formal parameters have their own memory, so any changes made in formal* program it will not affect the actual parameter.


Call by Value and Result:


           During subroutine call, the formal parameters are creates a copy of actual parameters. The formal parameters have their own memory. Changes made in formal* parameters are copied to the actual parameters at the end of subroutine.

1.     Function Module(FM):

       Function group (FG) is a container of function module when we are create a function group automatically two include program are created they are as follows,

·       L<FG-NAME>TOP (To declare a global variable).
·       L< FG-NAME>UXX (It’s standard never change, it contains further include statement for include program).
·       L<FG-NAME>U01 (It contain actual function module. It will create automatically when at the time of FM creation).

        Function module is a global modularization we can call it anywhere in the program, it must be define in the function group. There are two type of function module, they are as follows,

·       Normal Function Module (Within SAP only we can access this FM).
·       Remote Enable Function Module (SAP to Non-SAP vice-versa).
·       Update Function Module (To update the master data as well as Transaction data)
Syntax:
           Call ‘function module name’ through pattern.
                    Statement block.
                   

Steps for Create FM :-> Go to enter se37 in comment box.
·       Before that you should create FG because they are the container for function modules in menu bar go to->Function Group->create Function Group.





·       Go to se80 for activate FG.

·       Go to se37 give any FM name.

·       Go to se37 click create button give FG name which we are create since before then
It will ask function module is reserved for SAP click continue then you have to maintain interface parameters they are as follows,




·       Attributes->Attributes of function module. Here we can choose whether the function             
                 Module is NFM or RFM

·       Import-> These must be supplied with data when you call function module unless they are flagged as optional. You can’t change them in function module.

·       Export- >These pass the data from the function module back to the calling program. It’s always optional.

·       Table->These pass the internal table as argument by reference.

·       Changing-> these must be supplied with data when you call function module unless they are flagged as optional. You can change value in the function module. The changed value are then return to the program.



·       Exception-> Here we can handle the exception, it has two type of exceptions

1. RAISE (Terminate the program and switch to debugging mode).
            2. MESSAGE…RISING (displayed specify message, then Continues depends on    the Message type).

·       Source code->Here we can write coding based on  our requirement.

·       Call the function module using pattern in se38 type 1 program.




1.     Macro:

    If you want to reuse the same set of statement more than once in a program you just include them into macro. You can use macro within the program in which it’s define.

Syntax:
  DEFINE <m_name>.
   Statement block;
  END-OF-DEFINITION.


Uses of Macro:
·       This can be useful for long calculation.
·       Complex writes statement.
    







No comments:

Post a Comment