modularization techniques in sap abap

MODULARIZATION TECHNIQUES

modularization techniques in sap abap
modularization techniques in sap abap

Modularization is the process of breaking the program into multiple blocks.
A block is a set/collection of statements which is defined only once and can be called / accessed any no. of times.

Advantages of Modularization:
·        Increases re-usability.
·        Efficient control on the flow of program execution.
·        Maintenance cost is decreased.
Following are the Modularization techniques:
·        Subroutines
·        Include programs
·        Macros(HR-ABAP)
·        Function modules
·        Methods(OOPS ABAP)
Subroutines:
It is a block of statements, which is defined only once and can be called any number of times.
Subroutine can be created either with parameters or without parameters.
A subroutine is associated with 2 sections.
·        Defining the subroutine
·        Calling the subroutine
Subroutine as to be defined at the end of the program.
Whenever a subroutine is called the control jumps to subroutine definition.
There are two types of subroutines.
·        Internal subroutine
·        External subroutine
Internal  subroutine:
It is defined as well as called from the same program.

Syntax for defining internal/external subroutine:
Form <subroutine> [ parameters list]
                        statements.
Endform.

Syntax for calling internal subroutine:
 perform    <subroutine> [parameters list]

External subroutine:
They are defined in external programs and called from other programs.
The external program can be another executable program or a subroutine pool.

Subroutine pool:
It is a repository object which is a collection of one or more external subroutines

Syntax for calling external subroutines:
Syntax 1
Perform <subroutine> in program <external program> [parameters list].
Syntax 2
Perform <subroutine> (<external program>) [parameters list].

Subroutines with parameters (for data exchange and manipulation)
We can define subroutines with parameters.
For this we use the following keywords.
1.     Using
2.     Changing
3.     Tables
The parameters specified as part of subroutine definition are called as formal parameters and the parameters specified at the time of calling the subroutine are called as actual parameters.

Using:
Using is the keyword used as part of subroutine definition and subroutine calling to deal with standard data types as parameters.
The formal parameters and actual parameters names can be same or different.
The number of formal parameters depends upon the number of actual parameters.

Subroutines returning values:
For this we can use the keywords changing or tables.
The number of return parameters depends upon number of changing and tables parameters.
The changing and tables parameters can be used for both passing the values as well as returning the values.
We can pass parameters to subroutines in two ways.
1.     Pass by reference (default).
2.     Pass by value.

pass by reference vs pass by value
Pass by reference:
In this, the address of actual parameters are copied to formal parameters. So, any changes made to the formal parameters variables will automatically reflect the content of the actual parameters.

Pass by value:
In this, the values of actual parameters are copied to formal parameters. So, any changes made to the data of formal parameters will not reflect the content of the actual parameters. For this, we need to use the keyword ‘value’ as part of formal parameters.

Internal tables as parameters to subroutines:
We need to use tables keyword as part of subroutine call and subroutine definition to deal with internal tables as parameters to subroutines.
In this case, if we perform the operations like delete and modify on formal internal table with where clause, we must specify the structure of the formal internal table and it is done by using the keyword structure as part of subroutine definition.
In this case, any changes made to the data of the formal internal table, will automatically reflect actual internal table data.
Internal tables are always passed by reference.

Note:- If anybody want some example of these all topic then kindly send/comment your mail id, i will send the all examples through mail in word format.


**Kindly like and share these all topic with your friends**

Post a Comment

0 Comments