Docs / Outbound Messaging

IDoc Messaging

IDoc messages have been the gold standard of reliable SAP-to-SAP communication for many years in SAP ERP, and are still strategic and relevant for SAP S/4HANA. The ASAPIO Integration Add-on lets you use your standard and custom IDocs in today's heterogeneous IT landscapes and for event-driven architecture — code-less.

Related articles: Installation, Connectors, Inbound messaging, Monitoring, Support.

Overview

IDoc bidirectional conversion overview between SAP and JSON-based messaging

Send IDocs as Outbound JSON Message

Create Logical System

Logical systems define unique identifiers for SAP systems that exchange IDocs. "LOCAL" is used to represent the current system. Creating a logical system ensures that IDocs can be correctly routed to and from this system.

Create Customer Distribution Model

(Optional — required for outbound IDocs only)

A distribution model controls which systems (logical systems) will receive outbound IDocs for specific message types. Without this model, outbound messages cannot be sent correctly.

Create IDoc Port

(Optional — required for outbound IDocs only)

IDoc ports define the technical connection and function module to be used when sending IDocs. They allow the system to route outbound IDocs to the correct interface.

WE21 IDoc port configuration with the ACI_IDOC_PORT_TRIGGER function module

Create Partner Profiles

Partner profiles define how IDocs are received or sent for each logical system. LOCAL is used for the current system, and it stores inbound and outbound settings including message types and processing codes.

WE20 partner profile outbound parameters for message type MATMAS

Create Outbound Object

Outbound objects define the data to extract from SAP and convert into JSON messages. This enables IDocs to be published to brokers automatically as JSON.

Note: In the example below, we want to trigger an outbound message for SAP material master IDocs (IDoc name "MATMAS"), convert the IDoc payload to JSON and send it to an event broker instance.

Data extraction will be carried on by a generic extractor (/ASADEV/ACI_GEN_VIEW_EXTRACTOR) with message type Z_SAP_EM_MATMAS. The generic extractor reads and extracts the data contained in the view EDID4, which has the information related to the IDOCs.

Example configuration:

Outbound object configuration for IDoc MATMAS using the generic view extractor and IDoc formatter

Data extraction will be carried out by a generic extractor (/ASADEV/ACI_GEN_VIEW_EXTRACTOR) with message type Z_SAP_EM_MATMAS. The generic extractor reads and extracts the data contained in the view EDID4, which has the information related to the IDOCs.

Set Up 'Event Linkage'

Event linkage connects the outbound object to a Business Object event. This ensures IDocs trigger JSON messages in real time.

SWE2 event linkage for BOR object ASADEV ID and event ACI_TRIGGER_EVENT

The BOR object /ASADEV/ID and its event ACI_TRIGGER_EVENT are part of the ASAPIO Integration Add-on framework.

In short, this linkage connects the business logic event of an outbound IDoc to the ASAPIO add-on's event-driven processing framework, ensuring that IDocs are automatically converted and sent without manual intervention.

Set-Up 'Header Attributes' (Outbound)

Header attributes specify metadata for the IDoc message, including which message type and broker topic to use.

BOR_ATTRIBUTE_MessageType with the actual message type of the IDoc you want to send (e.g. MATMAS). This will be used in the check function module to filter out IDocs that are not relevant.

Header attribute BOR_ATTRIBUTE_MessageType configuration for outbound IDoc filtering

Set-Up 'Header Attributes' — General

Header attributeHeader attribute value
BOR_ATTRIBUTE_MessageTypeSelect single IDoc type by message type (e.g. "MATMAS")
ACI_IDOC_DIRECT_COMMITX
By default, the ASAPIO Integration Add-on creates the inbound IDoc without triggering an immediate commit, allowing a rollback if the process code encounters an error. To enable a direct commit, activate the corresponding attribute.
Note: This attribute can be configured either at object level (applying only to a specific inbound object) or as a global default (applying to all inbound objects in the instance). If both are set, the object-level configuration takes precedence over the global default.

Set-Up 'Header Attributes' — Azure

Header attributeHeader attribute value
AZURE_TOPICTopic/Queue (e.g. "/my_topic")

Set-Up 'Header Attributes' — Confluent/Kafka

Header attributeHeader attribute value
KAFKA_TOPICTopic/Queue (e.g. "sap_demo.matmas")

Set-Up 'Header Attributes' — Solace

Header attributeHeader attribute value
SOLACE_TOPICTopic/Queue
SOLACE_CALL_METHODPOST
SOLACE_CONT_TYPEtext/plain
SOLACE_DELIV_MODEPersistent

Set-Up 'Header Attributes' — SAP-EM

Header attributeHeader attribute value
SAP_EM_TOPICTopic/Queue (e.g. /myqueue)
SAP_EM_CALL_METHODPOST
SAP_EM_CONT_TYPEapplication/json
SAP_EM_QOS0

Test the Outbound IDoc Event Creation

Note: Message type should be MATMAS in our example (screenshot shows ARTMAS because it's a retail system).

Start transaction BD10 to test the described formatter:

BD10 transaction used to test the outbound IDoc formatter

Results can be shown in transaction /ASADEV/ACI_MONITOR.

Receive IDocs from Inbound JSON Message

Note: In the example below, we want to receive an inbound message for SAP material object from an event broker, which will be a JSON format. The JSON payload will be converted into an IDoc (IDoc name "MATMAS").

Create Partner Profile

Partner profiles define inbound processing rules, including which process code to trigger for incoming JSON messages.

WE20 inbound partner profile for message type MATMAS with process code MATM

Create Inbound Object

Inbound objects define which JSON messages to process and convert into IDocs.

Example configuration:

Inbound object configuration for message type MATMAS using the JSON to IDoc extractor

Data extraction will be carried on by a generic extractor (/ASADEV/ACI_JSON_TO_IDOC) with message type MATMAS. The generic extractor reads and extracts the data into 1 to multiple IDOCs.

Set-Up 'Header Attributes' (Inbound)

In addition, header attributes of message type MATMAS are filled with the topics (depending on your connector):

Set-Up 'Header Attributes' — Azure

Header attributeHeader attribute value
AZURE_QUEUE_NAMETopic/Queue (e.g. "myqueue")
AZURE_PULL_DURATION3
AZURE_PULL_WAIT1

Set-Up 'Header Attributes' — Confluent/Kafka

Header attributeHeader attribute value
KAFKA_DOWNLOAD_ACCEPTapplication/vnd.kafka.json.v2+json
KAFKA_DOWNLOAD_TOPICTopic/Queue (e.g. "sap_demo.matmas")
KAFKA_GROUPNAMEasapiogroup
KAFKA_INSTANCE_NAMEasapio_matmas_consumer
KAFKA_MAX_BYTES1000000
KAFKA_TIMEOUT1000
Inbound header attributes configured for the Kafka connector

JSON Schema for IDoc Creation

When an inbound message is received from the broker, it will usually be in JSON format.

The ASAPIO Integration Add-on will create an IDoc out of the JSON file.

In order to see which fields are needed for the IDoc creation, go to transaction WE60. There you will find documentation and an XML schema with the fields that are available for the according IDoc.

Example MATMAS05:

WE60 basic type documentation navigation for MATMAS05
WE60 XML schema selection for MATMAS05

The WE60 documentation will provide you the available fields in an XML format, which can be part of your JSON file that you want to send inbound.

WE60 XML schema field list for MATMAS05
Note: Watch the mandatory fields of the JSON header highlighted as seen below.
"EDI_DC40": [
  {
    "TABNAM": "",
    "MANDT": "",
    "DOCNUM": "",
    "DOCREL": "",
    "STATUS": "",
    "DIRECT": "",
    "OUTMOD": "",
    "IDOCTYP": "MATMAS05",
    "MESTYP": "MATMAS",
    "SNDPOR": "ACI_TEST",
    "SNDPRT": "LS",
    "SNDPRN": "LOCAL",
    "RCVPOR": "",
    "RCVPRT": "LS",
    "RCVPRN": "",
    "CREDAT": "",
    "CRETIM": "",
    "SERIAL": ""
  }
],

Test the Inbound IDoc Creation

Testing inbound IDoc creation verifies that JSON messages received from the broker are correctly converted into SAP IDocs. ASAPIO supports two modes for inbound messages, depending on your broker: PUSH-Based and PULL-Based.

PUSH-Based

In PUSH mode, the broker actively sends messages to SAP as soon as they are available. SAP does not need to poll the broker; instead, the event is triggered automatically by the broker, and ASAPIO receives the JSON payload in real time. The inbound function module /ASADEV/ACI_JSON_TO_IDOC processes the payload and creates the corresponding IDoc.

Steps:

  1. Activate the service asadev in transaction SICF.
  2. Push the message to the URL of the asadev service, combining the Inbound Object Instance and Object name:
https://<saphost>:<port>/asadev/<Instance>/<Object>

PULL-Based

In PULL mode, SAP periodically polls the broker or message queue to retrieve available JSON messages. This is useful for systems that cannot receive real-time push events or for testing purposes. ASAPIO will read the messages during the scheduled pull and process them into IDocs.

Start transaction /n/ASADEV/ACI.

Choose your configured Connection and Replication Object:

/n/ASADEV/ACI PULL-based connection and replication object selection
PULL-based inbound message list for the selected replication object
PULL-based inbound message detail view