function module in sap abap

Function Module in SAP ABAP

function module in sap abap

It is a set of statements which are defined only once and can be called any no. of times. We can create custom function modules by using function builder tool (SE37).

There are many standard function modules provided by SAP itself. Each Function Module is designed to perform a task. These function modules can be called/accessed in different programs by passing values to the appropriate parameters.

Function modules (custom/standard) are stored inside function group.

Function group is a container of function modules.

Table for function module-> TFDIR (accessed from SE11)

Table for repository objects (executable, include, subroutine pool…) -à TADIR

Table for SAP Tables à DD02L

Function group:

Before creating custom function module, we need to create or consider a function group which already exists.

Function group can be created either by SE80 (object navigator) / SE37.

In SE37, choose the menu ‘GOTO’ à function groups à create group

Whenever a function group is created, SAP creates two include programs.

A.    Include ending with ‘TOP’:

This is called as top include program, which can be used for declaring global variables, subroutine, module definitions and class definitions.
The components of the ‘top’ include program can be accessed by all the function modules of that particular function group.

B.     Include ending with ‘UXX’

It is reserved for SAP internal use. As part of this include, SAP generates sub includes (i.e), whenever a new function module is created, a sub include will be generated on behalf of that function module.
The no of sub includes depends upon the no. of function modules of that function group.

Syntax for defining function module:

Function   <function name>.
Statements.
Endfunction.

Syntax for calling normal function module:

Call function   <function name>  <parameter list>.
Before calling any function module, we must check the signature of the function module to understand the parameter types, return values, default values, pass by value or pass by reference, optional and mandatory parameters.

As part of function modules we have 4 types of parameters:

1.     Import
2.     Export
3.     Tables
4.     Changing

Import parameters:

Are the parameters which are received by the function module.

Export parameters:

Are the parameters which are returned by the function module.

Export parameters are always optional.

Changing parameters:

Acts as both import and export,  we go for changing parameters when we need to use same variable for passing the value as well as receiving the return value.

Tables:

Are used for dealing with internal tables as parameters to function modules , these internal tables must refer to dictionary structures created in se11.

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

2 Comments