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

activate/implement function module

Former Member
0 Likes
3,807

Hi,

How to activate/implement function module?

Thx.

Anirudh,

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,159

Run transaction SE37 & open the Function Module , activate it.

If you want to use it in your program, then Goto SE38 , open the program & click on PATTERN & type the FUnction module name.

6 REPLIES 6
Read only

Former Member
0 Likes
2,160

Run transaction SE37 & open the Function Module , activate it.

If you want to use it in your program, then Goto SE38 , open the program & click on PATTERN & type the FUnction module name.

Read only

Former Member
0 Likes
2,159

Creating a Function module

Use

Function modules are ABAP routines that are administered in a central function library. They apply across applications and are available throughout the system. You must assign function modules to a function pool that is called a function group. A function group is nothing but a container for the function modules. Now create a function group and then a function module, which you can use for the next exercise steps.

Procedure

Create a Function Group:

To open the Object Navigator choose from the SAP Menu Overview ® Object Navigator.

From the Object Selection window select Function group, enter FG_Tutorial as name of your function group, and choose Display.

Since the function group FG_Tutorial does not yet exist, the system asks you whether to create it. Confirm with Yes.

Enter a short description and choose Save.

In the window Create Object Catalog Entry choose Local object.

You created a local function group. Before it can receive function modules, you must activate it.

In the object list, use the right mouse button to select the function group FG_Tutorial you just created and choose Activate.

On the next screen choose Continue.

The function group is now active.

Create Global Data:

Within the function group you can declare global data. All function modules of this function group share this global data.

In the Object Selection window open the directory tree Includes and double-click on LFG_TutorialTOP.

Choose Create « Change ( STRG+F1 ) and enter the following data declarations in the tool area:

TABLES spfli.

DATA spfli_workarea LIKE spfli.

Check ( STRGF2 ) and activate ( STRGF3 ) the include file.

Create a Function Module:

Create a function module that reads data from table SPFLI .

If you are not yet in the Object Navigator, choose from the SAP Menu Overview à Object Navigator and display the function group FG_Tutorial .

In the Object selection window, use the right mouse button to select function group FG_Tutorial , and choose Create à Function module.

Enter as function module name XX_RFC_READ_SPFLI and replace XX with the initials of your name.

Enter a short description and choose Save.

The system lists the function module in the object list in a new directory Function modules, and displays it on the right side in the Function Builder.

Select the Attributes tab and under Processing type choose Remote-enabled module.

Select the Import tab and enter in the appropriate columns the names of the import parameters: carrid with reference type like spfli-carrid and connid with reference type like spfli-connid . For each parameter set the Pass value flag.

Select the Export tab and enter in the appropriate columns the names of the export parameters: ex_spfli with reference type like spfli and sys with reference type like sy-sysid . For each parameter set the Pass value flag.

Select the Exceptions tab and enter the exception invalid_data .

Select the Source code tab.

The system copies the entries you made in the other tabs and creates a source text.

Complete the function module with the actual flight data retrieval.

Compare your function with the model solution.

Save the function module ( STRG+S ). When the note on remote-enabled function modules appears, choose Continue.

Check the function for errors ( STRGF2 ) and then activate it ( STRGF3 ).

Test the Function Module:

Choose Test/Execute ( F8 ) or Function module à Test à Test function module.

As import parameter for CARRID enter LH ; for CONNID enter 400 . Leave the RFC target system line empty.

Choose Execute ( F8 ).

The system displays the export parameters EX_SPFLI and SYS in an additional table.

For a detailed display of the data select the value in line EX_SPFLI.

Result

You created a function module and assigned it to a function group.

Regards,

Sankar

Read only

Former Member
0 Likes
2,159

Hi,

You can use transaction SE37 to create and display function module

For creating new function module ..check this link

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

Thanks,

rewards point.

Read only

Former Member
0 Likes
2,159

hi,

http://help.sap.com/saphelp_nw2004s/helpdata/en/43/41341147041806e10000000a1553f6/frameset.htm

Function Modules are Global ABAP programs created by SAP for reusable purpose. They have IMPORT, EXPORT and TABLE parameters, and EXCEPTIONS to through when error occurs.

You can create them from TCode SE37.

Go through the following doc:

Function modules are cross-program, reusable procedures that are organized into function groups, and whose functions are implemented between the statements FUNCTION and ENDFUNCTION. Function modules and their interfaces are created in the Function Builder.

Function Module Interfaces

The parameter interface of a function module is defined in the Function Builder. It includes the definition of interface parameters and the specification of exceptions that can be triggered by a function module. The Function Builder automatically generates comment lines below the FUNCTION statement in the source code of the function module, which represent the interface of the function module with the following syntax:

Syntax

... [IMPORTING parameters]

[EXPORTING parameters]

[CHANGING parameters]

[TABLES table_parameters]

[{RAISING|EXCEPTIONS} exc1 exc2 ...]

The syntax and semantics of IMPORTING, EXPORTING, CHANGING, RAISING, and EXCEPTIONS mainly correspond to the definition of method interfaces with [CLASS-]METHODS. The additional option of defining table parameters using TABLES is obsolete.

Interface parameters

The interface parameters are defined on the relevant tab pages in the Function Builder.

IMPORTING parameters are input parameters. When the function module is called, a suitable actual parameter must be specified for every non-optional input parameter. The content of the actual parameter is passed to the input parameter when the call is made. The content of an input parameter for which 'pass by reference' is defined cannot be changed in the function module.

EXPORTING parameters are output parameters. When the function module is called, a suitable actual parameter can be specified for every output parameter. The content of an output parameter that is defined for 'pass by value' is transferred to the actual parameter if the function module is completed without errors. An output parameter that is defined for pass by reference is not initialized when the function module is called.

CHANGING parameters are input and output parameters. When the function module is called, a suitable actual parameter must be specified for every non-optional input or output parameter. When the function module is called, the content of the actual parameter is passed to the input/output parameter, and when the function module is completed, the content of the input/output parameter is passed to the actual parameter.

TABLES parameters are table parameters. Table parameters are obsolete CHANGING parameters that are typed as standard tables with a header line. If an internal table without a header line or a table body is passed as an actual parameter to a formal parameter of this type, an empty local header line is generated in the function module. If an internal table with a header line is used as an actual parameter, both the table body and the header line are passed to the function module. Pass by value is not possible in formal parameters defined using TABLES. Formal parameters defined with TABLES can be replaced by formal parameters defined with CHANGING. A local work area can be created for the internal table in the function module by using the addition LIKE LINE OF itab of the DATA statement.

Exceptions

The exceptions of a function module are defined on the Exceptions tab page in the Function Builder. Here you can select exception classes to define whether class-based exceptions are declared or non-class-based exception is defined. Class-based exceptions are represented in the above syntax by RAISING, and non-class-based exceptions are represented by EXCEPTIONS.

CALLING A FUNCTION MODULE:

1)In U ABAP Editor --> Click "Patter" ---> Selection Option Button "Call Function"

--> Write the Corresponding FM name --> Hit Enter

2)The appropriate import ,export Parameters will be displayed in ur editor

3)Pass the Values Here.

Check this link:

http://help.sap.com/saphelp_erp2004/helpdata/en/9f/db988735c111d1829f0000e829fbfe/content.htm

http://help.sap.com/saphelp_nw2004s/helpdata/en/ef/d94b78ebf811d295b100a0c94260a5/frameset.htm

http://help.sap.com/saphelp_nw2004s/helpdata/en/43/41341147041806e10000000a1553f6/frameset.htm

regards,

rewards point.

Read only

Former Member
0 Likes
2,159

Hi Anirudh,

To activate Function Module first Activate Function Group.

To Activate Function Group

go to se37 then GOTO >Function Group>Display and then Activate it.

And after activating it Open function Module from SE37 and Activate it.

Reward if useful,

Sachin.

Read only

Former Member
0 Likes
2,159

<b>For activation</b>

Goto transaction SE37

|

open the Function Module

|

activate it.

<b>For Usage</b>

then Goto SE38

|

open the program

|

click on PATTERN

|

type the Function module name.

|

Give the Import and Export parameters

regards,

srinivas

<b>*reward for useful answers*</b>