Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

http://www.abapmadeeasy.

com Prepared By: Uttam Agrawal


30 SAP ABAP Remote Function Call (RFC) - Interview
Questions With Answers.
1. What Do You Mean By RFC? Explain In Detail.
RFC stands for Remote Function Call. Remote Function Call is an interface for
communication between a SAP System and other SAP or third-party compatible
system. Remote function calls may be associated with SAP software and ABAP
programming and provide a way for an external program (written in languages such
as PHP, ASP, Java, C, C++) to use data returned from the server or insert data into
server records.
For business applications, sometimes it becomes necessary to communicate and
exchange information (in predefined formats) with other SAP Systems or non-
SAP Systems (Example Visual Basic to SAP, Java to SAP etc.). To enable this
communication, SAP has provided us with a mechanism called RFC, which stands
for 'Remote Function Call'.
RFCs can be used for external integration with SAP, such as PHP/SAP, Flex/
SAP, Ruby/SAP, etc.
In SAP, RFC Interface system is used for setting-up RFC connections between
different SAP systems, and also between an SAP and an external (Non SAP) system.
Say for example, If you have VB system which has your company's Inventory
Management & you have FICO / SD / MM / PP in you SAP system. Your VB
Inventory mgmt system wants to send or receive data/update database in SAP. This
can be done use RFC.
Although an RFC associated with communication between two different systems,
it can also be created for communication within a system.
RFCs can be created or maintained via transaction code SE37. RFC calls a
function to be executed in a remote system. SM59 transaction code can be used
to define and maintain the logical destination of RFC.
2. What Is An RFC Interface? What are the types of RFC Interface?
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
The RFC interface provides the ability to call remote functions. In SAP, RFC
Interface system is used for setting-up RFC connections between different SAP
systems, and also between an SAP and an external (Non SAP) system.
RFC consists of two interfaces:
a) Calling interface for ABAP 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.
Syntax:
CALL FUNCTION <RFC_Name>DESTINATION
EXPORTING
f1 =
IMPORTING
f2 =
TABLES
t1 =
EXCEPTIONS
.
b) Calling Interface For Non-SAP programs: If either the calling program
or the called partner is not an SAP program, the program in question must be
programmed in such a way that it can play the role of the other partner in RFC
communication. 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. Connectors can be used to achieve the same,
for example SAP Java Connector (JCo) or SAP .Net Connector.
3. What Are The Functions Of RFC Interface?
Some of the functions of the RFC interface are:
Calling the communication routines needed to talk to the remote system.
Converting all parameter data to the representation needed in the remote system
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
Handling communications errors, and notifying the caller, if desired (using
EXCEPTIONS parameter of the CALL FUNCTION).
4. Explain A Scenario Where There Will Be A Need Of Using RFC?
RFCs are not only used for external access to SAP systems but also for
interconnections of SAP systems. For example, if there is a Central User
Administration (CUA) installed in an SAP system landscape, then there will be need
of RFC destination to all daughter systems of the CUA system.
Say we have CRM and R/3 System. In CRM we cannot know anything about
delivery status of sales orders. In such cases RFC's can be used to retrieve delivery
status of sales orders from R/3 Server. In This way CRM server can get information or
data regarding Delivery status of Sales Orders.
An important scenario which requires RFC is Application Link Enabling
(ALE). Let's assume there is a Master Data Management (MDM) system and we want
to distribute the master data to all SAP systems which would require access to master
data. For such scenarios, ALE can be used to distribute the master data among the
different SAP systems using IDocs. ALE in turn uses RFC to establish a connection
between MDM and its daughter system in this scenario.
5. What Are The Advantages Of RFC Remote Function Call?
RFC helps to reduce the efforts of programmers, by letting them avoid the re-
development of modules and methods at remote systems. It is capable enough to:
Convert the data into the format understandable by the remote (target) system.
Convert the data into the format understandable by the remote (target) system.
Call up certain routines which are necessary to start communication with remote
system.
Handle errors that might occur in the process of communication.
6. For What Purposes Can RFCs Be Used?
RFCs can be used for the following mentioned purposes:
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
To establish Communication between different systems, such as between
two SAP systems or between an SAP system and an external system.
To establish Communication between application instances or between the
application layer and the presentation layer (GUI communication).
Can be Used for Parallelizing Processes as one program after another can
start several RFCs asynchronously without waiting for processing to finish,
RFCs are used to parallelize processes and dynamically distribute workload
over the different servers within an SAP system.
7. State Whether RFCs Are Client Dependent Or Client Independent Objects?
RFCs are Client Independent Objects. RFC connections can always be used across
the entire system. This means that an RFC connection you have defined in client 100
can also be used from client 110 also without any difference.
8. What Are The Types of RFCs available in SAP System?
There are 5 types of RFCs available in SAP System. They are:
Synchronous RFC (sRFC)
Asynchronous RFC (aRFC)
Transactional RFC (tRFC)
Queued RFC (qRFC)
Parallel RFC (pRFC)
9. How Are RFCs Executed? In Background Or Dialog Work Processes?
All RFCs, whether synchronous, asynchronous, or transactional, are started in dialog
work processes. Dont get deceived by the syntax IN BACKGROUND TASK; this
has nothing to do with background work processes. Transactional RFCs are also
executed in dialog work processes.
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
10. State Some Factors That Can Increase The Response Time Of An RFC
Connection Between Two Systems?
The response time for the transfer of data depends on the network used. Ideally, the
response time should be between 10 and 100 milliseconds.
High response times can be due to the following three things
The network connection is generally slow or overloaded.
The recipient system is physically overloaded.
Too few processes are configured in the recipient system to receive RFCs.
11. What Is Synchronous RFC (sRFC)?
Synchronous Communication is implemented when there is a need for immediate
return of data (response) from the receiving system to the sender system. The
receiving system should be active at the time this communication is made so that it
can process the function call at that very time. This communication is very helpful
when real time response is required or when results are required immediately from the
destination system.
Synchronous RFC is based on synchronous communication which means both the
source system and destination system (Client & Server) involved must be available at
the time function call is made.
sRFC is a means of communication between systems where acknowledgements
are required. The resources of the Source System wait at the target system and
ensure that they deliver the message/data with ACKD. The Data is consistent and
reliable for communication.
The only issue is if the target system is not available, the source system resources
wait until target system is available which may lead to the Processes of source
system to go into Sleep/RFC/CPIC Mode at target systems and hence blocks these
resources.
Synchronous RFC can be used for
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
For communication between systems.
For communication between SAP Web Application Server to SAP GUI.
12. What Is Asynchronous RFC (aRFC)?
Asynchronous RFC is based on asynchronous communication which means the
receiving system may or may not be able to retrieve the function call request made
from the sender system. The function call can be processed at a later time when the
receiving system gets available. Till that time the function call remains in an outbound
queue of the sending system and the call is repeated at regular intervals until the
receiving system gets available to process the request.
The advantage of this communication is that the receiving system need not be
available all the time to process the request especially in cases where the receiving
system is temporarily unavailable like due to upgrade or any other reason.
aRFC is a means of communication between systems where acknowledgements
are not required (it is similar to post card delivery).It doesn't require both the
systems to be available at the time of execution and the result is not immediately
required to be sent back to calling system.
The Source System resource does not wait for the target system as they deliver
the message/data without waiting for any acknowledgement. It is not reliable for
communication since data may be lost if the target system is not available.
Asynchronous RFC can be used for
For communication between systems.
For parallel processing jobs.
13. What Is Transactional RFC (tRFC)?
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) are
used. This ensures that the called function module is executed only once in the RFC
server system.
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
If an error occurs during a synchronous remote function call, the system cannot
tell at what point the error occurred (most crucially, whether the function module
was actually processed in R/3 before the operation failed). Restarting a failed call
is therefore a dangerous thing to do, since there is a risk of duplicating a completed
function call.
In Such cases, tRFCs can be used which guarantees that each function call
issued will be executed only once, even if the call is submitted repeatedly to the
R/3 System. The system implements this safeguard by assigning a unique transaction
ID (TID) to each transaction that you submit. When you attempt to process the
transaction, the system checks whether that TID has already been processed or not. If
it has, the transaction is ignored.
tRFC is an extension of aRFC. Transactional RFC is an asynchronous communication
method that executes the called function module in the RFC server only once, even if
the data is sent multiple times due to some network issue. The remote system need
not be available at the time when the RFC client program is executing a tRFC.
The tRFC component stores the called RFC function, together with the
corresponding data, in the SAP database under a unique transaction ID
(TID). tRFC is similar to aRFC as it does not wait at the target system (Similar to a
registered post). If the system is not available, it will write the Data into aRFC Tables
with a transaction ID (SM58) which is picked by the scheduler RSARFCSE (which
runs for every 60 seconds).
14. What Is Queued RFC (qRFC)?
When transactional RFCs are used, there is no guarantee of the order in which
the function calls will be processed in the system (it is quite possible that one
call might overtake another). For cases where there is a need to specify a particular
processing order, Queued RFC can be used.
qRFC is an extension of tRFC. In qRFC, you place each function call in a logical
queue. A function call cannot be executed until all of its predecessors in the queue
have been processed. Queued RFC calls are processed asynchronously.
qRFC are to be preferred when there is a need of guarantee that several
transactions are processed in a predefined order or when there is a need of
guarantee that multiple LUWs (Logical Unit of Work/ Transaction) are processed in
the order specified by the application.
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
qRFC ensures that the transaction is committed based on FIFO Queue. It ensures
transaction consistency of LUW and reliability of data transmission. The system
stores the queue specifications in table TRFCQOUT. With each COMMIT
WORK, the system determines a counter that is used to keep the sequence of
transaction processing.
SMQ1: To monitor the outbound queues of a sending system refer SCOT for Fax.
SMQ2: Provides interface to monitor inbound queues.
15. What Is The Disadvantage Of Using Queued RFC (qRFC)?
If, for example, due to network/communication problems the first LUW in a
queue cannot be executed, not only this queue keeps pending, but also all other
LUWs that are interdependent with this queue. The resulting "jam" could cause
a database problem. However, as soon as the communication problem is solved, all
transactions and thus all queues can be processed automatically one after the other.
16. What Is Fast RFC (fRFC)?
Fast RFC is a type of RFC used for system internal communications. Interactions
between J2ee engine in SAP & the ABP runtime environment in the same
instance are done using Fast RFC. This type of RFC is possible only if both the
source & target are on the same system.
17. What Is Parallel Processing In RFC (pRFC)?
Parallel Processing is an extension of aRFC. Generally when we call a function
module, it will stop the current program, execute another (called) program and then
returns control to original program and again original program starts execution.
With asynchronous function module control will start parallel without stopping the
current program from which you called the function module. Parallel processing is
generally used when there is a need to process large amount of data.
In parallel processing, a job step is started as usual in a background processing work
process. A program that runs in a job step can be programmed to use a special variant
of asynchronous RFC to have portions of the data to be processed run in parallel in
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
other work processes. You can recognize such a program by its use of the CALL
FUNCTION STARTING NEW TASK DESTINATION IN GROUP instruction to
start the function modules that process the data.
While the job itself runs in a background process, the parallel processing tasks that
it starts, run in dialog work processes. Such dialog work processes may be located
on any SAP server. Parallel processing has been implemented in some SAP
applications that have long-running reports.
18. What Are The Features Of Transactional RFC (tRFC)?
Some of the salient features of tRFc are:
tRFC guarantees that a called function module is executed in the target
system exactly once.
All tRFC calls terminated with the statement COMMIT WORK belong
to one LUW (Logical Unit of Work). Each LUW automatically receives a
transaction ID.
Within an LUW, all function modules are executed in the target system in
the sequence in which they are called in the send system.
tRFC calls with the addition AS SEPARATE UNIT map a separate LUW
each in the target system. Such a sub LUW contains exactly one tRFC call
and is processed independent of the actual (superior) LUW. This sub LUW
receives its own transaction ID.
If within an LUW several destinations are used, all tRFC calls that belong to
one destination also form a sub LUW. However, since this bundling happens
only internally, there is no separate transaction ID assigned to the sub LUW.
19. What Are the Disadvantages of Transactional RFC (tRFC)?
Some of the disadvantages of tRFC are:
tRFC processes all LUWs independent of one another. Due to the amount of
activated tRFC processes, this procedure can reduce performance significantly
in both the send and the target systems.
In addition, the sequence of LUWs defined in the application cannot be
kept. Therefore, there is no guarantee that the transactions are executed
in the sequence dictated by the application. The only guarantee is that all
LUWs are transferred sooner or later.
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
20. State the difference between Synchronous RFC (sRFC), Asynchronous RFC
(aRFC), Transactional RFC (tRFC), Queued RFC (qRFC) and Parallel RFC
(pRFC)?
21. What Do You Mean By The Terms RFC Client & RFC Server?
RFC client is the instance that calls up the Remote Function Call (RFC) to
execute the function that is provided by an RFC server. The process that starts the
RFC is called the sender or client, and the process in which the RFC is executed is the
recipient or server.
Say we have CRM and R/3 System. If we want to read Sales Orders Delivery
Status record from R/3 Systems database, we will have to create a remotely callable
function module in the R/3 environment which retrieves Sales Orders Delivery Status
records. Now we will have to call this function from the CRM System using a remote
function call (Also list the destination for the target R/3 System in SM59). In this
case CRM server acts as an RFC Client and R/3 acts as an RFC Server.
22. What Do You Understand By The Term DESTINATION Used In RFC?
CALL FUNCTION RemoteFunction DESTINATION Dest
EXPORTING
f1 =...
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
f2 =...
IMPORTING
f3 =...
TABLES
t1 =...
EXCEPTIONS......
The field 'Dest' can be either a literal or a variable. Its value is a logical destination
(for example,
"CRM110") known to the local SAP System. Logical destinations are defined
using transaction SM59 and the corresponding data is stored in standard database
table RFCDES.
The remote function call concept, for example, allows you to access a function
module in an R/3 System from an ABAP program in a CRM System. If you want
to read Sales Orders Delivery Status record from your R/3 Systems database, create
a remotely callable function module in the R/3 environment which retrieves Sales
Orders Delivery Status record. Call this function from your CRM System using a
remote function call and listing the destination for the target R/3 System:
CRM System: Client
CALL FUNCTION RFC_SALES_DEL_STATUS
DESTINATION R10
EXPORTING VBELN = SALESNO
TABLES STATUS_T = IT_TAB
EXCEPTIONS NO_RECORD_FOUND = 01.
R/3 System: Server
FUNCTION RFC_SALES_DEL_STATUS.
.... (Read Sales Orders Delivery Status record)
ENDFUNCTION.
23. How Parameter Handling Is Different For Remote Function Calls & Local
Function Calls?
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
In Remote Function Calls, The actual table is transferred, but not the table
header. If a table parameter is not specified, an empty table is used in the called
function.
Internal ABAP tables can be used as parameters for function module calls. In a
local function module call, a parameter table is passed on by reference, and
no new local copy has to be created. RFC does not support the by reference
mechanism, so the whole table has to be exchanged between the RFC client and the
RFC server. When the RFC server receives the table entries, it creates a local copy of
the internal table.
24. Can We Call Remote Function Calls Locally?
Sometimes there might be a need to call a remote function call from within the same
system. This function can run either as a remote or a local call, depending on
the CALL FUNCTION statement on how it is declared. Its a known fact that
parameter handling are different for Remote Function Call and Local Function Call,
so whether the call runs as remote or local the parameter handling gets affected
adversely.
We can call remote functions calls locally using two ways.
CALL FUNCTION...DESTINATION = 'NONE'
This is a remote call, even though DESTINATION = 'NONE' means that the remote
function will run in the same system as the caller. As a remote call, the function
module runs in its own roll area, and parameter values are handled as for other remote
calls
CALL FUNCTION RFC_SALES_DEL_STATUS
DESTINATION NONE
EXPORTING VBELN = SALESNO
TABLES STATUS_T = IT_TAB
EXCEPTIONS NO_RECORD_FOUND = 01.
CALL FUNCTION... [no DESTINATION used]
This is a local call, even though the function module is registered as remote. The
module does not run in a separate roll area, and is essentially like a normal function
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
call. Parameter transfer is handled as for normal function modules. In particular,
if the call leaves some EXPORTING parameters unspecified, it terminates
abnormally.
CALL FUNCTION RFC_SALES_DEL_STATUS
EXPORTING VBELN = SALESNO
TABLES STATUS_T = IT_TAB
EXCEPTIONS NO_RECORD_FOUND = 01.
25. Can a Server System Call Remote Function Of Client System BACK or
When to use DESTINATION BACK?
In general, the client and the server are determined at the start of an RFC. While
a function is being processed on the server, this server can call a remote function
on the client. In other words, the remote function can invoke its own caller (if the
caller is itself a remote function module), or any remote function module loaded with
the caller. The called-back function then runs in the same program context as the
original caller.
This call-back mechanism can be triggered by using the special destination
name BACK. If this name is specified in an RFC call on the system acting as the
server, the system uses the same RFC connection that was established when the server
received the first call. Once an RFC connection is established, it is maintained until it
is either explicitly closed or until the calling program terminates. During a call-back,
the system will always attempt to use existing RFC connections before establishing a
new one.
To perform a call-back, the syntax is:
CALL FUNCTION... DESTINATION 'BACK'
In the below screenshot, remote function B of System B invokes remote function A in
the calling System A.
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
26. How Can You Differentiate Types Of RFC By Syntax In An ABAP Program?
Basically RFCs can be recognized in an ABAP program by the syntax CALL
FUNCTION <rfc name=' '> DESTINATION <destination name=' '>.
If the RFC function call contains the clause STARTING NEW TASK, it is an
asynchronous RFC; the clause IN BACKGROUND TASK indicates a transactional
RFC. If the call only contains the clause DESTINATION, but neither STARTING
NEW TASK nor IN BACKGROUND TASK, then the RFC is started as a
synchronous RFC.
The following code starts the functional module ZRFC_SALES_DEL_STATUS
synchronously, asynchronously, and transactionally.
* Synchronous RFC
CALL FUNCTION ZRFC_SALES_DEL_STATUS
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
DESTINATION R10
EXCEPTIONS
argument_error = 1
send_error = 2
OTHERS = 3.
* Asynchronous RFC
CALL FUNCTION ZRFC_SALES_DEL_STATUS
STARTING NEW TASK task
DESTINATION R10
EXCEPTIONS
communication_failure = 1
system_failure = 2
RESOURCE_FAILURE = 3.
* Transactional RFC
CALL FUNCTION ZRFC_SALES_DEL_STATUS
IN BACKGROUND TASK
DESTINATION R10
COMMIT WORK.
27. What Do You Mean By Trusted RFC Connections? What Are The
Advantages Of It?
While defining RFC destination via tcode SM59, there is an option to make the RFC
connection as 'Trusted'. Once selected, the calling (trusted) system doesn't require
a password to connect with target (trusting) system.
Following are some of the advantages of using trusted channels:
Cross-system Single Sign-On facility.
Password does not need to be sent across the network.
Timeout mechanism for the log-on data prevents misuse.
Prevents the mishandling of log-on data because of the time-out mechanism.
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
User-specific log-on details of the calling/trusted system is checked.
The RFC users must have the required authorizations in the trusting system
(authorization object S_RFCACL).Trusted connections are mostly used to connect
SAP Solution Manager Systems with other SAP systems.
28. What Are The Different Testing Options Available For RFC Connection?
Different testing options available for RFC connection are:
Connection test.
Authorization test.
Unicode Test.
Remote Logon Test
For More Information, Check the link: http://www.guru99.com/how-to-
configure-and-test-rfc.html
29. How To Debug A Remote Function Call (RFC)?
METHOD 1:
Suppose you want to debug a function module which is there in SRM/APO system
from R/3.
(As you all know this RFC Destination is maintained via transaction code SM59).
Keep the external break-point in your calling program before it calls the RFC. Now
login into the Destination system where youre remote enabled function module
exist and put an external break-point.
Now go to Transaction code SRDEBUG and click on the Activate Debugging
Button: It will give you a pop up which confirm your id, application server etc.
Click enter which will give you another popup. Keep it as it is.
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
Now go to your Report program in source system and Execute it , it will open
debugger , when you press F5 key to go inside the RFC Function module it will start
debugging in APO system.
User Id used to Login to destination system to activate debugging should be same
as RFC login id in the Calling system.
Calling System
Destination System
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
METHOD 2. Calling a custom RFC
Three steps needs to be followed.
For example we are calling an RFC enabled FM in ECC system from CRM system.
Add an infinite loop in the remote custom Function Module (adding a DO.
ENDDO. statement at the start of the FM would be enough).
Execute your program in the CRM system. The execution stops at the RFC call,
because of the infinite loop.
Now login to the ECC system and go to transaction SM50 select the process
which is executing the RFC and navigate to the menu: Program/Session-
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal
>Program->Debugging this triggers the debugger session in a separate
window.
For More Information, Check the link:
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e0e8b21b-
e1b4-2c10-49b5-fd6a95162976?overridelayout=true
30. What Are The Basic Transaction Codes Used For RFC's?
http://www.abapmadeeasy.com Prepared By: Uttam Agrawal

You might also like