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,
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 (https://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.
Map Constant (SRM Business System)–> Service
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("https://sap.com/xi/XI/System/HTTP","URLParamOne"); DynamicConfigurationKey urlParam2 = DynamicConfigurationKey.create("https://sap.com/xi/XI/System/HTTP","URLParamTwo"); DynamicConfigurationKey urlParam3 = DynamicConfigurationKey.create("https://sap.com/xi/XI/System/HTTP","URLParamThree"); DynamicConfigurationKey urlParam4 = DynamicConfigurationKey.create("https://sap.com/xi/XI/System/HTTP","URLParamFour"); DynamicConfigurationKey urlParam5 = DynamicConfigurationKey.create("https://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.
Define interface determination as below.
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.
1 1a 1b 1c 1d 1e 2 2a 2b 2c 2d 2e
Lets check SXMB_MONI for the messages.
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
New NetWeaver Information at SAP.com
Very Helpfull