There are many different ways of interfacing with an SAP system. Some require additional middleware and others require extensive configuration or setup. For platforms like Ignition that are built on Java, SAP provides a library called the Java Connector ("JCo") to enable bidirectional communication to an SAP system.
Not to be confused with Functional Modules, Function Modules are encapsulated ABAP code. They have documented interfaces for inputs and outputs, similar to a function signature. Typical SAP installations come bundled with hundreds of Function Modules, and developers can also create their own.
Function Modules can be configured to be "Remote-Enabled," which means they can be accessed from external applications via the Remote Functional Call (RFC) protocol.
Note to programmers: Function Modules can be thought of as SAP's version of a function. Similarly, Function Groups are akin to Python modules or Java packages. Designating a Function Module as "Remote-Enabled" is like declaring a Java function as Public.
Business Application Programming Interfaces ("Business APIs" or most commonly "BAPIs") are another form of encapsulated ABAP code. Whereas Function Modules are organized into Function Groups, all BAPIs are organized by and associated to a corresponding Business Object. BAPIs are standardized by SAP; unlike Function Modules, BAPIs tend to be consistent between versions, which tends to make them a safer interface technology than Function Modules.
Unlike Function Modules, BAPIs are always "remote-enabled," as they are intended to be called from external systems by design. Developers can also create their own BAPIs (typically called "ZBAPIs").
Note to programmers: BAPIs can be thought of as SAP's version of a method. Some BAPIs are like constructors or static methods in that they are associated with a class, while others are akin to instance methods, in that they are associated with an instance of a class (i.e., an object).
BAPIs and Function Modules are called via the Remote Function Call (RFC) protocol. SAP allows for three (3) different calling types.
Synchronous RFCs (sRFCs) immediately return a response. These are ideal for requesting data (e.g., get production orders), as the data will be the most up-to-date and there is no risk of calling the RFC multiple times.
If an sRFC fails, the calling program will know right away, after which it can parse out the error message and either retry the call or pass it into a queue for manual reconciliation.
Transaction RFCs (tRFCS) are processed asynchronously and include a unique Transaction ID. If an RFC is called with the same Transaction ID multiple times, SAP will ignore subsequent calls while still returning an “OK” status. tRFCs should be used for submitting data (e.g., posting a production order confirmation) where it is important that a call is not duplicated.
The calling program will not immediately know when a tRFC has been processed, only whether or not it has been received by the SAP system. Similarly, if a tRFC fails, the calling program will not be notified. Instead, the calling program may manually query the tRFC status by reading from the ARFCSSTATE table using the RFC_READ_TABLE function module.
Similar to tRFCs, queued RFCs (qRFCs) are processed asynchronously and require a Transaction ID. They are built on top of tRFCs and have the added protection of ensuring that messages are processed in the correct order. This is important for executing sequences where order matters (e.g., posting a Goods Receipt prior to marking a Production Order as Technically Complete (TECO)).
As with tRFCs, the calling program will not immediately know when a qRFC has been processed, only whether or not it has been received by the SAP system. Similarly, if a qRFC fails, the calling program will not be notified. Instead, the calling program may manually query the qRFC status using a function module like TRFC_GET_QIN_INFO. Once the transaction has left the queue, its status may be queried like any other tRFC – i.e., by reading from the ARFCSSTATE table using the RFC_READ_TABLE function module.