WhatsApp Button




top of page
Writer's pictureIshnoor Singh Sethi

Fast - Track Your MODULARISATION TECHNIQUES in ABAP

Updated: May 31, 2022


MODULARISATION TECHNIQUES


Modularisation is a technique used to divide the application program into smaller units to maintain easily and reduce the code redundancy. The identical logic coded in many places (either in the same program or in multiple programs) called as a redundandant code. It also improves performance of the code.

Advantages of Modularisation Techniques—>


  • Easy to read and understood

  • Easy to maintain

  • Easy to debug

  • Eliminates code redundancy

  • Increases reusability of code


Types of Modularisation techniques—>

  1. SUBROUTINE

  2. INCLUDE

  3. FUNCTION MODULE

  4. MACRO

NOTE-->

1. As an ABAP consultant we don’t use MACRO as this is to be used by HR Consultants


1. SUBROUTINE—> Subroutines are procedures that can define in any program and call from any ABAP program. Subroutines normally contains sections code or algorithms.

Subroutines can be defined anywhere in the program and no restriction on where to define. Subroutines can be defined using FORM and ENDFORM statements.

PERFORM statement used to call the subroutine. PERFORM and FORM must contain the same number of parameters.

Let us take an example program and below diagram explains how the program look like before and after subroutine implementation—



Program has the same statements block in three places which is redundant code. It also increases the complexity of the program.

The below diagram shows the same program after subroutines implementation -



In the above diagram, subroutine-1 is the subroutine definition and the code block is replaced with calling subroutine-1 in all the places.


NOTE--> We should not write the declaration part inside of the subroutine


SYNTAX—>


PERFORM PERFORM_NAME.


FORM FORM_NAME.

CODING.

ENDFORM.


We don’t need to write this syntax manually as the system will automatically write the code for us just by writing the PERFORM statement.


Steps to create a SUBROUTINE—>


1. Write PERFORM statement.




2. Double click on PERFORM_NAME and then click on YES.



3. Now select the program line in which program you have written the PERFORM statement and click on the tick radio button.



4. SUBROUTINE is created successfully.


CODING SCREEN BEFORE APPLYING SUBROUTINE—>



OUPUT SCREEN BEFORE APPLYING SUBROUTINE—>



INPUT AFTER APPLYING SUBROUTINE—>



OUTPUT AFTER APPLYING SUBROUTINE—>




2. INCLUDE—> If same set of statements (source code) used in more than one program, those statements can add to the include program. Include programs is available to all the programs and used in any program.


Include programs are only used to modularise the source code but have no parameter interface. Include programs are not standalone programs and cannot be executed independently.

Include programs available globally and can use in any ABAP program. Include program contains small piece of source code that can be included in a program with an INCLUDE statement.

INCLUDE statement is responsible for copying the include program source code to the main program during the runtime. Include programs can’t call themselves. Include program must be syntax error free and contain complete statements.


We can do declarations in INCLUDE as they are only the subprograms to be used in any ABAP code.

CONVENTION—> INCLUDE name should always start with either ‘y’ or ‘z’.

SYNTAX—>


INCLUDE ZINCLUDE_NAME.


NOTE--> We can write the declaration part inside of a INCLUDE.


STEPS TO CREATE A INCLUDE SUB PROGRAM—>


1. Write INCLUDE statement.



2. Double click on the ZINCLUDE_NAME part and click on yes.



3. The INCLUDE Sub-program is created and you can write the code there.



CODING SCREEN WITHOUT USING INCLUDES—>



OUTPUT SCREEN WITHOUT USING INCLUDE—>



CODING SCREENS USING INCLUDE—>



INSIDE ZDECLARE_INFO—> To declare the structure, internal table and work area.



INSIDE ZGET_INFO—> To get desired information from the database table.




INSIDE ZDISPLAY_INFO—> To display the data.



An error will come in DISPLAY FUNCTION inside INCLUDE statement.

To remove this error we have to use a keyword

‘END-OF-SELECTION’ at the top of the INCLUDE sub-program.



CORRECTED CODING SCREEN FOR ZDISPLAY_INFO—>



NOTE—> We always have to save, check and activate the INCLUDE Sub-program and will not execute it from there. Execution will only be done from master program.


OUTPUT—>



3. FUNCTION MODULE—> Function modules are sub programs that contains set of reusable source code statements with importing, exporting parameters and exceptions. Function modules are stored in central library.

Function modules available to the entire system. Function modules can execute independently. If the source code is only used within the same program, then use a Subroutine. Otherwise a function module is preferred.

Every function module is a part of function group. The function group acts as a container for function modules that would logically belong together. Function modules plays significant role in updating the databases.


Types of FUNCTION MODULES—>

  1. Normal Module

  2. Remote Enable Module (RFC)

  3. Update Function Module (not in use now)


Components of Function Module—>

  • Import - Input parameters of a Function Module.

  • Export - Output parameters of a Function Module.

  • Changing - Specifies the parameters act as importing and exporting parameters to a Function Module.


Steps to create a FUNCTION MODULE—>

In the below example I have created a function module in which we enter a material number and will get the information for that material number.

1. Create a function group using transaction code se80.



2. Create a function module using transaction code se37.



3. On the import tab write the requirements for importing parameters.



4. On the export tab write the requirements for exporting parameters.


5. Write the condition in the source code tab.




OUTPUT SCREENS—>



After executing the program click on the circled button to get the following output screen.


CALLING FUNCTION MODULE IN ABAP PROGRAM—>

1. Click on PATTERN option.


2. Select CALL FUNCTION radio button and type the FUNCTION MODULE as per requirement.



3. Remove commenting by selecting the statements and pressing ctrl + > .




4. Write code to display data.



OUTPUT SCREENS—>



After executing the program click on the circled button to get the following output screen.







ISHNOOR SINGH SETHI

1,482 views2 comments

Recent Posts

See All

2 則留言


CBKM BOCU
CBKM BOCU
11月11日

EPS Machine EPS Cutting…

EPS Machine Eps Raw…

EPS Machine EPS Recycling…

EPS Machine EPS Mould;

EPS Machine EPS Block…

EPP Machine EPP Shape…

EPTU Machine ETPU Moulding…

EPS Machine Aging Silo…

EPTU Machine ETPU Moulding…

EPS Machine EPS and…

EPS Machine EPS and…

AEON MINING AEON MINING

AEON MINING AEON MINING

KSD Miner KSD Miner

KSD Miner KSD Miner

BCH Miner BCH Miner

BCH Miner BCH Miner

按讚

CBKM BOCU
CBKM BOCU
11月11日

EPS Machine EPS Cutting…

EPS Machine Eps Raw…

EPS Machine EPS Recycling…

EPS Machine EPS Mould;

EPS Machine EPS Block…

EPP Machine EPP Shape…

EPTU Machine ETPU Moulding…

EPS Machine Aging Silo…

EPTU Machine ETPU Moulding…

EPS Machine EPS and…

EPS Machine EPS and…

AEON MINING AEON MINING

AEON MINING AEON MINING

KSD Miner KSD Miner

KSD Miner KSD Miner

BCH Miner BCH Miner

BCH Miner BCH Miner

按讚
bottom of page