Sei sulla pagina 1di 29

REMOTE FUNCTION CALL

02-Sep-09

Kaavian Systems

Remote Function Call

A remote function call (RFC) is the call of a


function module that runs in a different system to
the calling program.

The remote function can also be called from within


the same system.

02-Sep-09

Kaavian Systems

Application Server Interface


Each application server consists of a gateway,
Internet Communication Manager(ICM),dispatcher
and set of work processes.

The

gateway

and

ICM

are

interfaces

for

communication with remote systems.

02-Sep-09

Kaavian Systems

Application Server Interface

02-Sep-09

Kaavian Systems

Remote Function Call types


Synchronous RFC (sRFC)
Asynchronous RFC (aRFC)

Transactional RFC (tRFC)


Queued RFC (qRFC)
Parallel RFC (pRFC)

02-Sep-09

Kaavian Systems

RFC Functions

An RFC client, requests the RFC server to execute a


function module or program.
This function module is remote enabled and can be
executed via RFC.
The remote-enabled radio button on the function
module attribute screen must be checked.

02-Sep-09

Kaavian Systems

Synchronous RFC
It is the most common type of RFC used and is ideal
when you need the results of a function module
immediately after its execution.
Pre-requisite : The RFC client and the RFC server
must be available at the time the call is made.
The sRFC call is passed immediately to the target
system, and the caller program is halted until the
response of the RFM is received.

02-Sep-09

Kaavian Systems

Synchronous RFC
Sometimes we want to call a remote function from
within the same system. This function can run either
as a remote or a local call, depending on the CALL
FUNCTION statement.
CALL FUNCTION...DESTINATION = NONE

This is a remote call runs in its own roll area, and


parameter values are handled as for other remote
calls.

02-Sep-09

Kaavian Systems

Calling Remote Functions

Locally

This is a local call, even though the function

module is registered as remote. The module does not


run in a separate roll area. Parameter transfer is
handled

as

particular,

if

for
the

normal
call

function

leaves

some

modules.

In

EXPORTING

parameters unspecified, it terminates abnormally.


CALL FUNCTION... [no DESTINATION used]

02-Sep-09

Kaavian Systems

Synchronous RFC

02-Sep-09

Kaavian Systems

10

Asynchronous RFC
Asynchronous RFC is a great option when you want
to improve the performance of your ABAP program.
By having the system call one or more function
modules in parallel rather than force your program
to wait for the results.
The process in which the aRFC does not return
parameters is referred as aRFC without response.
Handling the results of function call is referred as
aRFC with response.

02-Sep-09

Kaavian Systems

11

Asynchronous RFC
Asynchronous RFC without response

Syntax
CALL FUNCTION My_first_func
STARTING NEW TASK 'my first task'
DESTINATION 'myfirstdestination'
EXPORTING...
TABLES..

02-Sep-09

Kaavian Systems

12

Asynchronous RFC
Asynchronous RFC with response

Syntax
CALL FUNCTION My_first_func
STARTING NEW TASK 'my first task'
PERFORMING <call back form> ON END OF TASK
DESTINATION 'myfirstdestination'
EXPORTING...
TABLES..
WAIT UNTIL <logical_exxpression>
FORM <Call back form>

02-Sep-09

Kaavian Systems

13

Parallel RFC
Parallel RFC (pRFC) is an extension of aRFC. It is
particularly useful when you plan to make a large
number of RFC calls.
It allows you to specify a group of application
servers on which to execute the RFC calls ,instead
of just a single RFC destination.
It can alert you to raise an exception when non of
the servers in the group has sufficient resources.

02-Sep-09

Kaavian Systems

14

Parallel RFC
Syntax
CALL FUNCTION 'MY_FUNC
STARTING NEW TASK 'new_task
DESTINATION IN GROUP 'mygroup
EXPORTING..
TABLES..
EXCEPTIONS
COMMUNICATION_FAILURE = 1
SYSTEM_FAILURE = 2.
RESOURCE_FAILURE = 3.

02-Sep-09

Kaavian Systems

15

Parallel RFC
Parallel RFC function

02-Sep-09

Kaavian Systems

16

Transactional RFC

A Transactional RFC (tRFC) lets you to group one or


more functional module calls together to a tRFC
LUW, they are executed in order.

When the remote system is unavailable , the SAP


System schedules the report RSARFCSE for
background processing with the relevant transaction
ID as variant.

The report is called repeatedly until it succeeds in


connecting with the desired system.

The tRFC logs can bee seen in SM58 transaction.

02-Sep-09

Kaavian Systems

17

Transactional RFC
Syntax
CALL FUNCTION <Remote Function>
IN BACKGROUND TASK<Options>
Options
Destination <DEST>
Exporting <P1 = F1> Tables <p1 = itab >
COMMIT WORK.

Note :
The call function statement returns immediately
always succeeding with sy-subrc = 0. The system
assigns a unique ID known as transactional ID

02-Sep-09

Kaavian Systems

18

Transactional RFC

Table ARFCSSTATE
Fields : Host id, Process id, Destination id, Name
of remote function module,
Transaction id,
Status of call etc.

Table ARFCSDATA
Fields : Host id, Process id, Destination id,
Transaction, Data etc.

02-Sep-09

Kaavian Systems

19

Transactional RFC

Configuring Destination: In transaction SM59 you


can select Destination->TRFC options which
enables you to configure each destination.

System if it is not reachable the system stops


calling RSARFCSE
and the status CPICERR is
written to the ARFCSDATA table.

The tRFC is a great choice to use when the


execution of the function modules in the remote
system has to be guaranteed, and the progress of
those calls to be monitored.

02-Sep-09

Kaavian Systems

20

Queued RFC

Queued RFC(qRFC) is an extension of tRFC,


guarantee an LUW sequence the tRFC is serialized
using queues.

Use the below function module to set the queue


before each function call : RFC_SET_QUEUE_NAME

Use the transaction SMQS to configure outbound


queues and SMQR to configure inbound queues.

02-Sep-09

Kaavian Systems

21

Queued RFC
qRFC Example

02-Sep-09

Kaavian Systems

22

Queued RFC
Function modules
TRFC_SET_QUEUE_NAME : For the queue name
to be passed.
TRFC_GET_QUEUE_INFO : To read the current
contents of one or all the queues of the table
TRFCQUOUT.
TRFC_QOUT_STOP : To stop processing one or more
queues.
TRFC_QOUT_RESTART : To continue processing

02-Sep-09

Kaavian Systems

23

RFC Interface
In the SAP System, the ability to call remote
function is provided by the Remote Function Call
interface system (RFC). RFC allows for remote calls
between two SAP Systems (R/3 or R/2), or between an
SAP System and a non-SAP System.
RFC consists of the following interfaces:
A calling interface for ABAP programs
CALL FUNCTION...DESTINATION Statement
02-Sep-09

Kaavian Systems

24

RFC Interface
Calling interfaces for non-SAP programs
When either the caller or the called partner is a nonABAP program, it must be programmed to play the
other partner in an RFC communication.
To help implement RFC partner programs in non-SAP
Systems,

SAP

provides

External

Interfaces.

ABAP

programs in R/2 or R/3 can use the functions provided


by external programs via these interfaces.

02-Sep-09

Kaavian Systems

25

Systems
R/3

Trust Relationships Between R/3

Systems

may

establish

trusted

relationships between each other. If a calling R/3


System is known to the called system as a trusted
system, no password must be supplied. The calling
R/3 System must be registered with the called R/3
System as a trusted system. The called system is
called the trusting system.

02-Sep-09

Kaavian Systems

26

Authorizations for RFC

The

system

profile

parameter

auth/rfc_authority_check is set (value 1), then the


System automatically checks at the CALL FUNCTION
keyword whether the authorizations user has the
required RFC authorization.

The RFC authorization object is S_RFC Authorization


check at RFC access. The authorization checks access
to function modules by function module group.

02-Sep-09

Kaavian Systems

27

Reference
The
learning
material
contained
in
this
PowerPoint
Presentation is prepared with the help of http://help.sap.com/
and sap press book. All rights reserved by SAP AG.
Unless otherwise specifically stated, this learning material is
intended for the sole purpose of class room session, internal use
and for knowledge transfer to the Consultants.
However, for detailed information on this learning material,
http://help.sap.com / sap press book may be referred.
Kaavian is not liable for any legal liability or responsibility for
the accuracy, completeness or usefulness of any information
disclosed in these learning materials.
No portion of the learning materials
shall be modified,
reproduced or transmitted in any form by any means, whether
by electronic, photocopier or otherwise without the written
permission of Kaavian. In no event shall Kaavian be liable for
any damage whatsoever resulting in any action arising in
connection with the use of learning material.
02-Sep-09

Kaavian Systems

28

THANK YOU

02-Sep-09

Kaavian Systems

Potrebbero piacerti anche