0% found this document useful (0 votes)
80 views15 pages

Session 6: Modularization Techniques:: Sub-Routines

The document discusses different modularization techniques in SAP ABAP including subroutines, include programs, function modules, and macros. It provides details on how to create and use each technique: subroutines can be used internally or externally and pass parameters by value or reference; include programs reuse code across programs; function modules are created using a function group and called to modularize program logic; macros allow reusable code blocks.

Uploaded by

Aravindh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views15 pages

Session 6: Modularization Techniques:: Sub-Routines

The document discusses different modularization techniques in SAP ABAP including subroutines, include programs, function modules, and macros. It provides details on how to create and use each technique: subroutines can be used internally or externally and pass parameters by value or reference; include programs reuse code across programs; function modules are created using a function group and called to modularize program logic; macros allow reusable code blocks.

Uploaded by

Aravindh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

SESSION 6:

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.

Sub-routines.
-Internal program
Call by value-Two memory address will allocate.(Using Value).
Call by Reference-Only one memory address will allocate.(Using,Changing,Changing Value)
-External Program

Include Programs.

Function Modules.
When we call the function module in ABAP program, it is internally inserted in the program.

First you create function group (Path: SE37 -> Goto -> function group -> Create a group) then you create
function modules.
(Or) Goto SE80-First create function group-after create function module.

Macros

Sub-routines:

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.

Internal program:REPORT ZMT_ARA1.


PERFORM SAM.
FORM SAM.
WRITE:/ 'INTERNAL PGM'.
ENDFORM.
Call by value:-(Using value)
PARAMETERS: A TYPE I,
B TYPE I.
DATA : C TYPE I.
PERFORM ANJU USING A B C.
C = A + B.
WRITE:/ 'C VALUE', C.
FORM ANJU using value(D) value(E) value(F).
D = 20.
E = 10.
F = D + E.
WRITE:/ 'F VALUE', F.
ENDFORM.
Call by reference:-(Using,Changing,Changing Value)

Changing value:
PARAMETERS: A TYPE I,
B TYPE I.
DATA : C TYPE I.
PERFORM ANJU USING A B C.
C = A + B.
WRITE:/ 'C VALUE', C.

FORM ANJU changing value(D) value(E) value(F).


D = 20.
E = 10.
F = D + E.
WRITE:/ 'F VALUE', F.
ENDFORM.

Using:PARAMETERS: A TYPE I,
B TYPE I.
DATA : C TYPE I.
PERFORM ANJU USING A B C.
C = A + B.
WRITE:/ 'C VALUE', C.
FORM ANJU using D E F.
D = 20.
E = 10.
F = D + E.
WRITE:/ 'F VALUE', F.
ENDFORM.

Changing:PARAMETERS: A TYPE I,
B TYPE I.
DATA : C TYPE I.

PERFORM ANJU USING A B C.


C = A + B.
WRITE:/ 'C VALUE', C.
FORM ANJU changing D E F.
D = 20.
E = 10.
F = D + E.
WRITE:/ 'F VALUE', F.
ENDFORM.

Function Module:Step:1

Go to T.code-SE80.First step-Choose -Function group and give Function group name.

Enter-Yes.
Step:2

Step 3:
Create package-Goto T.code-SE80-Choose Package and Enter.

Step 4:

Give package name.

Save.

Enter.

If you create Function group at that time two Include program will create default.

Step 5:
Create Function module on your Function group.-Right click on function modulecreate-Function group.

Give Function module name and short text.

Save and Enter.


Step 6:Choose on function module name and select -Import tap here give two variable
name.

Step 7:Select Export tap.

Step 8:Select Source code tap.-Here give syntax ---F = D + E.

Step 9:Create Program: Now call your Function module-Name ZFM_1.


REPORT ZFM_PGM.
PARAMETERS: A TYPE I,
B TYPE I.
DATA: C TYPE I.

CALL FUNCTION 'ZFM_1'


EXPORTING
d
= A
e
= B
IMPORTING
F
= C
.
WRITE:/ 'C VALUE',C.
4.Macros.
DATA: C TYPE I.
DEFINE MACRO.

C = &1 &2 &3.


END-OF-DEFINITION.
MACRO 10 + 10.
WRITE:/ C.
-------------------------------------------------------------------------END.

You might also like