Application Development 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: 

Creating Function module

Former Member
0 Kudos

Hi can anybody give me the steps to create a function module.

thanks in advance

KP

7 REPLIES 7

Former Member
0 Kudos

HI KP,

go to SE37.

In the menu..GOTO -> FUNCTION GROUPS -> CREATE GROUP.

Give the function group name as z_group_name ..give the description..

( function modules are grouped together which r related to one project or object to pass the data )

Save.

create a FM with z_name in se37 initial screen

go to <b>Import</b> Parameter tab.

provide details:

<b>parameter type Associated type default

a type i 10

b type i 20</b>

go to <b>export</b> tab.

<b>parameter type Associated type

res type i</b>

go to <b>source code</b> tab.

<b>write res = a + b.</b>

save , activate and execute...

this is simple program to build FM.

according to ur requirement u can explore urself

Regards

SAB

Former Member
0 Kudos

Hi,

1)

First create a function group..

go to se37..

In the menu..GOTO -> FUNCTION GROUPS -> CREATE GROUP.

Give the function group name Ex: Z_TEST_FGROUP ..And then give the description..

Save.

2) FM creation..

Go to SE37.

Give the function module name..Example. Z_TEST_FM.

Press create..

Give the FUnction group name..And then description..

In the import parameters tab, give the input parameters.

Exa. P_MATNR TYPE MATNR

In th exporting parameters tab, give the output parameters..

Ex: S_MARA TYPE MARA.

In the exceptions tab, give the list of exceptions.

EX: NO_MATERIAL_FOUND Material not found.

In the source code tabl. Use the INput parameter to get the value and place in the output parameters.

Ex:

SELECT SINGLE * FROM MARA

INTO S_MARA " output parameter

WHERE MATNR = P_MATNR . " Input parameter.

IF SY-SUBRC <> 0.

RAISE NO_MATERIAL_FOUND. " Exception..

ENDIF.

Thanks

Naren

former_member187255
Active Contributor
0 Kudos

check this...<a href="http://help.sap.com/saphelp_nw04/helpdata/en/26/64f623fa8911d386e70000e82011b8/content.htm">Creating a Function module</a>

Former Member
0 Kudos

HI,

first a function griup is to be created and thena function module..

below is the link which is self_explanatory..

http://help.sap.com/saphelp_nw04/helpdata/en/26/64f623fa8911d386e70000e82011b8/content.htm

hope this helps u a bit,

all the best,

regards,

sampath

  • mark helpful answers

Former Member
0 Kudos

Hi KP,

1) Documentation

The documentation describes the purpose of the function module, lists the parameters

for passing data to and from the module, and the exceptions. It tells you how you can

pass data to and from the function module, and which errors it handles.

2) Interface parameters and exceptions

This section provides further information about the interface parameters and exceptions,

and how to use the function module. For further information, refer to Displaying

Information about Interface Parameters [Ext.] in the ABAP Workbench documentation.

Function modules can have the following interface parameters:

3) 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.

4) 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.

5) 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.

6) Tables parameters. You use these to pass internal tables. They are treated like CHANGING

parameters. However, you can also pass internal tables with other parameters if you specify

the parameter type appropriately.

You can use the EXCEPTIONS option to handle the exceptions of the function module. If an

exception <ei> is raised while the function module is running, the system terminates the function

module and does not pass any values from the function module to the program, except those that

were passed by reference. If <ei> is specified in the EXCEPTION option, the calling program

handles the exception by assigning <ri> to SY-SUBRC. <ri> must be a numeric literal.

If you specify of ERROR_MESSAGE in the exception list you can influence the message

handling of function modules. Normally, you should only call messages in function modules using

the MESSAGE ... RAISING statement. With ERROR_MESSAGE you can force the system to

treat messages that are called without the RAISING option in a function module as follows:

Messages of classes S, I, and W are ignored (but written to the log in a background job).

Messages of classes E and A stop the function module as if the exception

ERROR_MESSAGE had occurred (SY-SUBRC is set to <rE>).

If you specify OTHERS after EXCEPTIONS, the system assigns a single return code to all other

exceptions that you have not specified explicitly in the list.

You can use the same number <ri> for several exceptions.

Regards

Sreeni

Former Member
0 Kudos

Hi,

Please make sure to reward points for helpful answers. And close the thread if the question is answered.

Thanks

Naren