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

function module

Former Member
0 Likes
882

hi...

i want to know the detail notes about the function module

10 REPLIES 10
Read only

former_member195383
Active Contributor
0 Likes
855

Hi...

Search in SDN as Function Module...U will get a lot of material....

Function module is a block of code that can be called from another program...It takes some values...and returns..required values or tables...

It increases modularisation and reusability in a program....

Read only

Former Member
0 Likes
855

Hi Baskaran,

Below description gives you a detail idea of what a function module is!

Overview

--General purpose ABAP/4 routines that anyone can use.

--Large Number of standard function Modules.

--Organized into Function Groups: Collections of logically related functions.

--A Function Module is always associated with a Function Group.

--Transaction SE37.

--Called Using u201CCall Function u201D in ABAP/4 program.

Information Associated with Function Module

--Administration

--Import/Changing/Export parameters.

--Table Parameters/Exceptions.

--Documentation

--Source code u2013 L

*Contains the list of all the include files for that function group

Import parameters. These must be supplied with data when you call the function module, unless they are flagged as optional. You cannot change them in the function module.

Export parameters. These pass data from the function module back to the calling program. Export parameters are always optional. You do not have to receive them in your program.

Changing parameters. These must be supplied with data when you call the function module, unless they are flagged as optional. They can be changed in the function module. The changed values are then returned to the calling program.

To call a function module, use the CALL FUNCTION statement:

CALL FUNCTION

    EXPORTING  f1 = a 1.... f n = a n

    IMPORTING  f1 = a 1.... f n = a n

    CHANGING   f1 = a 1.... f n = a n

    TABLES     f1 = a 1.... f n = a n

    EXCEPTIONS e1 = r 1.... e n = r n ERROR_MESSAGE = r E

         OTHERS = ro.

When a Function Module is called from a Report the export parameters in the Report becomes the import Parameters in the Function Module and the import parameters in the report are the parameters that are exported by the the export parameters of the Function Module.

Calling subroutines

--Can be written at the end of function module in source code.

--Include program L is used for subroutines across function modules.

--Can call any number of external subroutines.

Raising Exceptions

--RAISE

Calling program handles the exception.

--SY-MSGID

--SY-MSGTY

--SY-MSGNO

--SY-MSGV1 to SY-MSGV4

If the system handles the exception

RAISE statement terminates the program and switches to debugging mode.

MESSAGE - RAISING displays a message and continues to according to message type.

Building New function Module

--Create a function Group (ZCAL).

--Create a function module, set the attributes and Save.

*Function group, Application, Short Text and Process Type

--Include file u201CLZCALU01u201D will have source code of first function module.

--Include file u201CLZCALTOPu201D will have global data.

--Main program u201CSAPLZCALu201D contains

  • Global data Include file u201CLZCALTOPu201D

  • Function modules include file u201CLZCALUXXu201D

*User defined Include files u201CLZCALF..u201D, u201CLZCALO..u201D and u201CLZCALI..u201D

--Define interface parameters and Exceptions

--Write the source code

--Activate Function Module

--Testing the Function Module

*Single Test & Debugging

--Documenting and Releasing a Function Module

Reward if useful.

Thankyou,

Regards.

Read only

Former Member
0 Likes
855

Refer the links -

Reward Points..

Read only

Former Member
0 Likes
855

hi

for creating Fm

http://www.saptechnical.com/Tutorials/ABAP/FunctionModule/page1.htm

Reward point if usefull

Cheers

Snehi

Read only

Former Member
0 Likes
855
Read only

Former Member
0 Likes
855

Hi!

Function Modules

Function modules are procedures that are defined in special ABAP programs only, so-called function groups, but can be called from all ABAP programs. Function groups act as containers for function modules that logically belong together. You create function groups and function modules in the ABAP Workbench using the Function Builder.

Function modules allow you to encapsulate and reuse global functions in the SAP System. They are managed in a central function library. The SAP System contains several predefined functions modules that can be called from any ABAP program. Function modules also play an important role during updating and in interaction between different SAP systems, or between SAP systems and remote systems through remote communications.

Unlike subroutines, you do not define function modules in the source code of your program. Instead, you use the Function Builder. The actual ABAP interface definition remains hidden from the programmer. You can define the input parameters of a function module as optional. You can also assign default values to them. Function modules also support exception handling. This allows you to catch certain errors while the function module is running. You can test function modules without having to include them in a program using the Function Builder.

The Function Builder also has a release process for function modules. This ensures that incompatible changes cannot be made to any function modules that have already been released. This applies particularly to the interface. Programs that use a released function module will not cease to work if the function module is changed.

For details chk this link:

http://help.sap.com/saphelp_nw70/helpdata/en/9f/db988735c111d1829f0000e829fbfe/frameset.htm

Rewrd if useful.

Read only

Former Member
0 Likes
855

Bhaskaran,

Kindly search on SDN by giving apropriate term in search box before throwing a thread.Am sure you will get hundred of answers for same.

please close this thread.

Amit.

Read only

Former Member
0 Likes
855

\[removed by moderator as it was just a copy and paste answer of someone else's work without giving a source -- breaking our rules of engagement can lead to your account being banned\]

Edited by: Jan Stallkamp on Jun 23, 2008 11:02 AM

Read only

Former Member
0 Likes
855

hi go to the tcode se37--> give the funtion module name->choose * function module documentation* on the menu tool bar...or check these links..

http://www.erpgenie.com/abap/functions.htm

http://www.sap-img.com/abap/function-list.htm

Read only

athavanraja
Active Contributor
0 Likes
855

baskaran,

since you are new here, did you go through this thread to understand the rules here

Raja