B2B Integration Scenario (EDI to iDoc) Using B2B Cockpit of SAP PI/PO

In the article, I will show you how to develop, configure and test a plain EDI to iDoc integration scenario step by step using B2B Integration Cockpit (Add-on). Not only will we configure an example EDI file to iDoc interface, but also look at the advantages of using B2B Integration Cockpit; prerequisites for B2B integration; ways of monitoring/testing B2B Integration scenario; and the use of other EDI message formats.

The topics covered under this article are as follows,

  • Advantages of using B2B add-on for plain EDI Scenarios
  • Prerequisites for implementing EDI integrations using B2B Cockpit
  • Example B2B integration scenario overview
  • Step-by-step plain EDI to iDoc interface development guide
  • Testing and monitoring a plain EDI to iDoc integration Scenario
  • Other EDI Message Formats and B2B Integration Cockpit

Advantages of Using B2B Integration Cockpit (Add-on) for Plain EDI Integration Scenarios

There are multiple advantages of using B2B Integration Cockpit for EDI integration instead of traditional integration methods.

A few of the main advantages of B2B Add-on are,

  • Reusability of standard EDI message types
  • Central repository for all custom content conversions
  • Functionality provided by EDI separator
  • Trading Partner and Number Range Objects (NRO) management

Reusability of Standard EDI Message Types

With the installation of B2B Integration Cockpit (Add-on), SAP provides a collection of standard EDI formats that can be reused in integration scenarios. Using EDI content manager you can access these standard EDI messages in formats Edifact, EANCOM, Ansi X. 12, Odette, Tradacoms, and VDA.

Go to the message editor in the EDI content manager to view EDI message types and versions provided under each EDI format.

Central Repository for All Custom Content Conversions

EDI content manager of the B2B Add-on allows us to manage all content conversions from one central location. Whether we are talking about delimited files, fixed-length files or other EDI formats, content conversion modules to transform these file formats into XMLs can be built and managed under one central location. This method is a much more organized way of keeping different file formats integrated than using the adapter module content conversion method.

Functionality Provided by EDI Separator

EDI separator (a B2B Add-on’s component) provides valuable functionality such as splitting bulk EDI files and generating 997 EDI acknowledgments.

Trading Partner and Number Range Object (NRO) Management

Organizations can now manage all EDI partners integrated via the EDI Tradepartner platform of the B2B Integration Cockpit.

Most EDI integration requires sequential number ranges to represent EDI data segment values. Using B2B cockpits Number Range Object (NRO) functionality, organizations can manage these number ranges efficiently.


Prerequisites for Implementing EDI Integrations Using B2B Cockpit

Before you can configure EDI integrations via B2B Integration Cockpit make sure,

  1. B2B Add-on is installed in SAP PI/PO
  2. Business Systems are configured in SLD
  3. iDoc connectivity is set up
  4. NWDS is installed and connected (Optional)

Prerequisite 1 – B2B Integration Cockpit (Add-on) Installed

B2B Add-on is compatible with SAP PI or PO versions higher than 7.1. Ever since the inception of B2B Add-on in 2012, the tool required a separate license. The good news is since the release of SAP Process Orchestrator SP4 B2B Integration Cockpit does not require an individual license.

Although SAP included the license of B2B cockpit, before you can start developing interfaces, you still need to install the components of B2B Integration Cockpit such as B2B Toolkit, B2B Mapping Kit, and EDI runtime content. If you are yet to install the B2B cockpit in your PI/PO system, follow the B2B Integration Cockpit installation steps in my previous article.

Prerequisite 2 – SLD (System Landscape Directory) Configured

Our aim is to integrate an EDI partner with SAP back-end system. Hence, you need to register the Technical System of the SAP system in SLD. Then, configure the Business System.

Assign the SAP back-end Business System with corresponding Product and Software Component Version (SWCV).

Prerequisite 3 – iDoc Connection Established

Since we can leverage the existing ALE/iDoc functionality, this is how most EDI business processors are integrated with SAP: either as outbound iDocs from SAP or inbound iDocs to SAP. Therefore, you need to establish the iDoc connectivity between PI/PO system and back-end SAP system.

You should already have the iDoc sender and receiver Communication Channels configured. In SAP PI versions 7.31 or newer, iDoc_AEE adapter is available to configure iDoc connectivity between systems. I have given iDoc sender and receiver Communication Channel parameters in Step #6.

Prerequisite 4 – NWDS Installed (Optional)

Although installing NWDS is optional, at this point it is better to get the hang of the Eclipse tool for your interface development. Not only will NWDS make the development lifecycle more effective, but the interface development more user-friendly, too! iFlow configuration via NW BPM makes it easier to develop the Integration Directory objects. The use of NWDS for integration development is certainly the preferred method going forward.


B2B Integration Scenario Overview

In this example, we will implement an interface to integrate an EDI partner who communicates purchase orders via a plain file format with SAP. EDI partner sends plain, comma-separated CSV files from an sFTP server to PI/PO.

flow diagram of the b2b integration example. Sender system SFTP server, middle wear PI/PO with the B2B integration cockpit as a sub component. Receiver system is SAP back-end system.
B2B integration example overview

First, PI/PO B2B Integration Cockpit converts the plain CSV file to XML. In the next step of the integration pipeline, the converted source XML is being mapped to target iDoc structure. Finally, PI/PO iDoc_AEE adapter-receiver Communication Channel transfers the iDoc to SAP back-end system.

Purchase orders are posted in SAP S4 HANA back-end system using iDoc message type PORDCR and iDoc basic type PORDCR05.

EDI Partner (sFTP File Sender) > B2B Add-on (plain to XML content conversion) > SAP back-end system (iDoc receiver)

SAP PI/PO, SLD and B2B Integration Cockpit object names are as follows,

EDI Plain File Sender Detail:

Sender file formatComma-delimited CSV
Message sender protocolFile/sFTP
EDI plain file sender Business ComponentBC_FILE_SENDER
sFTP sender Communication ChannelSFTP_s_PurchaseOrder
Outbound Service InterfacePurchaseOrder_Out_Async
Namespaceurn:SAPIntegrationHub.com:PurchaseOrder
Sender XML’s External DefinitionEX_PurchaseOrder

iDoc Receiver SAP System Detail:

SAP Business SystemSADCLNT200
iDoc Receiver Communication ChanneliDoc_r
Inbound iDoc Service InterfacePORDCR.PORDCR05

B2B Add-on Objects:

EDI content-typePlain
Control keyCSV_to_XML
Message TypePurchaseOrder

Cross Component ESR Objects:

Message Mapping namePurchaseOrder_to_PORDCR_PORDCR05
Operation Mapping namePurchaseOrder_to_PORDCR_PORDCR05

B2B Interface Development Steps in Detail

Let’s look at how to build a plain CSV to iDoc B2B integration scenario using the B2B Integration Cockpit in detail.

  1. Configure B2B plain to XML Content Conversion
  2. Import XSD to ESR
  3. Create File Sender Outbound Service Interface
  4. Import iDoc Metadata to Sender SWCV
  5. Define Message Mapping between B2B Converted XML to iDoc
  6. Configure Sender and Receiver Communication Channels
  7. Build the Integration Scenario using iFlow

Step 1: Configure B2B Plain to XML Content Conversion

The very first step of the integration development is to build an EDI content conversion module in B2B Integration Cockpit. In this example, we need to create a custom plain to XML converter module.

Steps to create a custom plain to XML content conversion in B2B Add-on are as follows,

  1. Create a Control Key Association
  2. Define Message Type (PurchaseOrder)
  3. Generate a Set (Row Types) of the Message
  4. Add Fields to Sets

I have illustrated the content conversion steps in detail in my previous article.

Using this plain converter module in B2B we can transform the custom EDI CSV file format to XML. We will be mapping the converted XML format to iDoc in the Message Mapping program.

Step 2: Import XSD to ESR

Now that we have generated the converter module, we need to obtain the XSD schema of the XML generated after the B2B conversion. This XSD will represent the sender Message Type (External Definition) in the file sender Outbound Service Interface.

Generate the XSD via EDI Content Manger

To generate the XSD, first, go to EDI Content Manager in B2B Integration Cockpit and select the Control Key ‘CSV_to_XML’ of the content conversion module with the Message Type ‘PurchseOrder’. Then, choose option plain>XSD-Generator from the main menu.

XSD generator of B2B Integration Cockpit. To generate the XSD, go to Plian->XSD Generator.
XSD generator of B2B Integration Cockpit

In the next screen, select the Control Key name and plain Message Type of the content conversion module we configured in Step 1. In the same screen assign the Namespace and the XSD root element name.

I will assign the Outbound Service Interface Namespace ‘urn:SAPIntegrationHub.com:PurchaseOrder’ as the Namespace and XSD root element can be PurchaseOrder.

In B2B add-on EDI content manger, select Control key name and plain Message Type in XSD Generator to create the XSD
Select Control key name and plain Message Type in XSD Generator

Now hit the ‘Generate XSD’ button, and the system will display multiple options for you to either download or display the generated XSD. Download the XSD schema file to your local PC.

Tip and Trick: XSD generated from the EDI Content Manager will contain ‘Plain’ as the type of the root element of the XSD.

Adjust the XSD created by EDI Content Manger

You cannot create an External Definition directly from the XSD generated by the B2B Add-on. Before you can upload the XSD to ESR, you must change the type of the XSD element to ‘PurchaseOrder’ and remove the text ‘Plain’.

External definition created in ESR from the XSD generated by B2B cockpit had to be adjusted.
Adjusted XSD created by B2B Add-on uploaded to ESR

Create External Definition Using the Generated XSD

Import the generated XSD (after adjusting the type) as an External Definition in ESR.

External definition created in ESR from the EDI XSD
External definition created in ESR from the EDI XSD

Step 3: Create File Sender Outbound Service Interface

Build the Outbound Service Interface for the Purchase Order EDI file sender. The request message type of the Outbound Service interface should be the External Definition we created in the previous step.

EDI file sender outbound service interface PurchaseOrder_Out_Async
Asynchronous Outbound Service Interface created in ESR

Step 4: Import iDoc Metadata to Sender SWCV

Right-click on the target SWCV ‘Imported Objects’ navigation menu to import the iDoc metadata to ESR.

Righ-click to import iDoc metadata to ESR

In this example, we will use the iDoc Message Type PORDCR and iDoc Basic Type PORDCR05.

iDoc metadata of idoc PORDCR.PORDCR05 imported to ESR
iDoc metadata imported to ESR

iDoc PORDCR.PORDCR05 will be the Inbound Service interface.

Step 5: Define Message Mapping
Between B2B Converted XML to iDoc

Using the sender message type which is the EDI External Definition EX_PurchaseOrder and receiver iDoc type PORDCR.PORDCR05, build the Message Mapping program between plain file format and iDoc.

message mapping and operation mapping objects used in the B2B integration scenario. Purchase order to Idocs.
Message and Operation Mapping Objects

Map the iDoc segments and fields as per your integration needs. If you need more information on how to define the iDoc Control Record from PI/PO Mapping program, read my previous tutorial.

Message mapping between EDI XSD (XML format) and PORDCR.PORDCR05 idoc structure in ESR
Message Mapping between EDI XML format and iDoc structure
Operation mapping of PurchaseOrder_Out_Async to iDoc created in ESR
Operation mapping between EDI Outbound Service Interface and iDoc Inbound Interface

Step 6: Configure Sender and Receiver Communication Channels

Let’s configure the Sender sFTP adapter and iDoc_AEE receiver to define the Communication Channels.

Sender sFTP Communication Channel Configuration

We will use Adapter Module ‘localejbs/PlainConverterModule’ to convert the plain file format to XML at the sender adapter.

PlainConverterModule configuration in sender sFTP Communication Channel. Parameter appendSeqNumToDupSet is set to false.
PlainConverterModule configuration in sender sFTP Communication Channel

Configure the other parameters of the sFTP Communication Channel such as host, port, etc. based on your needs.

Tip and Trick: PlainConverterModule’s parameter ‘appendSeqNumToDupSet’ suppresses the B2B converter from appending a sequence number to the XML segment names of repeating rows.

When you test the EDI to XML content conversion using the EDI Content Manager, you can notice a sequence number added to repeating segments of the output XML.

Convert plain to xml module in EDI content manger adds a sequence number to the repeating elements of the xml. xml segments article_1 and article_2, etc
Sequence number assigned to the XML converted via B2B Content Conversion

Parameter ‘appendSeqNumToDupSet’ of adapter module ‘PlainConverterModule’ suppresses the sequence number from being generated from the B2B Converter Module.

Receiver iDoc Communication Channel

Assign the HTTP destination of SAP back-end system configured in Netweaver Development Admin (NWA) to the iDoc Communication Channel.

iDoc receiver adapter configured in ID. RFC client parameter destination assigned as xi_idoc_default_destination_sad
iDoc Receiver Communication Channel

Step 7: Build the Integration Scenario Using iFlow

Finally, we can build end-to-end integration scenario between the plain EDI file sender system and SAP HANA back-end system. Here is how the complete iFlow created in Eclipse NWDS looks like.

B2B integration iflow generated in eclipse NWDS. EDI XML to SAP iDoc. Sender is a business component and reciever SAP backend
B2B EDI to iDoc iFlow in Eclipse NWDS
Sender Business Component, EDI Outbound Service Interface and Sender sFTP Communication Channel of the flow shown in Eclipse NWDS tool.
Sender Business Component, EDI Outbound Service Interface and Sender sFTP Communication Channel
iDoc receiver SAP back-end system, Inbound iDoc Interface and iDoc receiver Communication Channel of the iFlow shown in the Eclipse NWDS.
iDoc receiver SAP back-end system, Inbound iDoc Interface and iDoc receiver Communication Channel

How to Test and Monitor the Plain EDI to iDoc Integration Scenario

You can test the EDI interface by completing two steps. First, we can test the EDI plain to XML convertor module using the EDI Content Manager of the B2B Integration Cockpit. Then, you can test the complete end-to-end integration by uploading CSV files to the sender sFTP server.

  1. Test the Plain to XML Content Conversion via EDI Content Manger
  2. Trigger the end-to-end integration from sender sFTP adapter

Issues Faced While Developing the B2B EDI Interface and How to Troubleshoot

While developing the integration scenario I came across several errors. Some of them are generic, but I thought it will be useful to list them down in case you come across similar issues.

Technical issues faced and how to troubleshoot them,

  1. iDoc: Preparing iDoc number list for the sender failed due to Sender Partner Number not being available.
  2. Adding control record to payload failed due to iDoc structure of the incoming message not being correct – element IDOC has no non-white space child elements.
  3. Error before sending due to iDoc parser error.
  4. Trouble finding a matching set-pattern.

iDoc: Preparing iDoc number list for the sender failed due to Sender partner Number not being available.

The issue was that Sender Partner was not allocated to iDoc control record field /IDOC/EDI_DC40/SNDPRN from the Sender Business Component BC_FILE_SENDER. I used the iDoc control record mapping technique dynamically setting the control record information at message processing runtime by disabling the control record fields in the Message Mapping. But Adapter Specific Identifiers were not defined correctly in the sender Business Component. Specifically, the iDoc Adapter Logical System in the Business Component was missing.

To resolve this issue, assign the Adapter Specific Identifiers to the sender Business Component or Business System.

iDoc structure of the incoming message is not correct – element IDOC has no non-white space child elements.

This issue occurs when no data segments are mapped in the target iDoc structure, i.e. the iDoc data segments were null. The same error can also occur if data segments are not correctly assigned from the mapping program. Double-check if the target iDoc data segments are mapped correctly.

Error before sending due to iDoc parser error.

If the receiver iDoc Control Record is not correctly mapped, this issue will occur.

Trouble finding a matching set-pattern.

I came across this error while testing the end-to-end EDI integration from the sender adapter by uploading a plain CSV file to the sFTP server.

When creating the plain to XML content conversion in EDI Content Manager, we configured the Message Type parameter ‘New Line’ as ‘Line Feed (Unix)’.

The conversion worked perfectly in the plain to XML convertor test tool in B2B Integration Cockpit.

Testing the content conversion via EDI content manger's Convert plain to xml tool of B2B Add-on SAP PI/PO

However, when it comes to end-to-end testing, the error occurred. To avoid it, the line feed should be changed to ‘Line Feed (Windows)’.


Other EDI Message Formats and B2B Integration Cockpit

Standard EDI Messages

In this example, we integrated a comma-separated plain CSV file using B2B Integration Cockpit. Since the plain file format is custom, we had to define a custom content conversion module to convert the plain file to XML. But, for global standard EDI message formats SAP has already provided standard content conversions and EDI message formats which can be reused in your integration scenarios.

EDI Message Formats in B2B Add-on

Using B2B Add-on, you can build EDI interfaces with EDIFACT, EANCOM, Ansi X. 12, Odette, Tradacoms, VDA, and plain EDI message formats. Go to EDI Content Manager and select the option ‘Message Editor’ under ‘Editor’ of each EDI message format to view the standard EDI formats provided by SAP. You can reuse these Control-Key associations and EDI Message Types in B2B interfaces.

EDI Separator

If you have a scenario where integration involves bulk EDI messages, you can use EDI_Seperator to split the bulk EDI messages to individual EDI messages.

You can also use EDI separator to generate 977 EDI acknowledgments from SAP PI/PO.


If you have any questions on B2B Content Conversion, EDI Integration or B2B Integration Cockpit in general, please leave a comment below!

22 thoughts on “B2B Integration Scenario (EDI to iDoc) Using B2B Cockpit of SAP PI/PO

  1. Sandeep says:

    Again a great blog with so much informative content in respect to SAP PI/PO B2B Add on.
    Please post some blog on below topics if possible.:
    AS2 and Rest Adapter configuration
    Certificate based authentication with encryption decryption.

  2. Imran says:

    Marvelous and hats off to your patience and dedication level of work
    Really amazing, i am a beginner to learn EDI it helps me a lot
    keep posting more content based on EDI
    Thanks a lot

  3. Ryan Zhang says:

    Hi Isuru
    This is a great blog and very helpful, I have a question, I use AS2 Adapter to convert CSV file on FTP to XML file and pass it to SAP system, I want to get the CSV file name in the proxy class, The value of “AS2Filename” in PI is what I want, I have tried many times without success.
    Could you please tell me how Should I do?
    Thank you.

  4. Gagan says:

    Hi Isuru,

    Really nice and helpful blog. Need some input on How do we define the Occurrence of segments. like in your example : “Carton segment having 1 to Unbounded occurrence”. How did you created the Occurrence. I’m getting the Occurrence as 1 to 1.

    Regards,
    Gagan

  5. Max says:

    Hi Isuru,

    when I remove “Plain” in the EDI Content Manager generated XSD -File I got the message:
    “Unable to convert imported document to WSDL
    Reason: Unable to recognize document as valid XSDCheck selected category”

    So could you upload your xsd-File, so that people can compare their xsd (generated by EDI Content Manager) to yours ?

  6. sap in hyderabad says:

    This post is extremely radiant. I extremely like this post. It is outstanding amongst other posts that I’ve read in quite a while. Much obliged for this better than average post. I truly value it!

Leave a Reply

Your email address will not be published. Required fields are marked *