You are on page 1of 21

WHAT IS MEANT BY MODULARIZATION ?

In General Modularization is the degree to which a system's components may be separated


and recombined.

T H E R E A R E D I F F. M O D U L A R IZ AT IO N T E C H N IQU ES
Macros Subroutine-Perform Function Module. Include Methods--- Oops

DIFFERENCE B/W MACROS & SUBROUTINES

MACROS: Macros can only be used in the program the are defined in and only after the definition. Macros can take max 9 parameters. Macros are expanded at compilation / generation. SUBROUTINES: Subroutines (FORM) can be called from both the program the are defined in and other programs ('perform ' of 'perform in program '). Subroutines can take any amount of parameters.

Subroutines are 'expanded' at runtime.

DIFFERENCE B/W SUBROUTINES & FUNCTION MODULE

SUBROUTINES: The name of a SUBROUTINE must be unique within the program (two programs can have different SUBROUTINEs with the same name). A SUBROUTINE is intended to be called internal (from within the program, however by a 'trick' you can call them external). FUNCTION MODULE: The name of a FUNCTION has to be unique throughout the system. A FUNCTION is intended to be called external (and is thus shared by 'many' programs). The latter is more important for programmers and maintenance. Since a FUNCTION is called external, it is important to keep the interface (parameters) the same. The interface of a FORM (which is intended to be called internal) is check when debugging a program (but it is only checked within the program that is debugged). So if the interface of a FORM is changed, but the call to the FORM (perform ) is not, the debugger will notice this and issue an error message.

DIFFERENCE B/W FUNCTION MODULE & INCLUDE

Function Module :Function Modules are stored in the central library and can be called from any program. Even the function modules(RFC enabled) can be called from non-SAP systems. Include:Include programs allow you to use the same source code in different programs. They are mainly used for modularizing source code and have no parameter interface.

DIFFERENCE B/W INCLUDE & METHODS


INCLUDE: If I am defining the same variables in many programs, instead of defining in all programs we have define all the variables in one program and that program is included or added to the programs whenever needed thats called include program. It cannot be executed independently it has to include in a program. METHODS:It describes the functions and behavior of classes and

their instances in ABAP objects methods must be defined in classes.

WHY WE ARE USING MACROS?


If we want to reuse same set of statements more than once in program , we can include them in a macros. Ex: statements like write, clear, form calls, and DB statements such as SELECT and UPDATE.

WHAT IS THE SYNTAX OF MACROS?


DEFINE <macro name>. ... END-OF-DEFINITION.

DEMO PROGRAM-1
Program Name: ZPW_MACRO1 DEFINE print. write:/ 'Hello Macro'. END-OF-DEFINITION. WRITE:/ 'Before Using Macro'. print.

OutPut :

DEMO PROGRAM-2
Program Name: DEFINE print. write:/ 'Hello', &1, &2. END-OF-DEFINITION. WRITE:/ 'Before Using Macro'. print 'ABAP' 'Macros'.

Output:

WHAT ARE THE LIMITATIONS OF MACROS?


We can use macros with in the program in which it is defined.(Prog Name: zpw_macro1) Macros definition should occur before the macro is used in the program.(Prog.Name:zpw_macro2) We can pass up to 9 place holders to macros. Macros can be useful for long Calculations or complex write

statements:-(Prog. Name :zpw_macro3)

Other than readability and meaning fulness macros also offer Performance Advantage.(Prog. Name:ZPW_MACRO4). We cant call this macro from another program,But you can call global macros from another program. http://saptechnical.com/Tips/ABAP/GlobalMacros/Define.htm

DIFFERENT WAYS OF USING MACROS?


Data Declaration Complex write statement Reading or changing variable values Formulas / calculations Nesting macros Program flexibility

Working with heavy data.(Prog.Name:zpw_macro5)

Most Popular Example of System Macros or Standard global macros is BREAK. Which is defined in table TRMAC

PROS AND CONS OF MACROS


Pros: Macro is faster than other modularization techniques ex. sub-routines (http://sapabap-tricks.blogspot.in/2011/10/macro.html)

Program Name:zpw_macro7,8,9,10

Cons: Macros can't be debugged. Hence, complex code should not be written inside macros

PROS AND CONS OF SUBROUTINE


PROs Reducing duplicate code within a program Enabling reuse of code across multiple programs Dividing a large programming task among various programmers, or various stages of a project Hiding implementation details from users of the subroutine Improving traceability, CONS:

Exceptions cannot be handled by subroutines. .(Prog.Name:ZPW_SUBROUTINE)

PROS AND CONS OF FUNCTION MODULE


PROS: it is one of the modularization techniques which helps code reusability. We can handle exceptions using function modules. CONS: Using FM we can Communicate With in SAP Systems Only

PROS AND CONS OF INCLUDE


PROS: Good Readability.

CONS: An include program cannot run independently, but must be built into other programs.

Include programs can contain other includes.


The only restrictions for writing the source code of include programs are: Include programs cannot call themselves. Include programs must contain complete statements. The INCLUDE statement has the same effect as copying the source code of the include program into the

program. In the syntax check, the contents of the include program are also analyzed. Include programs are not

loaded at runtime, but are expanded when the program is generated. Once the program has been generated, the
load version contains static versions of all of its includes. If you subsequently change an include program, the programs that use it are automatically regenerated.(PROG. NAME:ZPW_INCULDE)

PROS AND CONS OF METHODS


PROS: CONS:

You might also like