Skip to Content
Author's profile photo Former Member

XI/PI: Extended Receiver Determination with Conditional Context Object interface Determination

In one of Flex Projects, we got an enhancement requirement for an existing design and the situation is something like this.

Sender: MDM (Single File Interface, but before enhancement it is 5 different File interfaces with same structure but with different values)

Single Receiver: SRM (5 different ABAP Proxies)

So in the new requirement, the single message from MDM interface should be split according to certain value in the payload for a recurring field and then the split messages should be routed to a single SRM Business system using 5 different ABAP Proxy interfaces.

Initially I thought I can go ahead with multi mapping concept, but later I realized that it doesn’t work as receiver is XI adapter and it doesn’t support multi mapping.

Second option would be XPATH expression conditions in Interface Determination for logical routing of messages to the corresponding ABAP proxy interfaces. But since the input field reoccurs from the MDM source system it is not possible to set conditions using XPATH Expression.

Then, how to proceed………?

The tricky thing is to use the combination of extended Receiver determination, Dynamic Configuration and then condition based interface determination using context objects.

Let me explain in more detail.

Assume that we have the following structure from MDM,

MDMStructure_MT.JPG

Here the DIMENSIONTYPECODE can have values 1 to 5. And based on these values the message should be splitted and each message should go to one of the 5 proxies.

e.g., all Dimension records with DIMENSIONTYPECODE = 1 should mapped to the first ABAP Proxy message type. Similarly for DIMENSIONTYPECODE = 2, 3, 4 and 5 the corresponding Dimension records should go to the second, third, fourth and fifth ABAP Proxy message Types. So we should have 5 message mapping and 5 interface mappings.

Next we should determine receiver business system using Extended Receiver Determination interface. So, define a mapping between MDM message type and Receivers message type from SAP BASIS SWCV (http://sap.com/xi/XI/System).
Now, hardcode the business system for the SRM system in this mapping. Now we need an UDF within this mapping which can initialize certain predefined context objects based on the values of DIMENSIONTYPECODE. Later, these context objects will be useful for conditional Interface Determination in Integration Directory for the five ABAP proxy interfaces. I am using HTTP URL param context objects (URLParamOne to URLParamFive) in the UDF code. We will set values for these context objects logically based on the values of DIMENSIONTYPECODE using Dynamic Configuration code.

MM_MDM_To_Receivers.JPG

Map Constant (SRM Business System)–> Service

MM_MDM_To_Receivers_UDF.JPG

Extended UDF code

int count1 = 0;
int count2 = 0;
int count3 = 0;
int count4 = 0;
int count5 = 0;
try{
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey urlParam1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/HTTP","URLParamOne");
DynamicConfigurationKey urlParam2 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/HTTP","URLParamTwo");
DynamicConfigurationKey urlParam3 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/HTTP","URLParamThree");
DynamicConfigurationKey urlParam4 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/HTTP","URLParamFour");
DynamicConfigurationKey urlParam5 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/HTTP","URLParamFive");
for (int i = 0; i < a.length ; i++)
{
 if (a[i].equals("1") && count1 == 0)
 {
  conf.put(urlParam1, "1");
  count1 ++;
 }
 if (a[i].equals("2") && count2 == 0)
 {
  conf.put(urlParam2, "2");
  count2 ++;
 }
 if (a[i].equals("3") && count3 == 0)
 {
  conf.put(urlParam3, "3");
  count3 ++;
 }
 if (a[i].equals("4") && count4 == 0)
 {
  conf.put(urlParam4, "4");
  count4 ++;
 }
  if (a[i].equals("5") && count5 == 0)
 {
  conf.put(urlParam5, "5");
  count5 ++;
 }
}
if (count1 == 0)
 conf.put(urlParam1, "0");
if (count2 == 0)
 conf.put(urlParam2, "0");
if (count3 == 0)
 conf.put(urlParam3, "0");
if (count4 == 0)
 conf.put(urlParam4, "0");
if (count5 == 0)
 conf.put(urlParam5, "0");
result.addValue("1");
result.addContextChange();
}
catch(Exception e){}

Then define interface mapping for the above mapping, which we will use in extended receiver determination in Directory.

Activate all the objects in Repository.

Next in Integration Directory, define a sender Agreement for the MDM interface associated with Sender File channel. Then, define an extended receiver determination using above the interface mapping which logically sets conditions for the context objects (URLParamOne to URLParamFive) based on the values of DIMENSIONTYPECODE filed from MDM system.

image

Define interface determination as below.

Conditional_InterfaceDetermination.JPG

image

Define five receiver agreements for each ABAP Proxy Interface.

Activate all objects in Integration Directory. Now, lets test the scenario with the below sample payload.

<?xml version="1.0" encoding="UTF-8"?>
<ns0:Dimension xmlns:ns0="urn:Flextronics.com/Dimension">
 <Dimension>
      <DIMENSIONTYPECODE>1</DIMENSIONTYPECODE>
      <COMPANYCODE>1a</COMPANYCODE>
 <LOCALDIMENSIONCODE>1b</LOCALDIMENSIONCODE>
 <LOCALDIMENSIONNAME>1c</LOCALDIMENSIONNAME>
 <CENTRALBLOCK>1d</CENTRALBLOCK>
      <ERPDELETED>1e</ERPDELETED>
 </Dimension>
 <Dimension>
 <DIMENSIONTYPECODE>2</DIMENSIONTYPECODE>
      <COMPANYCODE>2a</COMPANYCODE>
 <LOCALDIMENSIONCODE>2b</LOCALDIMENSIONCODE>
 <LOCALDIMENSIONNAME>2c</LOCALDIMENSIONNAME>
 <CENTRALBLOCK>2d</CENTRALBLOCK>
      <ERPDELETED>2e</ERPDELETED>
 </Dimension>
</ns0:Dimension>

Lets check SXMB_MONI for the messages.

SXMB_MONI_MESSAGES.JPG

Note: The same requirement can be achieved using multimapping concept with SOAP adapter. Refer my Blog :  Calling ABAP Proxies using SOAP and HTTP Adapters in SAP XI3.0/PI7.0

Assigned Tags

      8 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member
      Hi Pawan,

      I was facing same condition when i got frustrated thinking on the possible ways of dynamic determination of the interfaces at runtime as there is very less which I could do with the conditions in Interface determination but the logic for enhanced receiver determination and setting values of context objects in UDF and using them as deciding parameters in interface determination helped me to crack it and the scenario is working fine now.

      Keep the good work going in future !!!

      Thanks again,

      Amit 🙂

      Author's profile photo Former Member
      Former Member
      Blog Post Author
      Glad to hear this helped...By the by my name is Praveen 🙂

      Thanks,
      Praveen Gujjeti

      Author's profile photo Former Member
      Former Member
      Great thought Praveen.You are great.Thank you
      Author's profile photo Former Member
      Former Member
      Hi Praveen,

      Your blog is hleping me to get similat stuff.
      I have a similar issue. Which i have written in forum, someone has given your blog for reference. But my scenario is quite different. Could you plz check this.

      Message splitting to multile files based on context
      Thanks.

      Author's profile photo Chen Lin
      Chen Lin

      Hi Praveen,

      you may also use the XPATH expression in Interface Determination like:

      /ns0:Dimension[count(Dimension[DIMENSIONTYPECODE = '1']) > 0] EX

      to resolve this problem.

      Best regards,

      Chen

      Author's profile photo Amaresh Sugoor
      Amaresh Sugoor

      Good document....

      Author's profile photo Nabendu Sen
      Nabendu Sen

      HiPraveen,

      Thanks a lot for writing this blog. You have showed how to influence "Context Objects". This has truly helped me to provide a simple solution to a critical requirement.

      Regards,

      Nabendu.

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Hi Nabendu,

      Glad to know that my content helped you. And thanks for adding value to the blog with your requirement Re: Number Limitation in XPath condition of Interface Determination

      Best Regards,

      Praveen Gujjeti