Skip to Content
Author's profile photo Kirill Levitskiy

How to send IDOCs from SAP MII to SAP ERP

Hello, friends!

Once, we faced with objective of implementation SAP MII transaction and managing mechanism to creating correct IDOC and sending it to SAP MDG (this instruction applicable to all SAP ERP systems).

Goal: to implement regularly sending needed data of contractors from non-SAP system to SAP MDG using SAP MII.

At first, we looking for mechanism of sending IDOCs from SAP MII to SAP MDG. After some time of searching we have found RFC IDOC_INBOUND_ASYNCHRONOUS at SAP MDG.


IDOC_INBOUND_ASYNCHRONOUS. This function module is used for SAP release 4.0 and later.

This function module starts inbound processing in the case of port type “tRFC”. The function module is a successor to INBOUND_IDOC_PROCESS, which processes IDocs in the Release 4.0 record types. If you are processing IDocs in Release 3.X record types, the function module INBOUND_IDOC_PROCESS must still be called.
The function module checks the ID ‘EDI_MES’ in authorization object B_ALE_RECV against the received message type.
The IDocs are saved by the function module IDOC_INBOUND_WRITE_TO_DB (a COMMIT for all IDocs) and then transferred directly to the application by the dispatcher module IDOC_START_INBOUND.

1. Create a connection in XMII admin menu: Data Services – Connections. Create new JCO connection with any name and description, then correctly set up Server URL, Client number, System number (for default 00) and Pool size (for first time 10 will be sufficient) – refer to Your SAP basis for more details.


2. Create credentials to using connection from first step at Security Services – Credential Stores. Create new credentials with Name and Password from target system (SAP MDG) to call this RFC function – refer to Your SAP basis for more details.


3. Now You can switch to SAP MII Worbench and create new transaction. Main blocks of this transaction will be SAP JCo operations.


Create some blocks in transaction in the following sequence: SAP JCo Start Session, SAP JCo Function, SAP JCo Commit, SAP JCo End Session.


SAP JCo Start Session operation opens connection to RFC at SAP MDG with created JCo-connection and Credentials. Simple choose connection from Connection Alias dropdown and credentials from Credential Alias dropdown.


SAP JCo Function operation directly call RFC at SAP MDG. In SAP JCo Session Action choose created connection from previous block and set at RFC Name name of RFC function (in our case IDOC_INBOUND_ASYNCHRONOUS, but You can search needed one from all available from Search Pattern).


To getting RFC fields make Generate Sample of SAP JCo Function block operation.


In Links Editor window of SAP JCo Function map RFC fields with data from Your input source.


SAP JCo Commit operation is commiting send operation from SAP JCo Function – simple choose connection from previous steps.


SAP JCo End Session is closing created connection with RFC function.


This is the necessary minimum. Now You can test created transaction.

I hope my guide will be useful.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo christian libich
      christian libich


      I think it would be really helpful to readers if you could go into more technical detail about how the required idoc fields/segments are determined and how they are mapped into the bapi.


      Author's profile photo Kirill Levitskiy
      Kirill Levitskiy
      Blog Post Author


      Thank you for reply. OK, I'll write next guide about mapping idoc fields. There are some interesting details when you try to grab fields into segment.



      Author's profile photo Anshul Arora
      Anshul Arora

      Hi All,


      Can you help in understanding if we can use Jco RollBack Action block under Session for Bapi IDOC_INBOUND_ASYNCHRONOUS.

      I have to send multiple IDOCs to SAP under same session but want to either send all or nothing to SAP.

      Is it possible ? Because when i am trying on rollback still i see the idoc in SAP.


      Best Regards,

      Anshul Arora