Technology Blog Posts by Members
cancel
Showing results for 
Search instead for 
Did you mean: 

Scenario:

Here, I was working on an integration where Business Partner data had to be transformed using Message Mapping. The target structure was designed to send the data through an OData batch request. The target payload contained multiple batchChangeSet nodes(duplicate subtrees), where each batchChangeSet represented a different business condition.

 

Here, depending on the values available in the incoming Business Partner payload, a particular batchChangeSet had to be generated. Therefore, the mapping contained multiple conditional mappings to determine which batchChangeSet should be populated.

 

A sample source payload:

<BusinessPartner xmlns="http://abc.com/BusinessPartner/v1" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
	<CounterParty>
		<Organisation_Person>1</Organisation_Person>
		<BP_Role_Customer>ABCD00</BP_Role_Customer>
		<BP_Role_Vendor>EFGH00</BP_Role_Vendor>
		<Is_All_Customer_Postings_Block>false</Is_All_Customer_Postings_Block>
		<Is_All_Vendor_Postings_Block>false</Is_All_Vendor_Postings_Block>
		<Account_Group>ABCD</Account_Group>
		<Name>TEST FOR RUNTIME</Name>
		<Search_Term>RUNTIME</Search_Term>
		<City>ABC</City>
		<Region>AB</Region>
		<Country>ABC</Country>
		<Street>ABCD</Street>
		<Postal_Code>00000</Postal_Code>
		<Language>EN</Language>
		<Tax>
			<Tax_Category>ABC</Tax_Category>
			<Tax_Number>00-000000000</Tax_Number>
		</Tax>
	</CounterParty>
</BusinessPartner>

While testing the mapping, I provided an input payload that was expected to satisfy the condition for one of the batchChangeSet nodes. However, instead of generating the expected target structure, the Message Mapping execution failed with the following runtime error.

 

solasu_swarnalipi_0-1787731846553.png

The Root Cause:  The input payload was designed to satisfy the condition for a specific batchChangeSet, so the expectation was that only that batchChangeSet would be processed.

 

However, the error message pointed to: /batchParts/batchChangeSet[3]/batchChangeSetPart

 

The important observation here was that batchChangeSet[3] was a disabled node in the mapping and was not the batchChangeSet that should have been triggered by the input payload.

 

During further analysis, I found that the formatByExample() function was actually being used in mappings associated with other batchChangeSet nodes, such as batchChangeSet[4] and batchChangeSet[5].

 

This led to an important behavior to consider in Message Mapping: The runtime can evaluate mapping functions such as formatByExample() while processing the mapping queues, even if the condition associated with the corresponding batchChangeSet is ultimately not satisfied.

 

In my case, the condition for batchChangeSet[5] was not satisfied by the input payload. Therefore, logically, I expected the mapping inside this batchChangeSet not to be executed.

 

However, formatByExample() was still evaluated during the runtime processing of the mapping queues. Since the queues supplied to formatByExample() did not have an equal number of values, the function generated the exception:

 

Function formatByExample: Queues have not equal number of values.

 

The confusing part was that the runtime error was reported against: /batchParts/batchChangeSet[3]/batchChangeSetPart

Even though batchChangeSet[3] was disabled. The input payload was intended to trigger a different batchChangeSet. The condition for batchChangeSet[5] was not satisfied.

formatByExample() was present in mappings associated with other batchChangeSet nodes.

 

Therefore, the target path shown in the exception should not automatically be interpreted as the batchChangeSet whose business condition was triggered.

 

Key Finding :

 

solasu_swarnalipi_1-1787731890143.png

The issue was difficult to identify because the error pointed to batchChangeSet[3], even though this node was disabled. Additionally, multiple conditional batchChangeSet nodes contained formatByExample(), making it difficult to determine which mapping was causing the runtime exception.

 

The important troubleshooting approach was therefore to:

  • Check which batchChangeSet should actually be triggered by the input payload.
  • Check whether the batchChangeSet mentioned in the error was enabled or disabled.

  • Search all conditional mappings for the formatByExample() function.

  • Check whether formatByExample() could be evaluated even when its surrounding business condition was false.

  • Analyze the queues and contexts being passed to formatByExample(.

  • Correct the queue/context handling by using removeContexts() before formatByExample().

 

Solution:

After identifying that the issue was related to queue processing and runtime evaluation of formatByExample(), I reviewed the mapping expression used for the affected batchChangeSet.

solasu_swarnalipi_2-1787731911953.png

After identifying the root cause, I modified the mapping logic by adding an if() condition around the formatByExample() function.

solasu_swarnalipi_3-1787731924387.png

The main objective was to ensure that the formatByExample() logic was evaluated only when the required business condition was satisfied.

 

Previously, the mapping directly started with formatByExample(). Because multiple batchChangeSet nodes were present in the target structure, the runtime could evaluate the formatByExample() function during queue processing even when the corresponding batchChangeSet condition was not satisfied.

 

Result : After making this change, I tested the same input payload again.

The result was:

  • The expected batchChangeSet was generated.

  • The conditions that were not satisfied did not generate their corresponding data.

  • The formatByExample() queue mismatch error was no longer raised.

  • The Message Mapping executed successfully.

Key Takeaway: When using formatByExample() in a complex SAP CPI Message Mapping with multiple conditional batchChangeSet nodes, it is important to control when the mapping logic should be evaluated.

 

In my case, adding an explicit if() condition around the formatByExample() logic resolved the runtime error: Queues have not equal number of values.

 

The key lesson was that the batchChangeSet mentioned in the runtime error does not necessarily represent the business condition that was triggered by the input payload. In complex mappings, the runtime may process mapping queues across different target contexts. Adding the if() condition provided the required control over the mapping logic and resolved the issue.

Labels in this area