on 01-07-2009 5:07 AM
Hi ..
I need mapping help for the below requirement.
Below is the input file.
Root
Node -
0---unbounded
Materialname
ReqQty
AvailQty
Cost
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Root xmlns:ns0="http://ProcurementCost">
<Node>
<Matname>Test1</Matname>
<ReqQty>5</ReqQty>
<AvailQty>0</AvailQty>
<Cost>1000</Cost>
</Node>
<Node>
<Matname>Test1</Matname>
<ReqQty>5</ReqQty>
<AvailQty>0</AvailQty>
<Cost>0</Cost>
</Node>
<Node>
<Matname>Test1</Matname>
<ReqQty>5</ReqQty>
<AvailQty>0</AvailQty>
<Cost>2000</Cost>
</Node>
</ns0:Root>
the condition is if the AvailQty is 0, then Totalcost,PCost,and OtherCost should be 0
or esle
Totalcost=(ReqQty-AvailAty)*cost (It should calculate for the sum of all ReqQty and AvailQty)
Pcost=[(ReqQty-AvailAty)*cost]+1500(It should calculate for the sum of all ReqQty and AvailQty)
OCost=0
I have done mapping for the above condition using if . But it is considering only the first record. It is not taking other than first record into consideration. Could you please help in this issue.
Thanks,
Leela
Hi leela,
Try the below mapping.
AvailQty-- equalsS(Text Func.)Ifelsethen(constant(0))--Else---->
Constant(0)
for Else part...
ReqQty(change context to (Node))sum(statistic func.)
AvailQty(change context to (Node))sum(statistic func.)sub(ArithmaticFunc.)---
Cost(change context to (Node))sum(statistic func.)mul(ArithmaticFunc.)>removecontext(fun.)->else
for PCost after mul(ArithmaticFunc.) use add function and add the constant(1500).
Regards,
Prakasu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Can you check which context is assigned for the node. you will get from context menu by right clicking on the source node...of your mapping)
context should be assigned to node not for root.
Regards,
Sreenivas.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>
> Hi ..
> I need mapping help for the below requirement.
>
> Below is the input file.
> Root
> Node -
0---unbounded
> Materialname
> ReqQty
> AvailQty
> Cost
> <?xml version="1.0" encoding="UTF-8"?>
> <ns0:Root xmlns:ns0="http://ProcurementCost">
> <Node>
> <Matname>Test1</Matname>
> <ReqQty>5</ReqQty>
> <AvailQty>0</AvailQty>
> <Cost>1000</Cost>
> </Node>
> <Node>
> <Matname>Test1</Matname>
> <ReqQty>5</ReqQty>
> <AvailQty>0</AvailQty>
> <Cost>0</Cost>
> </Node>
> <Node>
> <Matname>Test1</Matname>
> <ReqQty>5</ReqQty>
> <AvailQty>0</AvailQty>
> <Cost>2000</Cost>
> </Node>
> </ns0:Root>
>
> the condition is if the AvailQty is 0, then Totalcost,PCost,and OtherCost should be 0
> or esle
> Totalcost=(ReqQty-AvailAty)*cost (It should calculate for the sum of all ReqQty and AvailQty)
> Pcost=[(ReqQty-AvailAty)*cost]+1500(It should calculate for the sum of all ReqQty and AvailQty)
> OCost=0
>
> I have done mapping for the above condition using if . But it is considering only the first record. It is not taking other than first record into consideration. Could you please help in this issue.
>
> Thanks,
> Leela
you can write a UDF for this. Use the advanced UDF. get all the values of ReqQty and AvailQty in a queue.
write a logic to add all the values of ReqQty and AvailQty. Also remember to right click the ReqQty and AvailQty fields that are input to the UDF and change the context to root of the XML.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
it will be a advanced UDF;
the input will be the fields ReqQty and AvailQty and their context will be changed to the top most context of the xml.
int SumReqQty, SumAvailQty = 0;
for(int x; x < ReqQty.length; x++)
{
SumReqQty = SumReqQty + ReqQty[x];
}
for(int y; y < AvailQty.length; y++)
{
SumAvailQty = SumAvailQty + AvailQty[x];
}
then attach whatever logic you want and enhance the above code
Hi,
Check the context for sender fields,
Use context change.
Sandeep
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
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.