Skip to main content

As you can see in the picture we have a SAP PO – Generic IDoc Outbound Interface with multiple IDoc Operation in our iFlow.

Introduction

Often you have the requirement to create a set of IDoc interfaces as a kind of template implementation, especially for EDI communication scenarios.

Regarding the EDI use case, you might have created a single iFlow receiving the partner’s data and separate the incoming messages over operations.

For the other direction you realize the IDoc sender adapter requires a dedicated IDoc outbound interface with only one operation. So we cannot provide a single template interface with multiple operations for sending data to the partner, which is resolved here SAP PI B2B Add-on 3.0 – Outbound by using EDI separator. I want to engage the sending system in order to build the SAP PO – Generic IDoc Outbound Interface…

My workaround is inspired by the blog post „Michal’s PO tips: How to send messages directly to AEX (ICO) – adapter independent – SOAPUI version“ to implement the BAdI IDOC_XML_ENVELOPE_OU in order to wrap the XML IDoc into the SOAP envelope and adding the XI headers.

If you are also searching for a solution to either…

  1. provide generic IDoc outbound interfaces
  2. create acknowledgements per partner profile and not per IDoc sender channel (additional adapter module required for ALEAUDs)
  3. setup a simple solution to create the serialization context for IDocs (based on Xpath)
    -> Configuration instead of function module development
  4. have a generic and single HTTP endpoint for XML-HTTP IDoc ports instead of creating multiples (one endpoint for each SAP PO outbound interface)
  5. avoid header mappings for outbound interfaces in order to set the XI Party (KB: 1941832 – Resolve logical receiver party) or replace the virtual receiver Logical System (KB: 2728276 – Resolve logical receiver service for LS receiver)
  6. send the IDoc to a dedicated iFlow having a virtual receiver, which could e.g. represent a dedicated SAP process. This helps to separate IDoc iFlows into business responsibilities and you could create IDoc iFlows without any dependency to any other IDoc interface.
    (I know, it increases the amount of point2point interfaces, but if you ask business, I’m not sure they are interested in using as many integration patterns as possible 🙂
    -> Less discussion about impact and regression testing after changing existing interfaces
  7. use HTTP based communication instead of TRFC / ressource adapter configuration for sending IDocs, but still want the full/better SAP PO functionality (see restrictions) compared to the restricted default XML-HTTP port behavior
    or
  8. overcome the 16 character serialization context length

…this BAdI implementation and some little customizing might help you to achieve it with only a single iFlow.

BTW: No metadata is required anymore if you send it over HTTP-XML…

Please bear with me in case you find issues regarding the ABAP part,I’m still on beginner level.
I’m happy receive your ideas/use cases and feel free to provide any optimization proposals.

Warning: This BAdI is not yet used in production. So adjust it to your needs and test it carefully before using it in productive environments – No warranty for correctness, performance and no support can be provided! This is no SAP code. So it is 100% in your responsibility to troubleshoot and correct it in case of any issue.

Restrictions

  • You will not successfully receive back ALEAUDs without an additional adapter module.
    ALEAUDs will stuck in SAP PO, not finding the corresponding inbound IDoc.
    I’m checking if I can publish the module.
  • Your WE21 port name must match *PO[X]_* regex: ^.*PO.{0,1}_.*$ according to the code below.

Steps to implement the BAdI

Before building the  SAP PO – Generic IDoc Outbound Interface, please check the perquisites.

Prerequisites

You should have at least basic ABAP development knowledge and create a package or know which development package needs to be selected before you continue with the next steps.

You must have at least 7.40 SAP Basis release to use the BAdI code below.

1. SAP PO SOAP sender channel (in SAP PO)

Make sure there is an active SOAP sender channel created for the Business System in where you implement the BAdI and this channel is used in ANY deployed iFlow/ICO, like shown in the referenced blog entry from above.

2. Create RFC Destination (SM59)

Type: G
Host: your SAP PO system (without protocol, like http[s]://)
Service Your SAP PO Http Port
Path Prefix: /XISOAPAdapter/MessageServlet?channel=:<SenderComponentName>:<ChannelName>
Setup Authentication

e.g. /XISOAPAdapter/MessageServlet?channel=:ER6_800:CC_SND_SOAP

Please note the colons which separate Party (empty in our case) from the sender system (business system)

Exmaple RFC destination

3. Create HTTP Idoc Port (WE21)

Name: SAP_PO_XI and assign it in the partner profile (copy/write the value manually if you do not find it with F4 help)

picture to compare the idoc port settings, which are basically default

4. Create domains (SE11)

(Select domain, enter name and click create button for all 2)

Name: ZSSTRING
Description: <something you like>

Data Type: SSTRING
No. Characters: 1133
Lower Case: X

picture to compare settings of domain zsstring

 

Name: ZRCVPRN
Description: <something you like>

Data Type: CHAR
No. Characters: 60
Lower Case: X

picture to compare settings of domain ZRCVPRN

 

-> Save and activate both new domains

 

5. Create data elements (SE11)

(Select datatype, enter name and click create button, choose data element for all 2)

Name: ZXPATH
Description: <something you like>

Domain: ZSSTRING

Field Label Tab
Short: 10 <something you like>

picture to compare settings of data type ZXPATH

Name: ZRCVPRN
Description: <something you like>

Domain: ZRCVPRN

Field Label Tab
Short: 10 <something you like>

 

picture to compare settings of data type ZRCVPRN

-> Save and activate all 2 new data types

 

6. Create tables (SE11)

(Select database table, enter name and click create button for all 2)

Name: ZIDOCENVELOPEOUT

Delivery and Maintenance Tab

Delivery Class: C
Data Browser/Table Maintenance: Display Maintenance Allowed

Fields Tab

FieldData ElementKey
.INCLUDEEDK13X
IDOCTPEDIPIDOCTP
CIMTYPEDIPCIMTYP
QIDXPATHZXPATH
CUSTSENDIFPRX_INTFID
CUSTSENDNSPRX_NSPCE
ERRORACKSAP_BOOL
SYSTEMACKSAP_BOOL

picture to compare field settings of table ZIDOCENVELOPEOUT

-> Technical settings

Data Class: APPL0
Size Category: 0

Regarding Buffering I am not sure, I’ve chosen “Not Allowed”

Log data changes X (Check with Basis for profile parameter rec/client <client> to make use of it)+

-> Extras -> Enhancement category -> can be enhanced

 

Name: ZIDOCENVELOUTNRO

Delivery and Maintenance Tab

Delivery Class: A
Data Browser/Table Maintenance: Display Maintenance Allowed with Restrictions

Fields Tab

FieldData ElementKey
.INCLUDEEDK13X
IDOCTPEDIPDOCTYPX
CIMTYPEDIPCIMTYPX
QUEUEIDCHAR16X
ZRCVPRNZRCVPRNX
CHANGEDATEAS4DATE
CHANGETIMEAS4TIME
XPATHRESULTZXPATH
QIDXPATH_VZXPATH

picture to compare field settings of table ZIDOCENVELOUTNRO

-> Technical settings

Data Class: APPL1
Size Category: 2

Regarding Buffering I am not sure, I’ve chosen “Not Allowed”

Log data changes [ ] No maintenance required -> no logging.

-> Extras -> Enhancement category -> can be enhanced

 

-> Save and activate both new database tables | ignore warnings about key length

 

7. Create number range object (SNRO)

(Select datatype, enter name and click create button, choose data element)

Name: ZQUEUEID

ShortTxt: <something you like>

Number length domain: char16
Buffering: No (if you don’t like gaps)

Interval name: Z1
From: 0000000000000001
To:     9999999999999999

8. Create the BAdI class (SE18)

(Select BAdI Name, enter IDOC_XML_ENVELOPE_OU and click display button)

Transaction-Code:  SE18
BAdI Name: IDOC_XML_ENVELOPE_OU

settings of numberrange object ZQUEUEID_SNRO

-> Implementation -> Create

navigate from BAdI UI to Overview and Implementation

Name: ZIDOC_XML_ENVELOPE_O

(enter name and click OK (green arrow) button)

Tab Interface

Double-click on PROCESS

navigate from the interface to the custom BAdI ZIDOC_XML_ENVELOPE_O

(Click on Source code Based)

navigate from the interface to the custom BAdI ZIDOC_XML_ENVELOPE_O

Copy and insert the code.
Save and activate it.

 

Customizing

Use SQL for the first insert into ZIDOCENVELOPEOUT, e.g.

Mandatory, if you want to apply a rule, otherwise it should also work without any transformation:From now on, you can edit the table in SE16, if the client settings allow it.
Consult your Basis if you face some issues.

Please maintain IDocTp and CimTp like you have maintained it in WE20 partner profile to match outgoing IDocs.

Optional:
You can enter your Custom / Generic IDoc Interface name in column „CustSendIf“.
You can enter namespace of Custom / Generic IDoc Interface name in column „CustSendNs“.
You can enter your virtual receiver in column „zRcvPrn“:
–> in case of LI/KU/GP… the value will appear in party field, in case of LS it will appear in the service field.
You can enter your Xpath-Expression for creating the serialization context in column „qIdXpath“:
-> In case you fill it, the QoS will be EOIO automatically – make sure to enter an Xpath which returns a result.
-> In case you leave it empty the QoS will be EO.

data in table ZIDOCENVELOPEOUT

Monitoring

You can monitor the assignment of queueids (from number range object), when they are created the first time in table ZIDOCENVELOUTNRO.
If you want, you can create a view joining ZIDOCENVELOPEOUT and ZIDOCENVELOUTNRO in order to suppress historic values (not part of this blog entry).

monitoring data in table ZIDOCENVELOUTNRO

Outlook

Full function with an additional SAP PO Adapter Module in case persistence is switched on:

  1. See incoming IDocs over SAP PO – Generic IDoc Outbound Interface in IDoc monitor (KB 2345912 – IDoc Message Monitor)
  2. Be able to return Acknowledgements and monitor them using standard SAP PO IDoc Monitor (KB: 2992965 – IDoc ALEAUD)

SAP PO IDOC MONITOR

Download Transportfile

Cofile: K900059.SLM
Datafile: R900059.SLM

Please consult your Basis team if you do not know how to use these files.

Feedback

Please 📧 contact us if you find any issue or have questions about it.


This post was first published on https://blogs.sap.com/