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

RFC and bapi

Former Member
0 Likes
1,475

hi,

pls give me answer

what are the diferences between RFC and BAPI ?

4 REPLIES 4
Read only

Former Member
0 Likes
974

Both are same.

RFC is nothing but a Function Module which can be called REMOTELY. i.e. Remote enable Function Module is RFC.

You can create your own RFC.

BAPI also can be called remotely & provided by SAP.

Read only

former_member188829
Active Contributor
0 Likes
974

Hi,

Please check the links,

Read only

Former Member
0 Likes
974

If there are images in this attachment, they will not be displayed. Download the original attachment

Objectives

• To introduce the concepts of Remote function calls ( RFC’s)

• RFC Basics

• Calling remote function modules

• Writing remote function modules

• Maintaining remote destinations

• To understand about ABAP queries and the difference between

ABAP reports and queries

• To get acquainted with BAPI’s ( Business Application

Programming Interface )

RFC ( Remote Function calls )

Basics

A remote function call is a call to a function module running in a

system different from the caller's. The remote function can also

be called from within the same system (as a remote call).

RFC consists of two interfaces : A calling interface for ABAP

Programs and a calling interface for Non-SAP programs.

Any ABAP program can call a remote function using the CALL

FUNCTION...DESTINATION statement. The DESTINATION

parameter tells the SAP System that the called function runs in

a system other than the caller's.

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.

The RFC Interface takes care of :-

- Converting all parameter data to the representation needed in the

remote system

- Calling the communication routines needed to talk to the remote

system.

- Handling communications errors, and notifying the caller, if desired (

using EXCEPTIONS paramater of the CALL FUNCTION).

Calling Remote function modules

You can use the CALL FUNCTION statement to call remote

functions by including an additional DESTINATION clause.

CALL FUNCTION ‘remotefunction’

DESTINATION dest

EXPORTING f1 =

IMPORTING f2 =

TABLES t1 =

EXCEPTIONS

The field ‘dest’ can be either a literal or a variable. Logical

destinations are defined in the RFCDES table via transaction SM59

or via the menu path: Tools ->Administration,Administration-

>Network->RFC destinations.

• Calling remote functions locally :-

( i.e. call a remote function within the same system )

The two options to do this are –

• CALL FUNCTION...DESTINATION = 'NONE'

• CALL FUNCTION...

• Calling remote function modules BACK :-

The remote function can invoke its own caller (if the caller is itself a

function module), or any function module loaded with the caller.

You can trigger this call-back mechanism using

CALL FUNCTION... DESTINATION 'BACK‘.

Types of RFC’s

Synchronous RFC – The calling program continues the execution

only after the called function is complete.

Asynchronous RFC - The calling program continues the execution

without waiting for return from the called function.

Eg: CALL FUNCTION ‘remotefunction’ STARTING NEW TASK

‘taskname’.

Transactional RFC - The called function module is executed exactly

once in the RFC server system.Each function call is seen as a

transaction in the target system. Transactional RFCs use the suffix IN

BACKGROUND TASK .

Eg : CALL FUNCTION ‘remotefunction’ IN BACKGROUND

TASK

Writing remote function modules

In the function module attributes tab (transaction code SE37), set

the processing type as Remote-enabled module to create a remote

function module.

Write the code for the function module.

Define the destination of the RFC server in the RFC client system

that calls the remote function ( via SM59 transaction).

Declaring Parameters: All parameter fields for a remote function

module must be defined as reference fields, that is, like ABAP

Dictionary fields.

Exceptions: The system raises COMMUNICATION_FAILURE

and SYSTEM_FAILURE internally. You can raise exceptions in a

remote function just as you would in a locally called function.

Writing remote function modules

writing remote function modules

Debugging Remote function calls

• It is not possible to debug a remote function call to another system.

• However, when testing ABAP-to-ABAP RFC calls, you can use the

ABAP debugger to monitor the execution of the RFC function in the

remote system.

• With remote calls, the ABAP debugger (including the debugging

interface) runs on the local system. Data values and other run

information for the remote function are passed in from the remote

system.

BAPI’s

What -

BAPIs are standardized programming interfaces (methods) enabling

external applications to access business processes and data in the R/3

System.

BAPIs provide stable and standardized methods to achieve seamless

integration between the R/3 System and external applications, legacy

systems and add-ons.

BAPIs are defined in the BOR(Business object repository) as

methods of SAP business object types that carry out specific business

functions.

BAPIs are implemented as RFC-enabled function modules and are

created in the Function Builder of the ABAP Workbench.

BAPI Explorer- ( Transaction :- BAPI )

The BAPI Explorer is the R/3 System working environment for

developing BAPIs.

A BAPI interface is defined by:

-Import parameters

-Export parameters

-Import/export (table) parameters

Each function module underlying a BAPI:

· Supports the Remote Function Call (RFC) protocol

· Has been assigned as a method to an SAP Business Object in the BOR

· Is processed without returning any screen dialogs to the calling

application

BAPI Programming

The process of defining and implementing a BAPI consists of the

following steps

Describing the Scenario the BAPI is Used in

Reviewing the BAPI Concept and BAPI Scenario

Defining a BAPI and Its Interface

Creating Individual Programming Objects

Testing the BAPI

Releasing and Freezing the BAPI .

Some BAPIs and methods provide basic functions and can be used for

most SAP Business Objects.These are called STANDARDIZED

BAPI’s.

Standardized BAPIs

BAPIs for Reading Data

GetList() , GetDetail() , GetStatus() , ExistenceCheck()

BAPIs for Creating or Changing Data

Create() or CreateFromData(),Change(),Delete() and Undelete() ,

Cancel() ,Addsales order.

Step 2: Refer to the documentation of the method to know how to use

the BAPI.

Eg : In order to create a sales order, select the BAPI CreateFromDat2.

(BAPI_SALESORDER_CREATEFROMDAT1).

Step 3: Simulate the desired output using SE37 transaction. Do

sample testing with the function module found. SAP does not specify

flag population part to control the update. That you can achieve by

some trial run of the function module.

• Example :

C

all function ‘BAPI_SALESORDER_CREATEFROMDAT1’

EXPORTING

Order_header_in = s_order_header

IMPORTING

Salesdocument = w_sales_docno

Return = s_return

TABLES

Order_items_in = t_order_item

Order_partners = t_order_partner

Order_item_out = t_order_item_out.

Here, in the ‘s_order_header’ structure we fill all the header data of

the sales order to be created.

Eg:- s_order_header-sales_org = ‘FR03’,

s_order_header_distr_chan = ’01’. Etc..

In t_order_item table we fill all the item data of the sales order, eg.

T_order_item-material = ‘M13321’,

T_order_item-plant = ‘0033’.

append t_order_item.

Similarly we fill, t_order_item_out,t_order_partner tables.

In the structure s_return, we will get the return messages from the

BAPI , eg. ‘Sales order created successfully’ or

‘Error in item ‘020’’.

If the BAPI is successful, the number of the sales order created will

be returned in the field, ‘w_sales_docno’.

Once , the BAPI is successful, to commit the changes to the

database, we must use the function module,

‘BAPI_TRANSACTION_COMMIT’.

Eg,

CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’

EXPORTING

wait = ‘X’.

Thus, we can create a sales order, using the appropriate BAPI, and

similarly, we can use BAPI’s for many other applications.

[http://help.sap.com/saphelp_nw04/helpdata/en/6f/1bd5b6a85b11d6b28500508b5d5211/content.htm | http://help.sap.com/saphelp_nw04/helpdata/

en/6f/1bd5b6a85b11d6b28500508b5d5211/content.htm] [http://help.sap.com/saphelp_nw04/helpdata/en/5c/f3f0371bc15d73e10000009b38f8cf/frameset.htm | http://help.sap.com/saphelp_nw04/helpdata/en/5c/f3f0371bc15d73e10000009b38f8cf/frameset.htm]

http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/200dd1cc-589e-2910-98a9-bb2c48b78...

if u like my work plz reward me

Message was edited by:

Trupti Zanwar

Read only

Former Member
0 Likes
974

Hi giridhar,

Just check it out these answers.

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.

*****************************

another points,

BAPI is object oriented. It is placed under Business objects as methods.

RFC is just a Function module or a call.

RFC: is just a FM that can be called from remote system too(destination defined in transaction SM59).

******************************

BAPI: Business Application Programming Interface

A BAPI is a method of a business object defined in the Business Object Repository (BOR). For example, in the BOR, you can find a business object called SalesOrder, which conceptually represents a sales order in the system. A business object typically has several methods that can be used to read, create, modify a particular instance of the business object, or list instances of the business object matching certain selection criteria. These methods are BAPIs.

Technically, a BAPI is implemented using a RFM. But, unlike the non-BAPI RFMs, a BAPI is usually well documented, has nicer parameter names, and is supported by SAP for several SAP software releases. You can browse Business objects and BAPIs in the SAP system using transaction BAPI.

Thanks

Sakthi C

*Rewards if useful*