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: 

Regarding the Remote Function Module

Former Member
0 Kudos

hi,

Can any body can provide the brief information regarding the Remote Function Module.

1)How to create the remote function module

2)how it differ from the normal function module

3)any special features about this.

Thanks in advance

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Creation:

You create a RFC function module just as you create a normal function module.

After you create the function module, in the general tab of the function module select the "Remote Enabled" radio button which makes the function module as RFC function module.

Also the parameters should be Pass by value so select the "Pass value" check box against each of the parameters.

Last but not the least. RFC function modules cannot have exceptions, so define a return structure and pass all your messages like success, error etc. in the return structure.

After the function module is created, the RFC function moule can be called using the statement

CALL FUNCTION <FN Name> DESTINATION <RFC Dest>.

where RFC Dest it the remote destination created in SM59.

RFC (Remote Function Call) is similar to the general SAP fun module: except that in the attributes you click the radio button: RFC enabled;

and you will be passing an Import parameter DESTINATION to it.

Other code and usage will be similar to any fun module;

Have a look at any fun module in SE37 to understand better about the different components of Fun modules;

Refer this link:

http://help.sap.com/saphelp_nw04/helpdata/en/22/042518488911d189490000e829fbbd/frameset.htm

A Normal Function Module cant be called from external system. but a RFC(Remote Function) can be.

e.g. If I have a Lotus Notes sysytem interacting with my SAP system. Now, to access trhe data from SAP, Lotus Notes system has to call some functions in SAP. RFC is designed for that purpose only that an extrenal system can access SAP system.

Reward all helpful answres..

Regards,

Omkar.

5 REPLIES 5

Former Member
0 Kudos

Hi,

Creation:

You create a RFC function module just as you create a normal function module.

After you create the function module, in the general tab of the function module select the "Remote Enabled" radio button which makes the function module as RFC function module.

Also the parameters should be Pass by value so select the "Pass value" check box against each of the parameters.

Last but not the least. RFC function modules cannot have exceptions, so define a return structure and pass all your messages like success, error etc. in the return structure.

After the function module is created, the RFC function moule can be called using the statement

CALL FUNCTION <FN Name> DESTINATION <RFC Dest>.

where RFC Dest it the remote destination created in SM59.

RFC (Remote Function Call) is similar to the general SAP fun module: except that in the attributes you click the radio button: RFC enabled;

and you will be passing an Import parameter DESTINATION to it.

Other code and usage will be similar to any fun module;

Have a look at any fun module in SE37 to understand better about the different components of Fun modules;

Refer this link:

http://help.sap.com/saphelp_nw04/helpdata/en/22/042518488911d189490000e829fbbd/frameset.htm

A Normal Function Module cant be called from external system. but a RFC(Remote Function) can be.

e.g. If I have a Lotus Notes sysytem interacting with my SAP system. Now, to access trhe data from SAP, Lotus Notes system has to call some functions in SAP. RFC is designed for that purpose only that an extrenal system can access SAP system.

Reward all helpful answres..

Regards,

Omkar.

0 Kudos

Hi,

When you create a Function module there is an optin in the propterites tabto select Remote Enabled.

Then this can be called from an outside system.

There are ristrictions on the TYPEing of the paramters.

Regards,

Sesh

Former Member
0 Kudos

Hi

RFC (Remote Function Call) is similar to the general SAP fun module: except that in the attributes you click the radio button: RFC enabled;

and you will be passing an Import parameter DESTINATION to it.

Other code and usage will be similar to any fun module;

Have a look at any fun module in SE37 to understand better about the different components of Fun modules;

Refer this link:

http://help.sap.com/saphelp_nw04/helpdata/en/22/042518488911d189490000e829fbbd/frameset.htm

check out the following link it might help you

http://help.sap.com/printdocu/core/Print46c/de/data/pdf/BCFESDE2/BCFESDE2.pdf

Function Modules;

Check this matter.

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 exception 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 are defined. Class-based exceptions are represented in the above syntax by RAISING, and non-class-based exceptions are represented by EXCEPTIONS.

The addition RAISING is used to declare class-based exceptions that can be propagated from the function module to the caller. Exceptions in the categories CX_STATIC_CHECK and CX_DYNAMIC_CHECK must be explicitly declared, otherwise a propagation can lead to an interface violation. A violation of the interface leads to the treatable exception CX_SY_NO_HANDLER. Exceptions of the category CX_NO_CHECK are implicitly always declared. The declaration of exceptions of the category CX_STATIC_CHECK is statically checked in the syntax check. For exceptions of the category CX_DYNAMIC_CHECK, the check is not performed until runtime. In a function module in which class-based exceptions are declared with the RAISING addition, the statement CATCH SYSTEM-EXCEPTIONS cannot be used. Instead, the relevant treatable exceptions should be handled in a TRY control structure.

The addition EXCEPTIONS is used to define a list of non-class-based exceptions that can be triggered in the function module using the statements RAISE or MESSAGE RAISING. Exceptions defined in this way - as with formal parameters - are bound to the function module and cannot be propagated. If an exception of this type is triggered in a function module, and no return value has been assigned to it with the homonymous addition EXCEPTIONS of the CALL FUNCTION statement when the call was made, this leads to a runtime error.

Note

For new developments after release 6.10, SAP recommends that you work with class-based exceptions that are independent of the function module.

RFC is a technology which is used to access a functions (Modules) from

the remote systems.

If a function module is set as remote enabled which can be access from

the remote system via RFC.Eg: U can access the Remote enabled function modules in ur VB,Webdynpro,Java,Visual composer program.

A function module can be set as remote enabled by SE37->Go to ur FM->click the option Button "remote enabled".

But Normal function modules can not accessd from the remote system.

Good Example for RFC enabled function module is : BAPI(Business Application Programming Interface)

Note: All BAPIs are Remote enabled but not all remote enabled function modules are BAPI.

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.

Also check these links.

http://www.geocities.com/victorav15/sapr3/abapfun.html

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

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

See the following links:

http://help.sap.com/saphelp_erp2005vp/helpdata/en/9f/db970e35c111d1829f0000e829fbfe/frameset.htm

http://help.sap.com/saphelp_erp2005vp/helpdata/en/9f/db970e35c111d1829f0000e829fbfe/frameset.htm

http://help.sap.com/saphelp_erp2005vp/helpdata/en/9f/db970e35c111d1829f0000e829fbfe/frameset.htm

http://help.sap.com/saphelp_erp2005vp/helpdata/en/9f/db970e35c111d1829f0000e829fbfe/frameset.htm

http://help.sap.com/saphelp_erp2005vp/helpdata/en/9f/db970e35c111d1829f0000e829fbfe/frameset.htm

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

<b>Reward points for useful Answers</b>

Regards

Anji

Former Member
0 Kudos

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:



1.To open the Object Navigator choose from the SAP Menu Overview -> Object Navigator.
2.From the Object Selection window select Function group, enter FG_Tutorial as name of your function group, and choose Display.
3.Since the function group FG_Tutorial does not yet exist, the system asks you whether to create it. Confirm with Yes.
4.Enter a short description and choose Save.
In the window Create Object Catalog Entry choose Local object.
5.You created a local function group. Before it can receive function modules, you must activate it.

6.In the object list, use the right mouse button to select the function group FG_Tutorial you just created and choose Activate.
7.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.

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

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

TABLES spfli.

DATA spfli_workarea LIKE spfli.

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

Create a Function Module:



Create a function module that reads data from table SPFLI .

1.If you are not yet in the Object Navigator, choose from the SAP Menu Overview à Object Navigator and display the function group FG_Tutorial .
2.In the Object selection window, use the right mouse button to select function group FG_Tutorial , and choose Create à Function module.
3.Enter as function module name XX_RFC_READ_SPFLI and replace XX with the initials of your name.
4.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.

5.Select the Attributes tab and under Processing type choose

Remote-enabled module

.

6.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.

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

8.Select the Exceptions tab and enter the exception invalid_data .

9.Select the Source code tab.

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

10.Complete the function module with the actual flight data retrieval.

Compare your function with the model solution.

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

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

Test the Function Module:

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

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

3.Choose Execute ( F8 ).

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

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

reward points if it is usefull....

Girish

Former Member
0 Kudos

The RFC Interface Locate the document in its SAP Library structure

A remote function call (RFC) is the call of a function module that runs in a different system to the calling program. Although it is also possible to call a function module in the same system as an RFC, normally RFCs are used when the caller and the called function module run in the same system.

In the SAP system, these functions are provided by the RFC interface system. The RFC interface system enables function calls between two SAP systems, or between an SAP system and an external system.

The RFC- interface system is made up of the following interfaces:

· Calling interface for ABAP programs

· Each ABAP program can call a remote function module using the command CALL FUNCTION...DESTINATION. The parameter DESTINATION informs the SAP system that the called function module runs in a different system to the calling system. RFC communication with the remote system takes place as a part of the CALL FUNCTION command.

· RFC function modules in an SAP system must be proper function modules and must be registered in the SAP system as remote.

· If the calling program and the called program are both ABAP programs, the RFC interface provides both communication partners. The calling program can be any ABAP program, and the called program must be a function module that is registered as remote.

· For more detailed information on calling function modules that are registered as remote, see Calling RFC Function Modules in ABAP.

· For more information on writing function modules that you want to call remotely, see Writing RFC Function Modules in ABAP.

· Interfaces for calling non-ABAP programs

If either the calling program or the called partner is not an SAP program, this program must be programmed in such a way that it can play the role of the other partner in RFC communication.

To support you when implementing RFC partner programs in non-SAP systems, read: Components of the SAP Communication Technology

RFC-supported and GUI-supported interfaces can be used by external programs to call function modules in SAP systems, and execute them in these systems. Likewise, ABAP programs can also use these interfaces to use functions supplied by external programs.

RFC in SAP Systems Locate the document in its SAP Library structure

In all SAP systems, CALL FUNCTION represents an integral part of the ABAP language. This statement executes a function (a function module) in the same system.

REMOTE FUNCTION CALL (RFC) is an extension of CALL FUNCTION in a distributed environment. Existing function modules can be executed using an RFC from a remote system. This is done by adding a DESTINATION clause to the CALL FUNCTION statement.

The destination parameter displays an entry in the RFCDES table (which is defined with transaction SM59). This entry contains all necessary parameters to connect to and log in the destination system.

You can use RFC between two SAP systems.

By using the RFC Library (RFC API), you can also use the functions of the RFC between an SAP system and a C program on different platforms. It is of no significance to the caller whether the remote function is provided in an SAP System or in a C program.

RFC frees the ABAP programmer from having to program his own communications routines. When you make an RFC call, the RFC interface takes care of:

· Converting all parameter data to the representation needed in the remote system. This includes character string conversions, and any hardware-dependent conversions needed (for example, integer, floating point). All ABAP data types are supported.

· Calling the communication routines needed to talk to the remote system.

· Handling communications errors, and notifying the caller, if desired. (The caller requests notification using the EXCEPTIONS parameter of the CALL FUNCTION statement.)

The RFC interface is effectively invisible to the ABAP programmer. Processing for calling remote programs is built into the CALL FUNCTION statement. Processing for being called is generated automatically (in the form of an RFC stub) for every function module registered as remote. This stub serves as an interface between the calling program and the function module.

A distinction is made between an RFC client and RFC server. RFC client is the instance that calls up the Remote Function Call to execute the function that is provided by an RFC server. In the following, the functions that can be executed remotely will be called RFC functions and the functions provided via RFC API will be called RFC calls.

All RFC functions available in a remote RFC server system, which are called by an RFC client, are processed transactionally. This means that after execution of the first RFC function in the RFC server system the complete context (all globally defined variables in the RFC server program or in the main program of a function module) is available for further RFC functions. The RFC connection is closed only

· when the context of the calling ABAP program has ended or

· explicitly by RfcAbort or RfcClose in the external program.

You can either assign an application server directly, or assign it through a message server, as part of a load distribution. This applies to RFCs between two SAP systems and to RFCs between an SAP system and an external system.

To make the execution of RFC functions reliable, safe and independent from the availability of the RFC server or RFC server system, the transactional RFC (tRFC) is available for SAP systems. This ensures that the called function module is executed only once in the RFC server system.

In transactional RFC calls, the data that belongs to an RFC function must first be stored temporarily on the SAP database in the RFC client system. When processing is completed, this must be reported back to the calling ABAP program. Everything else is handled by the tRFC component in the SAP system.

Since a database is not always available on external systems, the link to the tRFC interfaces is implemented such that the client or server programs based on RFC API must take on some administrative functions to ensure that the respective function module is executed only once.

Regards,

srinivas

*reward for useful answers*</b>