Modularization Techniques
Modularization Techniques are used to modularize a code, which
helps to improve code maintenance and readability.
Various Techniques in Modularization techniques are:
Include program/Includes.
Function Module
Subroutines
Class-Methods.
Include Programs
Include Programs is a modularization technique. We use Include
Programs to organize a program in to smaller units.
We can create include programs with the help of SE38(ABAP Editor).
The type of include programs are “I”.
We cannot execute a include program directly.
The main purpose of include programs is for lengthy data
declarations used in different programs.
The syntax to use a include program into another type of programs
is -
INCUDE <include program name>.
Function Modules
It is a modularization technique.
The transaction code to create a FM is SE37.
To create a function module, first we need to create a function
group, and then we have to assign the function module in the
function group.
A function group acts like a container for the function modules.
The transaction to create a function group is SE80.
A function group can store up to 99 function modules.
Demo –
We are creating a Function Group ZFG_61.
By default, two includes are available while creating a function group.
A TOP include, which acts as a global declaration for all the function
modules in the entire function group.
Another one is individual
This “XX” is the function group name index. For example, if we
create 4 function modules under the function group, the 4 includes
will be – LZFG_61U01, LZFG_61U02, LZFG_61U03, LZFG_61U04.
After Creating a function Group, don’t forget to activate the function
group. If we don’t activate the function group, the at the time of assigning
the function module we will get an error.
Let’s create a function module,
It’s our first function module, that’s why the name is LZFD_U01.
Tabs of Function Module -
The Various tabs of function module are as follows:
Attributes – It provides the generic information about the function
module like – date, username, function group, package name etc.
Import – Input parameters of the function module.
Export – Output parameter of the function module.
Changing – Changing can act as both input or output parameters.
Tables – tables are for internal tables.
Exceptions – This tab is used to raise the exception/error.
Source Code – The purpose of this tab is to write logic.
Practical -
YFM_SALESORDER. – Display single sales order record
ZSTR_SALES_ORDER_DETAILS – Structure
ZTSTR_SALES_ORDER_DETAILS – line type
ZRPG_SALESORDER_DETAILS – demo report to call YFM_SALESORDER.
YFM_MULTIPLE_SALESORDER - Display Multiple sales order record
We will use the concept. ‘SELECT-OPTION’ is an internal table with
header line concept.
Sign
Option
Low
High
By default, passing multiple sales order passing option is not available. We
will create a separate structure for passing the multiple sales order to
make it as a select-option.
Now, SELECT-OPTION is an internal table with header line. That means we
have to declare a Table-Type also, based on this structure.
Rest, complete logic we have copied from Function module
YFM_SALESORDER.
To execute this... double click on the select-option internal table.
Click on “back”.
Now, input has been added in the form of an internal table i.e. a SELECT-
OPTION.
Now execute this.
ZRPG_MULTIPLE_SALESORDER – Report to run this FM.
RFC (Remote function call)
SAP technical objects are divided into 6 different areas (RICEFW)
R – Reports
I – Interfaces
C – Conversion
E – Enhancements
F – Forms
W – Workflow
SAP cross applications are the part of the interfaces which helps to
transfer the data between the system.
With the help of cross applications, we can transfer the data from
Non-SAP to SAP, SAP to Non-SAP, SAP to SAP.
The various cross applications are –
BAPI,
RFC,
IDOC’s (ALE, EDI) ... etc
RFC stands for Remote Function Call.
As the name is suggesting, with the help of RFC we can connect
with the external system, the external system can be SAP or Non-
SAP system.
In all SAP system, CALL FUNCTION represents an integral part of
ABAP language. The statement CALL FUNCTION executes a function
module in the same system.
RFC is an extension of CALL FUNCTION in a distributed environment.
Existing function modules can be executed using an RFC from a
remote system.
This is done by adding a DESTINATION clause to the CALL FUNCTION
statement.
Syntax – CALL FUNCTION ‘ZFM_ORDER’ DESTINATION ‘A4H’.
In the above syntax, CALL FUNCTION – Keyword,
ZFM_ORDER – Name of the function module,
DESTINATION – Keyword,
A4H – Name of the SOURCE system in which function
module is created.
Difference between BAPI and RFC
BAPI – RFC function module + Business Object.
The external system connects with the business object and that
business object calls the RFC function module.
Whereas in the case of RFC, external system directly connects with
the RFC function module.
BAPI is based upon OOPS concept,
Whereas RFC doesn’t follow OOPS concept.
Pre-requisites for creating an RFC
RFC function module is just like any other function module created
in SE37, with some specific pre-requisites.
1. The processing type of the function module should be remote-
enabled module.
2. All parameters must be pass by value.
This “Remote-Enabled Module” checkbox should be checked. Otherwise it
won’t be available in other systems.