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: 

what is the difference between RFC and Function Module in SAP?

Former Member
0 Kudos

what is the difference between RFC and Function Module in SAP?

1 ACCEPTED SOLUTION

Former Member

Hi uma,

Function modules are modularzation elements in the ABAP programming language. The encapsulate some function that can be reused. They provide an interface or signature in which to pass data to and from the function module. RFC is a remote enabled function module. All you need to do is set the flag on the attributes tab of the function module and you have an RFC. A BAPI is nothing more than a function module. BAPIs usualy contain the logic for some business function, like "Create Sales Order", or "Change Purchase Order". Again they provide an interface to pass data to and get data from the BAPI. You will never see "Exceptions" in a BAPI as they are designed to be called from other systems, and may no be able to handle exceptions. Also, you will never see a BAPIs signature change. If SAP feels the need to change the signature of the BAPI, then will create a new bapi. Example, is BAPI_SALESORDER_CREATEFROMDAT1 and BAPI_SALESORDER_CREATEFROMDAT2. They won't change the signature, but they will create a new one and incorporate the change

reward if it is useful.

5 REPLIES 5

Former Member

hi

good

Function modules are routines with a defined interface, supporting optional parameters and labelled exceptions, intended to perform specific tasks encouraging re-use.

Functions that are remotely callable via SAP's proprietary remote function call (RFC) protocol, have additional technical restrictions, primarily that the parameters cannot be changing and/or passed by reference, as previously mentioned. When a function module is marked as RFC-enabled, SAP checks that the function's interface meets the restrictions and also generates an internal stub routine to allow the RFC communication to take place (but we don't really need to know anything about that stub).

When a function module raises an exception, control is passed back to the calling program. When the calling program is an external RFC client, the caller receives only a return code indicating that an application exception was raised and the name of the exception as an upper-case text string. The caller is then responsible for inspecting the exception text to see what kind of error occurred.

BAPI stands for Business API and are implemented as function modules that follow SAP-specified standards. They do not need to be RFC-enabled, but since the purpose of BAPI's is to expose business functionality internally and externally, then you will find that most are RFC-enabled.

The main standards that BAPI's must implement are:

1) The interface remains static between releases, or at least backwards-compatible.

2) Exceptions are not used, instead outcome information is returned to caller via a special parameter called a RETURN parameter (the structure of which is somewhat standardised, there are a couple of alternatives). The RETURN parameter provides more information, particularly the SAP message details and text.

3) Database updates are not to be performed directly by a BAPI. Instead the BAPI is to perform the necessary validations and then queue the updates to be processed by the next COMMIT WORK (usually done by calling a subroutine via syntax PERFORM ... ON COMMIT).

In cases where a single BAPI call processes multiple transactions, it is common for the RETURN information to be passed as a table parameter.

Calling application must remember to invoke the ABAP COMMIT WORK statement. This can be done externally by calling RFC function module BAPI_TRANSACTION_COMMIT.

This brings me to me biggest pet peave about BAPI's and the RFC protocol. For some reason that is beyond my understanding of the RFC protocol (upon which many other things such as ABAP to Java and .NET integration are based), is that the end of each function call performs an implicit database commit. This is the reason why BAPI transactions are not allowed to perform database updates directly, because doing so would otherwise prevent chaining multiple BAPI calls into a single unit of work.

However this is really a catch 22 situation, because the problem with the BAPI approach of queueing updates is that chances are the subsequent BAPI call, which I'd like to be part of the same unit of work, will fail because the database updates of the first BAPI call have not been made yet.

Take for example the following scenario (please note that I'm not an SD person):

- Create a customer

- Create a sales order for that customer

This can't be done in a single unit of work, because the call to the "Create Customer" BAPI (whatever that is) will not create the customer in the database (it will just queue it for update) and so the second BAPI call to "Create Sales Order" will fail because the customer number does not exist yet.

reward point if helpful.

thanks

mrutyun^

Former Member
0 Kudos

Hi

Remote Function Call:

RFC is an SAP interface protocol. Based on CPI-C, it considerably simplifies the programming of communication processes between systems.

RFCs enable you to call and execute predefined functions in a remote system - or even in the same system.

RFCs manage the communication process, parameter transfer and error handling.

http://help.sap.com/saphelp_47x200/helpdata/en/22/042860488911d189490000e829fbbd/frameset.htm.

BAPI

BAPI stands for Business API(Application Program Interface).

A BAPI is remotely enabled function module

ie it can be invoked from remote programs like standalone JAVA programs, web interface etc..

You can make your function module remotely enabled in attributes of Function module but

A BAPI are standard SAP function modules provided by SAP for remote access.

Also they are part of Businees Objest Repository(BOR).

BAPI are RFC enabled function modules. the difference between RFc and BAPI are business objects.

You create business objects and those are then registered in your BOR (Business Object Repository)

which can be accessed outside the SAP system by using some other applications (Non-SAP) such as VB or JAVA.

In this case u only specify the business object and its method from external system

in BAPI there is no direct system call. while RFC are direct system call.

Some BAPIs provide basic functions and can be used for most SAP business object types.

These BAPIs should be implemented the same for all business object types.

Standardized BAPIs are easier to use and prevent users having to deal with a number of different BAPIs.

Whenever possible, a standardized BAPI must be used in preference to an individual BAPI.

Remote Function Call:

RFC is an SAP interface protocol. Based on CPI-C, it considerably simplifies the programming of communication processes between systems.

RFCs enable you to call and execute predefined functions in a remote system - or even in the same system.

RFCs manage the communication process, parameter transfer and error handling.

BAPI

BAPI stands for Business API(Application Program Interface).

A BAPI is remotely enabled function module

ie it can be invoked from remote programs like standalone JAVA programs, web interface etc..

You can make your function module remotely enabled in attributes of Function module but

A BAPI are standard SAP function modules provided by SAP for remote access.

Also they are part of Businees Objest Repository(BOR).

BAPI are RFC enabled function modules. the difference between RFc and BAPI are business objects.

You create business objects and those are then registered in your BOR (Business Object Repository)

which can be accessed outside the SAP system by using some other applications (Non-SAP) such as VB or JAVA.

In this case u only specify the business object and its method from external system

in BAPI there is no direct system call. while RFC are direct system call.

Some BAPIs provide basic functions and can be used for most SAP business object types.

These BAPIs should be implemented the same for all business object types.

Standardized BAPIs are easier to use and prevent users having to deal with a number of different BAPIs.

Whenever possible, a standardized BAPI must be used in preference to an individual BAPI.

BAPIs:

- are designed as the methods of business objects in the business object repository (accessable using transaction BAPI or SWO1)

- have non-technical parameter names (the technical field names in SAP are mapped)

- have a fixed interface and functionality across all SAP releases (this is probably the key point as it means you can develop integrations with them which do not need to be changed when you upgrade)

Generally, if you are trying to find a function for a particular requirement you should look for a BAPI first, then for a RFC function which has a released status (check the function attributes in SE37), and then just a normal RFC last.

The benefit of an RFC function with released status means that it also has a fixed interface which will not change with new SAP releases

<b>Reward if usefull</b>

Former Member
0 Kudos

RFC and FM are simillar but only diffrence is RFC are remote enabled means you can call RFC from any any stack of SAP.Suppose you made a FM using ABAP code. Now this FM is required to be used in application using SAP portals,in that case we make that FM remote enabled(ie it becomes RFC) and we can call that RFC.On the other hand if it is only FM you cannot call it from any other SAP component but only from R/3.

Former Member
0 Kudos

Hi,

Functional Modules are of 3 types

1. Normal FM

2. Remote-enabled FM

3. Update FM

Normal FM's are Created/Used in the Same Server.

For example, If you have 3 R/3 servers NCD NCQ NCP.

In the case of Normal FM, If you have Created it in NCD, you can call that FM, only in NCD.

In case of Remote-enabled FM, If you have Created it in NCD, you can call that FM

from NCQ or NCP also.

Here, you have to do 2 things.

1. Go to SM59, create RFC destination

2. in the Calling use the syntax

Call Function ZXX_FM destination 'REMOTE'....

Try this,

KC

Former Member

Hi uma,

Function modules are modularzation elements in the ABAP programming language. The encapsulate some function that can be reused. They provide an interface or signature in which to pass data to and from the function module. RFC is a remote enabled function module. All you need to do is set the flag on the attributes tab of the function module and you have an RFC. A BAPI is nothing more than a function module. BAPIs usualy contain the logic for some business function, like "Create Sales Order", or "Change Purchase Order". Again they provide an interface to pass data to and get data from the BAPI. You will never see "Exceptions" in a BAPI as they are designed to be called from other systems, and may no be able to handle exceptions. Also, you will never see a BAPIs signature change. If SAP feels the need to change the signature of the BAPI, then will create a new bapi. Example, is BAPI_SALESORDER_CREATEFROMDAT1 and BAPI_SALESORDER_CREATEFROMDAT2. They won't change the signature, but they will create a new one and incorporate the change

reward if it is useful.