on 10-01-2008 5:28 AM
Hi...
Please help in user defined function
<?xml version="1.0" encoding="utf-8" ?>
- <ns1:mt_out xmlns:ns1="http://Block">
- <Material>
<Item>0</Item>
<ItemName />
<ReqQty>0</ReqQty>
<AvailQty>0</AvailQty>
<Cost>100</Cost>
<suppid />
<suppname />
<leadtime>0</leadtime>
<matname>Y-351</matname>
<plantloc>2222</plantloc>
<date>2008-09-30T00:00:00</date>
<orderqty />
<warehouseloc />
<unit>KG</unit>
</Material>
- <Material>
<Item />
<ItemName />
<ReqQty>0</ReqQty>
<AvailQty>0</AvailQty>
<Cost>200</Cost>
<suppid />
<suppname />
<leadtime>0</leadtime>
<matname>Y-355</matname>
<plantloc>1111</plantloc>
<date>2008-09-30T00:00:00</date>
<orderqty />
<warehouseloc />
<unit>KG</unit>
</Material>
- <Material>
<Item />
<ItemName />
<ReqQty>0</ReqQty>
<AvailQty>1000.000</AvailQty>
<Cost>0</Cost>
<suppid />
<suppname />
<leadtime>0</leadtime>
<matname>Y-352</matname>
<plantloc>1100</plantloc>
<date>2008-09-30T00:00:00</date>
<orderqty />
<warehouseloc />
<unit>KG</unit>
</Material>
</ns1:mt_out>
The output file is
<Material>
<ProcurementCost />
<OtherCost />
<TotalCost />
</Material>
The input file is having multiple records. If the AvailQty feild is "0", then, the corresponding record will be having the cost.
The Total cost should be the sum of all the costs in the input file. ( I should get 100 + 200 )
Could you please in defining user defined function for the above reqiurement..
Hi,
That is possible using standared functions itself..
AvailQty(EqualsS(Text Function))Constant(0)IfWithout(Boolean)
then(Cost(Context Parent)Sum(statistic function)map with target...
Regards,
Prakasu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Try the below udf
use cache parameter as context
here a = avail_qty
b = cost
public void total(String[] a,String[] b,ResultList result,Container container)
{
//write your code here
int total_cost = 0;
for(i = 0;i != a.length;i++)
{
if(a<i>.equals("0"))
{
total_cost = total_cost + Integer.parseInt(a<i>);
}
}
result.addValue(total_cost);
}
avail_qty--------\
total-------->tgt
cost--------------/
Edited by: malini balasubramaniam on Oct 1, 2008 6:49 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
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.