cancel
Showing results for 
Search instead for 
Did you mean: 

Counter Restart

Former Member
0 Kudos

Hi,

I have a mapping problem: i have a source structure that contains many orders containing many LineItem. I have to count each LineItem of an order and to restart my counter for each order. Example:

<Orders>

<Order>

<Item> I1 </Item> 1

<Item> I2 </Item> 2

<Item> I3 </Item> 3

</Orders>

<Order>

<Item> I1 </Item> 1

<Item> I2 </Item> 2

<Item> I3 </Item> 3

</Orders>

</Orders>

How can I reset my counter for every Order change? I need of a detailed solution description.

Thanks to all!

Accepted Solutions (1)

Accepted Solutions (1)

MichalKrawczyk
Active Contributor
0 Kudos

Hi Gabriele,

use UDF type Context

http://help.sap.com/saphelp_nw04/helpdata/en/f8/2857cbc374da48993c8eb7d3c8c87a/content.htm

and it will reset your counter per one order

so in your case:

<Orders>

<Order>

<Item> I1 </Item> 1

<Item> I2 </Item> 2

<Item> I3 </Item> 3

</Orders>

<Order>

<Item> I1 </Item> 1

<Item> I2 </Item> 2

<Item> I3 </Item> 3

</Orders>

</Orders>

your userr defined function (UDF) will be executed twice

once per each context and this will be what you need

Regards,

michal

-


<a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

Former Member
0 Kudos

Hi Michal,

I think that this is the right solution, but I need to have more details to implement that. Can you give me some java code examples on thi argument?

Thanks!

Former Member
0 Kudos

Hi;

Just forgot to add in that if you want to split out the values to multiple fields then used split by value after UDF .

Mudit

Award points if it helps

Former Member
0 Kudos

Hi, can you explain more in detail your solution? It's very interresting!

Thanks!

Former Member
0 Kudos

Hi;

As per the solution if you have 3 items in first order 2 in second and 4 in third than the code input to the UDF will look like

3

2

4

the first for will run 3 times as there are 3 elements(orders) in the queue.

Next for loop will add numbers to the result list based on the number of item nodes in each order.

Mudit

Award Points to motivate me further to reply

Former Member
0 Kudos

Hi ;

Is the code working??

Please update and if you have any more queries we can take forward the forum.

Mudit

Award Points if this helped

Former Member
0 Kudos

Hi Mudit,

>> Input --- Value Context level function

What do you want to say? What do you intend for "Value Context Level function"? Is it a UDF function? And...

>> Item -- Count -- RemoveContext -- UDF

What do you intend for "Count"? Is it a UDF or the Counter default XI function?

Thanks!

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi ;

Mapping

Item --- Count --- Remove Context --- UDF --- Field

UDF

Input --- Value Context level function

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

{

for(int j=0;j<Integer.parseInt(Value<i>);j++)

{

result.addValue((j1)"");

}

}