on 06-13-2013 1:25 AM
Hi Experts,
I have below source/target test XML structures, i need to add -1 counter value increment by -1 in target if Order ID value is same ,tried using counter but no luck.
<Order>
<OrderID>AZ1234</Order>
<Location>CA</Location>
<Region>NA</Region>
<Name>Mike</Name>
<Status>New</Status>
<Card>yes</Card>
</Order>
<Order>
<OrderID>AZ1234</Order>
<Location>CA</Location>
<Region>NA</Region>
<Name>Mike</Name>
<Status>Old</Status>
<Card>yes</Card>
</Order>
<Order>
<OrderID>AZ9999</Order>
<Location>CA</Location>
<Region>NA</Region>
<Name>MikeSwiney</Name>
<Status>New</Status>
<Card>yes</Card>
</Order>
Output
<FinalOrder>
<OrderID>AZ1234-1</</Order>
<Name>Mike</Name>
<FinalOrder>
<FinalOrder>
<OrderID>AZ1234-2</</Order>
<Name>Mike</Name>
<FinalOrder>
<FinalOrder>
<OrderID>AZ9999-1</Order>
<Name>MikeSwiney</Name>
<FinalOrder>
Thank you so much.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Amit,
Thanks a ton,there was some change in requirement, if there is no duplicate in file then no need counter value, if there is any duplicate then first duplicate should have -1,first duplicate should have -2 as counter like below.
<Order>
<OrderID>AZ1234</Order>
<Location>CA</Location>
<Region>NA</Region>
<Name>Mike</Name>
<Status>New</Status>
<Card>yes</Card>
</Order>
<Order>
<OrderID>AZ1234</Order>
<Location>CA</Location>
<Region>NA</Region>
<Name>Mike</Name>
<Status>Old</Status>
<Card>yes</Card>
</Order>
<Order>
<OrderID>AZ1234</Order>
<Location>CA</Location>
<Region>NA</Region>
<Name>Mike</Name>
<Status>CHANGE</Status>
<Card>yes</Card>
</Order>
<Order>
<OrderID>AZ9999</Order>
<Location>CA</Location>
<Region>NA</Region>
<Name>MikeSwiney</Name>
<Status>New</Status>
<Card>yes</Card>
</Order>
Output
<FinalOrder>
<OrderID>AZ1234</</Order>
<Name>Mike</Name>
<FinalOrder>
<FinalOrder>
<OrderID>AZ1234-1</</Order>
<Name>Mike</Name>
<FinalOrder>
<FinalOrder>
<OrderID>AZ1234-2</</Order>
<Name>Mike</Name>
<FinalOrder>
<FinalOrder>
<OrderID>AZ9999</Order>
<Name>MikeSwiney</Name>
<FinalOrder>
Thanks
Hi,
Have a UDF with two inputs, first will be
OrderID->Split by value(ValueChange)->CollapseContext->
Second input will be
OrderID->Split by value(ValueChange)->Count
Take the first input as inp1 & other as count(type integer), with all values of context as execution type:
int cnt =-1;
for(int i =0;i<inp1.length;i++)
for(int j =0;j<count[i];j++)
result.addValue(cnt-j);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.