Integrating IDocs through OpenAPI

With our latest release of Callable we now support sending SAP IDocs in addition to RFC and BAPI calls.

IDocs (or intermediate documents) are still the preferred way of asynchronous integration with SAP. Typical use cases for IDocs are order, billing, and invoicing processes or master data integration into SAP ERP.

The challenges with IDoc integration for external system developers is to create correct data formats exposed mainly inside the SAP system.

The current release of Callable radically simplifies IDoc integration by exposing IDocs in easy consumable Open API 3.0 format.

Create Businesspartner via IDoc

Here is an example how to create a Business partner in an ERP system via the „BUPAFS_FS_CREATE_FRM_DATA01” IDoc with Callable.

The first step is to choose the IDoc definition from the Callable Resource Index. This Index represent all registered RFCs and IDocs available of your connected system.

IDoc listing for BUBUPAFS_FS_CREATE_FRM_DATAPA

We choose the entry with the name „BUPAFS_FS_CREATE_FRM_DATA01/BUPA_FS_CREATE_FRM_DATA“ from the list.

The “long” name for the IDoc contains a combination of IDoc type and message type. An Idoc Type defines the structure of the IDoc, the message type the application use case defined by SAP (or you).

Callable concatenates IDoc type/Message type as name and displays any available combination per IDoc type.

Create an API request

To get the API definition for this IDoc type, just click on the entry and a Swagger UI preloaded with the IDoc API definition will load.

API definition

The API definition lists all fields of the IDoc including optional EDI_DC40 headers for routing purposes in a SAP system. For the sake of simplicity we just use a few fields that are needed to create a business partner as a person. These are e.g. first and last name and the flag to categorize if its a person or organisation.

Therefore we will use the following reduced JSON input:

{
  "EDI_DC40": {
       "SNDPRN": "CALLABLE",
       "SNDPRT" : "LS"
  },
  "E1BUPAFS_FS_CREATE_FRM_DATA": [
    {
      "BUSINESSPARTNEREXTERN": "A123456789",
      "PARTNERCATEGORY": "1",
      "E1BPBUS1006_CENTRAL_PERSON": [
        {
          "FIRSTNAME": "Andy",
          "LASTNAME": "Smith"}
      ]
    }
  ]
}

You might now wonder how you would know what field values are allowed for particular fields of the JSON structure like the value “1” of PARTNERCATEGORY. The answer is quite simple, all restricted fields are displayed in the open API Schema view.

Here you can see what field values are allowed for PARTNERCATEGORY (here 1 = Person, 2 = Organization, 3 = Group)

SAP partner category

API model

The second thing you’ll notice in the JSON example is the EDI_DC40 headers. The values used there are actually depended on your SAP internal configuration.

We created an inbound partner profile for Callable as Logical system in the SAP system. Therefore we set the Partnernumber “CALLABLE” as SNDPRN and “LS” for Logical System (SNDPRT).

Partner Profiles (WE 20) in our SAP system

We paste the reduced JSON back to and hit “Execute” to actually send the IDoc from the OpenAPI view:

API request data

Callable returns a 200 response plus the Transaction ID of a successful transmission into the SAP system. We re done.

The Idoc is successfully created inside the SAP system and can be further asynchronously processed via direct processing or batch jobs to create the business partner.

API response data

The TID (transaction Id), that is returned is also useful to lookup IDoc numbers for monitoring purposes, which you can do by simply exposing an endpoint to the RFC function module “/INBOUND_IDOCS_FOR_TID” through Callable. This function module allows you to fetch the IDoc number of the call.

Now let’s have a look at the SAP GUI to check the partner is really created.

Navigate to transaction “BP” in your SAP system.

We use the field businesspartner number for search and enter the value “A1234567889” that we submitted as external reference id.

Here we are:

SAP BUPA view

Summary

We created a business partner with submitting an IDoc through callable. In order to do that we only need two things:

  • A Partner Profile for Callable maintained in the SAP system.
  • Create a new endpoint for the actual IDoc.
  • Set the necessary fields to execute the call and send it to the system

callable.cloud

SAP integration just a container away!

Powered by APImeister Consulting GmbH (imprint)