on 02-11-2011 4:58 AM
Hi Experts,
How to increment the counter value by 5 every time, I tried using counter arithmetic function it is now working for my requirement.
My Source structure
<Elemica_Order>
<HItem>1..to unbouded
<LItem>
<Item>1..to unbounded
Target
<Order>1..to unbounded
<OItem>1 to unbouded
<id>
Order mapped with HItem and OItem mapped with lItem.suppose my source having 2 hitem records then target side I will have 2 orders.
my Hitem record having 3 LItems then my first order will have 3 order Items , in this case my I want to increment the ID value by each time by20, initial value is going to be 10.
Second Hitem having only one Litem then I want to increment value by 20.
I tried using counter arithmentic function, it is working for only one Hitem, second Hitem it is not reseting value to 20.
I think UDF required for this, help me
Regards,
Jam
Hi Jam,
If you looking to get the target like this:
<Order>
<OItem>
<id>10</id>
<OItem>
<id>30</id>
<OItem>
<id>50</id>
</Order>
<OItem>
<id>10</id>
</Order>
You can achieve this by using the "index" function from Static Functions list.
LItem -> index -> formatByExample (first input)
formatByExample(out put) -> id
Item -> formatByExample (Second input)
for the index function parameters set Initial Value = 10; Increment = 20;
Tick the option of "Reset Index to Initial Value with each new context".
Regards,
Aravind
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
You can try the below code, if I got your requirement correctly.
int i,j,Hcount = 10, Lcount = 10;
for(i=0;i<Hitem.length;i++)
{
for(j=0;j<Litem.length;i++)
{
// Litem value as output as 10, 30, 50 for each Hitem
result.addValue(""+Lcount);
Lcount = Lcount + 20;
}
Hcount = Hcount + 10;
//if you want HItem value in output as 10, 20, 30
//Uncomment the below code if you want to get HItem count.
// result.addValue(""+Hcount);
//Resetting Litem counter to 10
Lcount = 10;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.