cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping Help required

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

HI...

Thanks for immediate response.

The context is Node not the root.

I have done the same thing.

Shabarish_Nair
Active Contributor
0 Kudos

>

> 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.

Former Member
0 Kudos

Hi..

can you please provide the udf.

Regards

Leela

Shabarish_Nair
Active Contributor
0 Kudos

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

former_member208856
Active Contributor
0 Kudos

Hi,

Check the context for sender fields,

Use context change.

Sandeep