ABAPintermediate

RFC (Remote Function Call)

The protocol and function module types that enable cross-system and cross-process calls between SAP and external systems.

RFC is how one SAP system calls a function in another system, or how an external program calls into SAP. BAPIs, IDocs and most middleware adapters all ride on it.

Synchronous RFC is a phone call where you wait on the line for an answer; transactional RFC is dropping a letter in the mailbox - it will arrive, but you don't wait for a reply; queued RFC is certified mail with sequence numbers so letters arrive in the order you sent them.

Key Concepts

1
Making a function callable remotely. Set the processing type in SE37 to "Remote-Enabled Module". That imposes restrictions: parameters must be RFC-compatible types, and they are passed by value rather than by reference, because the two systems do not share memory.
SE37
2
Destinations hold the connection details. SM59 defines where a call goes — target host, client, logon user, gateway:
SM59
3
    CALL FUNCTION 'Z_GET_STOCK' DESTINATION 'PRD_CLNT100'
      EXPORTING iv_matnr = lv_matnr
      IMPORTING ev_qty   = lv_qty.
4
A trusted relationship between two systems lets the calling user's identity carry across without a stored password, which is how single sign-on between SAP systems works.
5
Three flavours, and the choice is about reliability.Synchronous (sRFC) — the caller waits for the answer. Used when you need the result now, such as a real-time stock check. If the target is down, your program fails.
6
Transactional (tRFC) — fire and forget, with a guarantee:
7
    CALL FUNCTION 'Z_UPDATE' IN BACKGROUND TASK DESTINATION 'PRD'.
    COMMIT WORK.
8
The call is recorded with a transaction id and executed asynchronously. If the target is unreachable it is retried. Delivery is at least once and order is not guaranteed — two calls can arrive in either sequence.
9
Queued (qRFC) — tRFC plus ordering. Calls go into a named queue and are processed strictly in sequence, so a create cannot overtake the change that follows it.
10
    need the answer now          -> sRFC
    must arrive, order irrelevant -> tRFC
    must arrive in order          -> qRFC
11
Where to look when it breaks. SM58 lists tRFC calls that have not completed, with the error. SMQ1 and SMQ2 are the outbound and inbound qRFC monitors. ST22 for short dumps, SM21 for the system log.
SM58SMQ1SMQ2ST22SM21
12
A stuck qRFC queue is worth understanding: because the queue is strictly ordered, one failing entry blocks every entry behind it. The queue does not skip ahead, so a single bad record halts the interface until somebody clears it.
13
The two failures that account for most incidents. The RFC user lacks an authorisation in the target system — the call connects and fails on the function, so the destination test in SM59 passes and the interface still does not work.
SM59
14
And gateway security: secinfo and reginfo control which external programs may register with the gateway. A correctly configured server program can be refused silently by these files, and they are checked last because they are usually somebody else's responsibility.
secinforeginfo
15
What the interviewer is probing.1. "What are the RFC types and when do you use each?" Probing: breadth. Stalls: "Just RFC." Moves up: synchronous when you need the answer, asynchronous to fire and forget, transactional for guaranteed exactly-once, and queued when order matters.
16
2. "Why is tRFC not enough when sequence matters?" Probing: the distinction. Stalls: "It is." Moves up: tRFC guarantees delivery but not order — qRFC serialises through a queue, which is what IDoc processing relies on.
17
3. "What makes a function module remote-enabled?" Probing: the mechanics. Stalls: "A flag." Moves up: the remote-enabled attribute plus pass-by-value parameters and no complex nested types the RFC layer cannot serialise.
18
4. "How do you troubleshoot a stuck tRFC?" Probing: operational knowledge. Stalls: "Restart it." Moves up: SM58 for the log, SMQ1 and SMQ2 for queues, and check the RFC destination and user authorisations in SM59.