cancel
Showing results for 
Search instead for 
Did you mean: 

SplitByValue Mapping issue

Former Member
0 Kudos

Hi All,

I am trying to achieve the following using the graphical mapping tool.

Source:

Document..... 1-1

.....rows........ 0-unbounded

.........documentNumber.....1-1

Target:

Document.....1..1

..... header ....0-unbounded

..........documentNumber...1-1

......lines........0-unbounded

A sample source document is:

<Document>

...<rows>

.........<documentNumber>1</documentNumber>

...</rows>

...<rows>

.........<documentNumber>1</documentNumber>

...</rows>

...<rows>

.........<documentNumber>2</documentNumber>

...</rows>

</Document>

In the target structure, I want to create a header for each unique documentNumber. I have successfully done this using SplitByValue combined with collapse contexts, so that in the above example, I am creating two headers. However, my problem is that the documentNumber contained in those headers are both '1'.

What I need to achieve is two headers, the first one with documentNumber=1 and the second one with documentNumber=2.

Please help.

Regards,

JM

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi All,

I have managed to solve this myself with a UDF of type 'Queue' to set the context of header:

public void createDocumentHeader(String[] uniqueDocumentNumbers, String[] allLineItems, ResultList result, Container container) throws StreamTransformationException{

int counter = 0;

boolean match = false;

for (int j = 0; j < allLineItems.length; j++)

{

match = false;

for (int i = 0; i < uniqueDocumentNumbers.length; i++)

{

if (uniqueDocumentNumbers<i>.equals (allLineItems[j]) && i==counter )

{

match = true;

//result.addValue(true);

counter++;

break;

}

}

if (match)

result.addValue(true);

else

result.addValue(false);

}

Former Member
0 Kudos

Hi JM

Looks like UDF is incorrect . You are sending true/false to result.addValue();

Thanks

Gaurav

Former Member
0 Kudos

Hi Gaurav,

Yes, the UDF is piping to a 'createIf' function, hence the reason I am putting true/false in the result. The createif sets the context for the 'header' mappings.

JM