RFC, BAPIs and IDocs
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production. |
A single SAP system rarely works alone. A shop system needs the stock level from a warehouse system, a payroll system must post a journal entry in accounting, and a bank sends a file that must become documents. SAP solved this long before web services were common with three tools that are still everywhere in classic systems. A remote function call (RFC) lets a program call a function module that lives in another system as if it were local. A BAPI is a function module with strict design rules that offers one business operation, for example "create a document", through exactly that RFC door. An IDoc is a data container, with a fixed structure, that two systems exchange when the data must arrive reliably even if the receiver is switched off for a while, and ALE is the technology that distributes business data between systems with IDocs. This page explains what each tool is for, how the variants differ, how to call them from ABAP, how to read an IDoc, and what is old in them. It is written against Standard ABAP release 8.16 (ABAP Platform 2025 in SAP S/4HANA 2025 FPS02) and ABAP for Cloud Development release 9.20 (2608). RFC, BAPIs and IDocs are classic Standard ABAP and S/4HANA on-premise (Private Edition) tools. In ABAP Cloud only the synchronous call remains, through a communication target, and a BAPI that is not released is reached through a wrapper. After reading, you can pick the right RFC variant, write a safe synchronous and asynchronous call, call a BAPI and commit it correctly, and follow an IDoc through its three records and its status values.
Before you read
-
Function Modules and Function Groups: what a function module is, what "remote-enabled" means, and how
CALL FUNCTIONworks, because RFC and BAPIs are built on it. -
SAP LUW, Update Tasks and Commit: the SAP LUW,
COMMIT WORKand the update task, because every RFC variant interacts with the database commit. -
Exceptions: classic and class-based exceptions, because RFC can carry only the classic ones.
-
ABAP Language Versions and Released APIs: why a classic function module is not freely usable in ABAP Cloud.
Key terms
-
Remote Function Call (RFC): a call of a function module in another system, or in another session, through the RFC interface.
-
Remote-enabled function module: a function module marked in its properties as callable by RFC.
-
RFC destination: the stored connection data (target system, connection type, logon data) that a call names after
DESTINATION. -
Synchronous RFC (sRFC): an RFC in which the caller waits until the remote function has finished.
-
Asynchronous RFC (aRFC): an RFC in which the caller continues at once and collects the result later in a callback routine.
-
Background RFC (bgRFC): a call that is stored and sent after
COMMIT WORK, the modern successor of tRFC and qRFC. -
Transactional RFC (tRFC): the older stored-and-sent-at-commit RFC, obsolete.
-
BAPI: a standardized, remote-enabled function module that is a method of a business object.
-
Business Object Repository (BOR): the catalogue of SAP business object types and their methods, in which BAPIs are defined.
-
IDoc: an intermediate document, the common exchange format with a control record, data records and status records.
-
Segment: one structured piece of IDoc data; segments form a tree of parents and children.
-
Partner profile: the settings that say which messages a partner may exchange, through which port, and how inbound messages are processed.
-
Application Link Enabling (ALE): the technology that distributes business data between loosely linked systems, mostly with IDocs.
Where each tool applies
| Tool | Standard ABAP (classic, on premise) | ABAP Cloud (9.20) |
|---|---|---|
sRFC ( |
Yes, with an RFC destination from SM59 or a dynamic destination. |
Yes, but only the synchronous form, and the target is a communication target (or |
aRFC and pRFC ( |
Yes. |
Not part of the language for cloud development: the keyword page lists only the synchronous forms. |
tRFC and qRFC ( |
Obsolete. Use bgRFC. |
Not available. |
bgRFC ( |
Yes, recommended. |
Not listed on the cloud keyword page. |
BAPI |
Yes. |
A BAPI that SAP has not released cannot be called directly; a released one can, and a classic one is wrapped. |
IDoc and ALE |
Yes, a mature technology of classic and on-premise systems. |
The IDoc interface is a classic technology; the cloud keyword pages used here do not describe it. New scenarios use released APIs and business events. |
The cloud column is read from the cloud edition of the Keyword Documentation, where the topic "CALL FUNCTION, RFC" shows only the synchronous syntax, and from the Cloudification Repository for BAPIs. The tables below keep the two worlds apart.
What RFC is and what the RFC interface does
Remote Function Call is the SAP-specific way to call function modules in remote systems. The systems can be two ABAP systems, an ABAP system and an external program, or an ABAP system and a Java program. For the ABAP side, the RFC interface does the hard work that a plain call never needs: it starts and controls the communication, logs on to the remote system and checks the authorizations for the called function group, converts the parameters to the format of the other side (code pages, byte order, all ABAP data types), and reports communication errors to the caller. Programs in other languages use libraries for it: the Java Connector for Java, the .NET Connector for C# and Visual Basic, and an RFC SDK for C and C++.
Every RFC runs in its own RFC session, a dedicated user session in the target system. The logon data of the session (user,
client, language) usually comes from the RFC destination; if the destination leaves them empty, they are copied from the
calling session. The function group of the called module is loaded into an internal session of that RFC session and stays
there, so two calls to modules of the same function group over the same destination share the global data of the group. The
connection and its session live until they are closed explicitly, for example with the function module
RFC_CONNECTION_CLOSE, or until the calling program ends.
Source: Keyword Documentation for Standard ABAP: RFC - Introduction, RFC - Interface and RFC - Session
The rules for a remote-enabled module
Because a call crosses a system boundary, the interface of a remote-enabled function module is restricted. The Keyword Documentation lists these restrictions.
-
The
IMPORTING,EXPORTINGandCHANGINGparameters must be passed by value;TABLESparameters are implicitly by value. -
Parameters are typed with ABAP Dictionary types or built-in ABAP types. A type from a type pool and a reference type are not possible, so no reference variable can be passed.
-
Only classic exceptions can be declared. A class-based exception raised in the remote module is not transported: the caller gets the predefined classic exception
SYSTEM_FAILUREinstead.COMMUNICATION_FAILUREreports errors of the connection andRESOURCE_FAILURE(only with pRFC) a missing resource. All predefined exceptions should be handled. -
Every synchronous or asynchronous RFC triggers a database commit in the caller, except during an update, where an sRFC or aRFC causes neither a work process switch nor a commit. An RFC therefore must not be used between ABAP SQL statements that open and close a database cursor.
-
A remotely called module may not run a statement that closes the RFC session, for example
LEAVE PROGRAM. -
With the profile parameter
auth/rfc_authority_checkset to 1, the system checks the authorization automatically when a function module is called remotely.
Intermediate results of a failed synchronous call are lost, because everything is passed by value; TABLES parameters are the
exception and keep the data they held before the exception.
RFC destinations and transaction SM59
The destination says where the call goes. A static destination is maintained in the system with transaction SM59 (the menu
path is Administration, System Administration, Administration, Network, RFC Destinations) and has a unique name that you write
after DESTINATION. For each destination SM59 stores a connection type, the partner program and the target system, and it can
store the logon data. Three more ways to name a target exist:
-
Dynamic destinations are built at runtime with the class
CL_DYNAMIC_DESTINATION, whose methodCREATE_RFC_DESTINATIONreturns a text that is accepted afterDESTINATION. A destination from SM59 can serve as a template. The result carries the prefix%%, and such a name must never be copied into a program from outside. -
Predefined destinations need no SM59 entry.
NONEstarts the module in the same application server instance in a separate RFC session of the current user,SELFdoes the same with fast serialization, andBACKlets a remotely called module call back its caller. -
An application server instance name of the form host name, system ID and instance number can also be used, but only for the current system or systems linked by a trust relationship.
In ABAP Cloud there is no SM59. A call goes through a communication target, a development object created in ADT, for which
the system generates a class with the same name. An administrator configures it with a communication arrangement or an
application destination, so the program never contains connection data. The two instance methods GET_TRANSIENT_SESSION and
CREATE_SESSION create a session object for CALL FUNCTION ... IN REMOTE SESSION: the transient session opens a new ABAP
session for every call, the stateful session keeps one remote session, and its variables, between calls.
The RFC variants
The Keyword Documentation names six variants. Four are current and two are obsolete.
| Variant | Statement | Behavior |
|---|---|---|
sRFC (synchronous) |
|
The caller waits until the remote function has finished. |
aRFC (asynchronous) |
|
The caller continues as soon as the remote function has started; results arrive in a callback routine. |
pRFC (parallel) |
aRFC with |
Several aRFCs spread over an RFC server group of the same system, for parallel work. |
bgRFC (background) |
|
Stored, and executed after |
tRFC (transactional), obsolete |
|
Registered for the SAP LUW and started by |
qRFC (queued), obsolete |
tRFC with a queue name |
tRFC with a guaranteed order. |
Synchronous RFC
The simplest and the most common variant. The statement CALL FUNCTION func DESTINATION dest parameter_list calls a
remote-enabled module and returns when it has finished. func and dest are character-like data objects. If dest is
empty or only blanks, the addition is ignored and an ordinary local call happens, which is a classic trap when a destination
name is read from customizing and is not filled. The call fills sy-subrc as every function module call does, and also
initializes the system fields for messages. A message of type A, E or X in the remote module normally raises
SYSTEM_FAILURE in the caller, and the message fields then describe that message.
The scenario: the expense app of the running example lives in system A. System B, the central accounting system, owns a
remote-enabled module that returns the data of one claim. The table behind it is the full ZEXP_CLAIM of
Database Tables and Structures (client, claim_id,
employee_id, status, currency_code, total_amount and the included structure zexp_s_audit). The function module
Z_EXP_READ_CLAIM is a custom module of this running example, created in a function group in system B with the processing
type remote-enabled; it has the import parameter claim_id, the export parameter claim typed with the table structure and
the classic exception not_found. System A holds an RFC destination named EXP_REMOTE in SM59. The listing needs an SAP
system with both; it is not run here.
DATA claim TYPE zexp_claim.
DATA message TYPE c LENGTH 200.
CALL FUNCTION 'Z_EXP_READ_CLAIM'
DESTINATION 'EXP_REMOTE'
EXPORTING
claim_id = 'C-0001'
IMPORTING
claim = claim
EXCEPTIONS
not_found = 4
system_failure = 8 MESSAGE message
communication_failure = 12 MESSAGE message
OTHERS = 16.
CASE sy-subrc.
WHEN 0.
WRITE: / claim-claim_id, claim-status, claim-total_amount.
WHEN 4.
WRITE / 'claim does not exist'.
WHEN OTHERS.
WRITE: / 'remote call failed:', message.
ENDCASE.
Source: Keyword Documentation for Standard ABAP: CALL FUNCTION DESTINATION, CALL FUNCTION DESTINATION, parameter_list and RFC - Exceptions
Reading it: the two predefined exceptions are written with MESSAGE so that the error text is available, and the remaining
exceptions fall into OTHERS. The documentation strongly recommends handling every predefined exception, also to stay
compatible when class-based exceptions arrive in RFC.
Asynchronous and parallel RFC
With STARTING NEW TASK task the caller does not wait. task is a freely chosen identifier (at most 32 characters) that is
handed to the callback routine; each task identifier opens a separate RFC connection with its own session. Without a
destination the call goes to the destination NONE, and an asynchronous RFC cannot talk to external programs. The result is
collected by a callback routine, registered with PERFORMING subr ON END OF TASK or CALLING meth ON END OF TASK. The
routine must read the result with RECEIVE RESULTS FROM FUNCTION func, which accepts IMPORTING and EXCEPTIONS; a routine
without RECEIVE is a programming error and keeps the connection open as if KEEPING TASK were written. A subroutine used
as callback has exactly one USING parameter of type clike, a method must be public with one non-optional input parameter
p_task.
The callback runs only when the work process changes, and only if the calling program is still alive in its internal
session. The statement WAIT FOR ASYNCHRONOUS TASKS UNTIL log_exp makes this explicit: it interrupts the program until
callback routines have run and the condition is true, and sets sy-subrc to 0 when it is true, to 4 when all routines have
run and it is still false. Like every RFC it causes a database commit, so it must not stand between ABAP SQL statements that
open and close a cursor.
For parallel processing the addition DESTINATION IN GROUP (called parallel RFC, pRFC) picks, for each call, the most
suitable application server instance of an RFC server group maintained in transaction RZ12; DEFAULT uses all instances. If no
instance has resources, the predefined exception RESOURCE_FAILURE is raised. The documentation prefers server groups to
self-made parallelism with explicit destinations, because the latter can overload client and server. The order of
execution of several calls is not fixed.
The scenario: the program reads the claims of two employees from system B at the same time. It reuses the module and the destination of the previous listing. It needs an SAP system; it is not run here.
DATA claim TYPE zexp_claim.
DATA received TYPE i.
CALL FUNCTION 'Z_EXP_READ_CLAIM'
STARTING NEW TASK 'T1'
DESTINATION 'EXP_REMOTE'
PERFORMING claim_done ON END OF TASK
EXPORTING
claim_id = 'C-0001'
EXCEPTIONS
system_failure = 8
communication_failure = 12
resource_failure = 16.
CALL FUNCTION 'Z_EXP_READ_CLAIM'
STARTING NEW TASK 'T2'
DESTINATION 'EXP_REMOTE'
PERFORMING claim_done ON END OF TASK
EXPORTING
claim_id = 'C-0002'
EXCEPTIONS
system_failure = 8
communication_failure = 12
resource_failure = 16.
WAIT FOR ASYNCHRONOUS TASKS UNTIL received = 2.
FORM claim_done USING task TYPE clike.
RECEIVE RESULTS FROM FUNCTION 'Z_EXP_READ_CLAIM'
IMPORTING claim = claim
EXCEPTIONS
system_failure = 8
communication_failure = 12.
IF sy-subrc = 0.
received = received + 1.
ENDIF.
ENDFORM.
Source: Keyword Documentation for Standard ABAP: CALL FUNCTION STARTING NEW TASK, CALL FUNCTION STARTING NEW TASK, parameter_list, RECEIVE and WAIT FOR ASYNCHRONOUS TASKS
A caution about the sketch: both claims land in the same claim variable, so only the count is meaningful here. A real
program would collect each result into an internal table inside the callback, using the task identifier to tell the
results apart.
Background RFC and the obsolete tRFC and qRFC
A background call is not run at once: it is stored and sent when the program says COMMIT WORK, so it is as reliable as the
local database change it belongs to. The old form, transactional RFC, is CALL FUNCTION func IN BACKGROUND TASK, with the
optional DESTINATION (default NONE) and AS SEPARATE UNIT. It registers the name, destination and parameters under a
unique transaction ID (TID) in two database tables of the caller, which transaction SM58 shows. At COMMIT WORK the calls
of the SAP LUW start in registration order; ROLLBACK WORK deletes the registrations. If the destination is not available
at the commit, a background job retries, by default every 15 minutes and up to 30 times. Queued RFC adds the guarantee that
the calls arrive in the same order, by naming a queue before the tRFC.
Both are obsolete. The Keyword Documentation says that background RFC, written CALL FUNCTION func IN BACKGROUND UNIT oref,
is the enhanced successor that includes and extends tRFC and qRFC, and that it should be used instead. The object oref must
implement the interface IF_BGRFC_UNIT; it holds the destination, whether the call is transactional or queued, and the
queue names. Calls that share one object run as one unit, and several objects with different queues or destinations run in
parallel. Inside a unit, COMMIT WORK, ROLLBACK WORK and any implicit database commit are forbidden. If a bgRFC unit and an
update module belong to the same SAP LUW, the unit waits for the update; the object method SEPARATE_FROM_UPDATE_TASK
decouples it. The background processing framework (bgPF) wraps bgRFC so that a time-consuming method can run asynchronously.
This page shows no bgRFC code, because the way to obtain a unit object is not described on the keyword page.
What older books show, and what has changed
Older ABAP books present the six variants as equals and write tRFC as the standard way to send data reliably. Today:
-
IN BACKGROUND TASK(tRFC) and queued RFC are marked obsolete; bgRFC replaces them, and new code must useIN BACKGROUND UNIT. -
A book may show
CALL FUNCTION ... DESTINATIONin every program. In ABAP Cloud the call is limited to the synchronous form and needs a communication target instead of an SM59 name; aRFC and the others are not in the cloud keyword pages. -
Books show subroutines as callbacks (
PERFORMING subr ON END OF TASK). Creating subroutines is obsolete in general; the keyword page offers a method (CALLING meth ON END OF TASK) with the same behavior. -
The older advice to call a BAPI from anywhere no longer holds for ABAP Cloud, where only released objects are allowed.
-
Books treat IDoc and ALE as the way to distribute data. SAP still documents and supports it for classic and on-premise systems, but new cloud-ready scenarios use business events and released APIs; see RAP Business Events.
BAPIs and the Business Object Repository
SAP defines its business data as business objects, for example a customer or a purchase order. The Business Object Repository (BOR) lists the object types and their methods. A BAPI, Business Application Programming Interface, is a method of such an object type that is meant for use from outside: it is defined in the BOR, it follows strict design guidelines, and it is implemented as an RFC-enabled function module. The point of the guidelines is a stable interface: the BAPI keeps its parameters when SAP changes the internals, so a non-SAP program can call "create a sales order" without knowing the tables. A BAPI can also be implemented outside the SAP system and called from it.
Two details of the design are important for a programmer:
-
A BAPI reports success and failure in a return parameter whose reference structure is
BAPIRET2(a message list). If the type field of an entry isA(abort) orE(error), the call failed. The ALE documentation describes this convention for BAPIs that are used asynchronously: withEthe status 51 is written andROLLBACK WORKexecuted, otherwise status 53 and aCOMMIT WORK. -
A BAPI that changes data must not commit itself when it is used in an ALE process. The documentation says a BAPI implemented as an asynchronous interface "must not issue a COMMIT WORK". The caller decides when to commit. This is the SAP LUW rule of SAP LUW, Update Tasks and Commit applied to BAPIs.
To define your own BAPI you work in your own namespace. You can copy and modify the function module of an existing BAPI and, in the BOR, create a subobject type of its object type in the customer namespace using the Business Object Builder (menu path Tools, Business Framework, BAPI Development). The subtype inherits the methods of the business object; the object type gets the status Implemented.
Source: ALE Programming Guide: Distribution Using BAPIs, Implementing Your Own BAPIs and Keyword Documentation for Standard ABAP: BAPI
Calling a BAPI and committing it
A BAPI that changes data does not make the change permanent by itself. The caller checks the return table, and then calls the
function module BAPI_TRANSACTION_COMMIT to commit, or BAPI_TRANSACTION_ROLLBACK to undo. Both are in the function group
BAPT and are listed as released for SAP Cloud ERP in the Cloudification Repository, so they can be called from ABAP Cloud
code too. Practitioner discussions on the SAP Community describe a parameter WAIT of the commit function: a blank value
gives a plain COMMIT WORK, a non-blank value gives COMMIT WORK AND WAIT, which is needed when a following BAPI depends on
the changes of the first. The SAP Community is not an official documentation page, so check the interface of the module in
transaction SE37 or in ADT before relying on it.
The sketch shows the pattern with a placeholder for the BAPI of your business case; this page does not invent a BAPI name for expense claims. It needs an SAP system and a BAPI; it is not run here.
DATA return TYPE STANDARD TABLE OF bapiret2 WITH EMPTY KEY.
" CALL FUNCTION '<your BAPI>' ... TABLES or IMPORTING return = return ...
IF line_exists( return[ type = 'E' ] ) OR line_exists( return[ type = 'A' ] ).
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = abap_true.
ENDIF.
Source: ALE Programming Guide: Implementing Your Own BAPIs (return parameter and type values), Cloudification Repository (the two modules are released) and SAP Community: How and when to use WAIT parameter in BAPI_TRANSACTION_COMMIT (community source for the WAIT parameter)
BAPIs in ABAP Cloud and in a clean core
The Cloudification Repository, SAP’s list of released and classic APIs, shows the situation for BAPIs. For SAP Cloud ERP the
file objectReleaseInfoLatest.json marks BAPI_TRANSACTION_COMMIT and BAPI_TRANSACTION_ROLLBACK as released, while it
marks BAPI_ACC_DOCUMENT_POST as not to be released and names the successor I_JOURNALENTRYTP, a RAP business object
interface. For SAP Cloud ERP Private, the file objectClassifications_SAP.json lists a large number of function modules as
classic APIs, among them BAPI_ACC_DOCUMENT_POST and BAPI_USER_CHANGE, with the label remote-enabled. A classic API is
still usable in the clean core model, but not directly from ABAP Cloud code. The repository points to a generator for
wrappers (the transaction ACO_PROXY and the SAP-samples project tier2-rfc-proxy) that produces a released wrapper class
for a non-released remote-enabled module such as a BAPI, so that ABAP Cloud code calls the wrapper. How released objects
and classic APIs are classified is the subject of
ABAP Language Versions and Released APIs, and
how a RAP business object can wrap a function module is shown in
RAP: Managed and Unmanaged Implementation.
IDocs
An IDoc (intermediate document) is the exchange format of the IDoc interface. The interface consists of a data structure definition and the processing logic for it. IDocs exist so that two systems can exchange business data without the data having to exist already as application documents on the receiving side, and so that errors can be handled with SAP Business Workflow. You meet IDocs in electronic data exchange (EDI), in the connection of other business systems, and in ALE.
The three records
An IDoc is stored in three database tables, and viewed from outside it has three record kinds.
| Record | Content |
|---|---|
Control record |
One per IDoc and identical in structure for all IDocs. It holds the administration data: sender, recipient, message, direction and IDoc type, and the last processing status in the field |
Data records |
The application data, stored in segments. Each data record carries the segment data in the field |
Status records |
Every status the IDoc went through, with administration information. They are not sent as part of the IDoc but as a separate data packet. |
IDoc number 0000000000012345 (example number)
control record : sender, recipient, message type, IDoc type, direction, STATUS
data records : parent segment (PSGNUM = parent number, HLEVEL = 01)
child segment (PSGNUM = parent number, HLEVEL = 02)
status records : one record per status the IDoc went through
The sketch only shows the shape; the IDoc number is an example, and the field names come from the documentation of the technical structure. The segment name starts with E1 for SAP segments, and a segment can be the child of several parents: the documentation names the segment E1EDPT1 as a child of E1EDP01 in the IDoc type EXPINV01 and of E1EDP07 in DESADV01. An IDoc type is defined by the segments it permits and their parent-child relations. A customer extension adds new segments as children of existing ones of the basic type, in the customer namespace. The message type names the business function, the IDoc type is its technical structure; ORDERS01 is the IDoc type that the documentation uses for a purchase order. The IDoc interface can check, per partner profile and direction, that the segments of an IDoc fit the definition of its type.
The status values are numbers. The documentation names these: 51 (application document not posted), 53 (application document posted), 63 (error passing the IDoc to the application), 69 (IDoc edited) and 70 (original of an IDoc that was edited); 03 carries the transaction ID of a tRFC port. A traffic light in the IDoc display turns the status into green, red or yellow through status groups.
Source: IDoc Display and ALE: Error Handling
Outbound, inbound and status processing
The IDoc interface supports three data flows. In outbound processing your system writes document data to IDocs and sends
them to a receiving system. There are two paths: indirect through Message Control, which finds the message by conditions, and
direct from the application, which builds the IDoc itself and hands it over with the function module
MASTER_IDOC_DISTRIBUTE. In inbound processing the interface first saves the IDoc in the database, and only in a second,
independent step creates the application document, so that the sender can transfer data quickly and reliably. The second step
runs either by a function module or through SAP Business Workflow. In status processing the receiving system confirms the
processing status of an outbound IDoc back to the sender, with status records, either through the file port or as an IDoc of
type SYSTAT01.
Which module reads or writes the data is decided by a process code in the partner profile. The inbound process code ORDE,
for example, assigns the function module IDOC_INPUT_ORDERS to the message ORDERS in the documentation’s example for a vendor
who receives an order. Process codes are maintained in transactions WE41 (outbound) and WE42 (inbound), and WE64 documents
them. Two preconditions precede any exchange: a port describes the technical link to the other system, and a partner
profile defines which messages the partner may exchange, through which port, and how inbound messages are processed. Port
types in the documentation are the file interface (most EDI subsystems), transactional RFC (ALE scenarios), CPI-C (R/2),
a programming interface and XML.
Errors and the monitor
When an error occurs the interface creates work items in the Business Workplace of the responsible agents; the agents are read
from the partner profiles. If an inbound IDoc is not posted (status 51 or 63), the report RBDMANI2 can resubmit it, also
as a periodic job for lock problems. A user can edit an incorrect IDoc in exception handling: it then gets status 69 and the
original is kept as a new IDoc with status 70. Each IDoc can be displayed as a tree of its records under the SAP menu
Tools, IDoc Interface/ALE, Administration, Monitoring.
ALE basics
Application Link Enabling integrates business processes between SAP systems, and between SAP and non-SAP systems. Its idea is a distributed but integrated installation: each system has its own database, and business messages, not a central database, connect them. ALE exchanges data asynchronously, so the data arrives even when the receiver is down at the moment of sending; synchronous connections are used only to read data. It has three layers, application services, distribution services and communication services, and it distributes master data, customizing data and transaction data.
There are two programming models. Distribution using message types defines message types and IDoc types and the ABAP code
for outbound and inbound processing. Distribution using BAPIs uses a BAPI as the interface: a synchronous call goes over an
RFC destination assigned in ALE customizing, and an asynchronous one uses a generated BAPI-ALE interface, which turns the call
into an IDoc and back. ALE is configured in the Implementation Guide (transaction SPRO, or SALE for the ALE part), and it
brings roles such as SAP_BC_MID_ALE_ADMIN and SAP_BC_MID_ALE_DEVELOPER. IDocs can be sent one by one or in packets: in mass
processing one RFC call transfers several IDocs, which is considerably faster with good packet sizes. ALE error handling is
built on SAP Business Workflow, with IDocs as the objects and a work item in the inbox of the responsible employee.
Source: ALE Integration Technology, Application Link Enabling (ALE), Distribution Using Message Types, Mass Processing of IDocs and Error Handling
The ALE pages used here belong to the ABAP Platform documentation of the classic integration technology. They describe the mechanism correctly, but their menu paths come from older releases, so check each path in your system.
Common mistakes
-
Calling an RFC between statements that open and close a database cursor; every synchronous or asynchronous RFC commits.
-
Declaring a class-based exception in a remote-enabled module and expecting the caller to see it: the caller gets
SYSTEM_FAILURE. -
Passing a reference variable or a type-pool type in the interface of a remote-enabled module.
-
An empty destination name: the call silently becomes a local call.
-
Using tRFC or qRFC in new code instead of bgRFC.
-
A callback routine without
RECEIVE RESULTS, which leaves the connection open. -
Forgetting
BAPI_TRANSACTION_COMMITafter a BAPI that changes data, so that the change is never made permanent, or committing inside a BAPI that is also used by ALE. -
Ignoring the
BAPIRET2entries of typeEorAand committing anyway. -
Confusing the IDoc with the application document: an IDoc can be saved and still not posted (status 51 or 63 on inbound), and status 53 says the application document was posted.
Summary
-
RFC calls a remote-enabled function module in another system. The call has variants: synchronous (sRFC), asynchronous (aRFC) and parallel (pRFC), and background (bgRFC); tRFC and qRFC are obsolete and bgRFC replaces them.
-
The target is an RFC destination (SM59, dynamic, predefined) in classic ABAP and a communication target in ABAP Cloud, where only the synchronous call remains.
-
A remote-enabled module passes parameters by value, uses Dictionary or built-in types and only classic exceptions; every synchronous or asynchronous RFC causes a database commit.
-
A BAPI is a remote-enabled function module that is a method of a business object in the BOR. Check its
BAPIRET2return, then commit withBAPI_TRANSACTION_COMMITor undo withBAPI_TRANSACTION_ROLLBACK; in ABAP Cloud a classic BAPI is wrapped. -
An IDoc has a control record, data records of segments and status records. Outbound, inbound and status processing, ports, partner profiles and process codes move it, and ALE uses it to distribute data between loosely linked systems.
References
-
Keyword Documentation for Standard ABAP: RFC - Authorizations
-
Keyword Documentation for Standard ABAP: CALL FUNCTION DESTINATION
-
Keyword Documentation for Standard ABAP: CALL FUNCTION DESTINATION, parameter_list
-
Keyword Documentation for Standard ABAP: CALL FUNCTION STARTING NEW TASK
-
Keyword Documentation for Standard ABAP: CALL FUNCTION STARTING NEW TASK, parameter_list
-
Keyword Documentation for Standard ABAP: WAIT FOR ASYNCHRONOUS TASKS
-
Keyword Documentation for Standard ABAP: CALL FUNCTION, IN BACKGROUND TASK
-
Keyword Documentation for Standard ABAP: CALL FUNCTION IN BACKGROUND UNIT
-
Keyword Documentation for ABAP Cloud: CALL FUNCTION, IN REMOTE SESSION
-
SAP-samples/tier2-rfc-proxy: Generator for custom wrappers for RFC function modules
-
SAP Community: How and when to use WAIT parameter in BAPI_TRANSACTION_COMMIT (community discussion, not official documentation)