Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to write function modules

Former Member
0 Likes
599

I m a beginner in ABAP .Any one please help me with some tutorials with minimum theory on how to write simple function modules?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
570

Function modules are special external subroutines(program type F)

Function modules are classified in function groups and stored in the Function Library. Function groups act as containers for function modules that logically belong together.

Function modules allow us to encapsulate and reuse global functions in the R/3 System.

Function modules also play an important role in database updates and in remote communications between R/3 Systems or between an R/3 System and a non-SAP system.

The R/3 System provides numerous predefined function modules that we can call from your ABAP/4 programs. We can also create your own function modules using Function Builder. (Transaction Code SE 37)

Function groups are containers for function modules.

We cannot execute a function group. When we call a function module, the system loads the whole of its function group into the internal session of the calling program (if it has not already been loaded).

Function group names are freely definable up to a maximum length of 26 alphanumeric characters.

When we create a function group or function module in the Function Builder , the main program and include programs are generated automatically.

New function groups can be created from the menu Goto - Function Group - Create

To program a function module, we must include our statements between the FUNCTION and ENDFUNCTION statements as follows:

Syntax : FUNCTION <module>

<statements>

ENDFUNCTION

An existing Function Module can be inserted into ABAP Code using Edit - Pattern

components of fm:

Import: Values transferred from the calling program to the function module.You cannot

overwrite the contents of import parameters at runtime.

Export: Values transferred from the function module back to the calling program

Changing :Values that act as import and export parameters simultaneously. The original

value of a changing parameter is transferred from the calling program to the function module.

The function module can alter the initial value and send it back to the calling program.

Tables: Internal tables that can be imported and exported. The internal table's contents are transferred from the calling program to the function module. The function module can alter the contents of the internal table and then send it back to the calling program. Tables are always passed by reference.

Exceptions:Error situations that can occur within the function module. The calling program uses exceptions to find out if an error has occurred in the

function module. It can then react accordingly.

CREATING FM:

Check whether a suitable function module already exists.

If not, create one as follows.

Create a function group, if no appropriate group exists yet.

Create the function module.

Define the function module interface by entering its parameters and

exceptions.

Write the actual ABAP code for the function module, adding any relevant

global data to the TOP include.

Activate the module.

Test the module.

Document the module and its parameters for other users.

Release the module for general use.

The Function Builder allows us to create, test, and administer function modules in an integrated environment.

HOPE IT IS USEFUL.

REGARDS,

SREELAKSHMI.

4 REPLIES 4
Read only

amit_khare
Active Contributor
Read only

Former Member
0 Likes
570

check ABAPDOCU for more details...

Read only

Former Member
0 Likes
571

Function modules are special external subroutines(program type F)

Function modules are classified in function groups and stored in the Function Library. Function groups act as containers for function modules that logically belong together.

Function modules allow us to encapsulate and reuse global functions in the R/3 System.

Function modules also play an important role in database updates and in remote communications between R/3 Systems or between an R/3 System and a non-SAP system.

The R/3 System provides numerous predefined function modules that we can call from your ABAP/4 programs. We can also create your own function modules using Function Builder. (Transaction Code SE 37)

Function groups are containers for function modules.

We cannot execute a function group. When we call a function module, the system loads the whole of its function group into the internal session of the calling program (if it has not already been loaded).

Function group names are freely definable up to a maximum length of 26 alphanumeric characters.

When we create a function group or function module in the Function Builder , the main program and include programs are generated automatically.

New function groups can be created from the menu Goto - Function Group - Create

To program a function module, we must include our statements between the FUNCTION and ENDFUNCTION statements as follows:

Syntax : FUNCTION <module>

<statements>

ENDFUNCTION

An existing Function Module can be inserted into ABAP Code using Edit - Pattern

components of fm:

Import: Values transferred from the calling program to the function module.You cannot

overwrite the contents of import parameters at runtime.

Export: Values transferred from the function module back to the calling program

Changing :Values that act as import and export parameters simultaneously. The original

value of a changing parameter is transferred from the calling program to the function module.

The function module can alter the initial value and send it back to the calling program.

Tables: Internal tables that can be imported and exported. The internal table's contents are transferred from the calling program to the function module. The function module can alter the contents of the internal table and then send it back to the calling program. Tables are always passed by reference.

Exceptions:Error situations that can occur within the function module. The calling program uses exceptions to find out if an error has occurred in the

function module. It can then react accordingly.

CREATING FM:

Check whether a suitable function module already exists.

If not, create one as follows.

Create a function group, if no appropriate group exists yet.

Create the function module.

Define the function module interface by entering its parameters and

exceptions.

Write the actual ABAP code for the function module, adding any relevant

global data to the TOP include.

Activate the module.

Test the module.

Document the module and its parameters for other users.

Release the module for general use.

The Function Builder allows us to create, test, and administer function modules in an integrated environment.

HOPE IT IS USEFUL.

REGARDS,

SREELAKSHMI.

Read only

Former Member
0 Likes
570

hi

good

see this link for function modules creation.

http://help.sap.com/saphelp_nw70/helpdata/en/9f/db98fc35c111d1829f0000e829fbfe/content.htm

for internal tables and work areas.

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3660358411d1829f0000e829fbfe/content.htm

<REMOVED BY MODERATOR>

thanks

mrutyun^

Edited by: Alvaro Tejada Galindo on Feb 21, 2008 11:14 AM