IDoc messaging
Overview
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 – ASAPIO Integration Add-on now allows you to use all your SAP standard and custom IDocs in today’s heterogeneous IT landscapes and for event-driven architecture – code-less!
- On-the-fly IDoc conversion to JSON-based messages, bidirectional
- for SAP-to-SAP connectivity via data brokers and platforms
- for SAP-to-any connectivity, using IDocs as a proven and reliable interface
Send IDocs as outbound JSON message
Create Logical System
- Transaction: SALE
- Select the created Connection
- Go to section Basic Settings → Define Logical System
- Add New Entry and specify:
- Log.System: Name has to be “LOCAL”
- Name: choose a description
Create Customer Distribution Model
- Transaction: BD64
- Create Model View and specify:
- Sender: Sending client
- Recipients: Logical system (LOCAL)
- Add message type as required (e.g., MATMAS)
Create IDoc Port
- Transaction: WE21
- Select the created Connection
- Go to section ABAP-PI
- Add New Entry and specify:
- Port: choose a name (e.g., ACI_IDOC)
- Description: choose a description
- Function module: /ASADEV/ACI_IDOC_PORT_TRIGGER
Create Partner profiles
Note:
Make sure a Distribution model is available (Transaction BD64)
- Transaction: WE20
- Open folder: Partner Type LS
- Go to section Outbound Options.
- Receiver port: ACI_IDOC
- Basic Type: MATMAS05
Create Outbound Object
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.
- Transaction: SPRO
- Goto ASAPIO Cloud Integrator → Connection and Replication Object Customizing
- Or go directly to transaction: /ASADEV/68000202
- Select the created Connection
- Go to section Outbound Objects
- Add New Entry and specify:
- Object: name of the outbound configuration
- Extraction Func. Module: /ASADEV/ACI_GEN_VIEW_EXTRACTOR
- Message Type: Specific message type (Example: Z_SAP_EM_MATMAS)
- Load Type: Incremental Load
- Trace: activate for testing purposes
- Extraction view name: EDID4
- Formatting Function: /ASADEV/ACI_GEN_IDOC_FORMATTER
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:
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’
Link the configuration of the outbound object to a Business Object event:
- Navigate to Outbound Objects → Event Linkage or use transaction SWE2.
- Add New Entry and specify:
- Object Category: BO BOR Object Type
- Object Type: /ASADEV/ID
- Event: ACI_TRIGGER_EVENT
- Receiver Function Module: /ASADEV/ACI_EVENTS_TRIGGER
- Linkage Activated: tick the checkbox
- Check Function Module: /ASADEV/ACI_EVENTS_CHECK
Set-up ‘Header Attributes’
Specific for the IDoc Outbound use-case you have to specify the header attributes:
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.
Set-up ‘Header Attributes’ – General
Header attribute | Header attribute value |
BOR_ATTRIBUTE_MessageType | Select single IDoc type by message type (e.g. “MATMAS”) |
Set-up ‘Header Attributes’ – Azure
Header attribute | Header attribute value |
AZURE_TOPIC | Topic/Queue (e.g., “/my_topic”) |
Set-up ‘Header Attributes’ – Confluent/Kafka
Header attribute | Header attribute value |
KAFKA_TOPIC | Topic/Queue (e.g., “sap_demo.matmas”) |
Set-up ‘Header Attributes’ – Solace
Header attribute | Header attribute value |
SOLACE_TOPIC | Topic/Queue |
SOLACE_CALL_METHOD | POST |
SOLACE_CONT_TYPE | text/plain |
SOLACE_DELIV_MODE | Persistent |
Set-up ‘Header Attributes’ – SAP-EM
Header attribute | Header attribute value |
SAP_EM_TOPIC | Topic/Queue (e.g. /myqueue) |
SAP_EM_CALL_METHOD | POST |
SAP_EM_CONT_TYPE | application/json |
SAP_EM_QOS | 0 |
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:
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 Message Type
- Create message type, If not already done before during the Outbound configuration.
- Transaction: WE81
Activate Message Type
- Transaction: BD50
- Add New Entry and specify:
- Message Type: the created message type
- Active: tick the checkbox
Create Partner profiles
- Transaction: WE20
- Open folder: Partner Type LS
- Select your Partner No.: LOCAL
- Go to section Inbound parameters.
- Add New Entry and specify:
- Message type: MATMAS
- Process code: MATM
- Message Type: the created message type (Example: MATMAS)
Create Inbound Object
- Transaction: SPRO
- Go to ASAPIO Cloud Integrator – Connection and Replication Object Customizing
- Or go directly to transaction: /ASADEV/68000202
- Select the created Connection
- Go to section Inbound Objects
- Add New Entry and specify:
- Object: name of the inbound configuration
- Extraction Func. Module: /ASADEV/ACI_JSON_TO_IDOC
- Message Type: the created message type (Example: MATMAS)
- Trace: activate for testing purposes
Example configuration:
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’
In addition, header attributes of message type MATMAS are filled with the topics (depending on your connector):
Set-up ‘Header Attributes’ – Azure
Header attribute | Header attribute value |
AZURE_QUEUE_NAME | Topic/Queue (e.g. “myqueue”) |
AZURE_PULL_DURATION | 3 |
AZURE_PULL_WAIT | 1 |
Set-up ‘Header Attributes’ – Confluent/Kafka
Header attribute | Header attribute value |
KAFKA_DOWNLOAD_ACCEPT | application/vnd.kafka.json.v2+json |
KAFKA_DOWNLOAD_TOPIC | Topic/Queue (e.g., “sap_demo.matmas”) |
KAFKA_GROUPNAME | asapiogroup |
KAFKA_INSTANCE_NAME | asapio_matmas_consumer |
KAFKA_MAX_BYTES | 1000000 |
KAFKA_TIMEOUT | 1000 |
JSON schema for IDoc creation
When an Inbound message is received from the broker, it will usually be a 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 a documentation and XML schema with the fields that are available for the according IDoc.
Example MATMAS05:
- Transaction: WE60
- Basic type: MATMAS05
- Select More → Documentation → XML Schema
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.
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
Note:
Message type should be ARTMAS in our example (ECC)
Start transaction BD10 to send a material to the topic:
Note:
If you already have objects in a topic at a broker of your choice, the steps above are not needed and you can start testing from here.
Start transaction /n/ASADEV/ACI
Choose your configured Connection and Replication Object:
-
- Connection: 00Confluent
- Replication Object: KAFKA_MATMAS_INBOUND