cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping issue

Former Member
0 Kudos

Hi,

I'm working on File to Idoc scenario, where I'm populating 5 quantity info from file to Idoc in a different filelds. And I have one more field in Idoc, where I need to populate the summation of these 5 quantities.

where thes quanties are may or maynot contain from the structure. My code is working, if all the Items have the quantity info..but in real time, they may contain null values and some times they dont have nodes as well. can you guys help me on the same. Is there anything we can deal this with global container?

Input XML:

<?xml version="1.0" encoding="UTF-8"?>

<ns1:MT_Test xmlns:ns1="http://test.com/todo">

<RECORD>

<Header>

<Header1>HeaderInfo</Header1>

<Header2>W</Header2>

<Header3>00005</Header3>

<Header4>20</Header4>

</Header>

<Item_Details>

<Child_Info>

<Item1>

<Invoiced_Quantity>0000001</Invoiced_Quantity>

<Part_Number>1524251</Part_Number>

</Item1>

<Item2>

<Invoiced_Quantity/>

<Part_Number/>

</Item2>

<Item3>

<Invoiced_Quantity>0000003</Invoiced_Quantity>

<Part_Number>1524253</Part_Number>

</Item3>

<Item4>

</Item4>

<Item5>

<Invoiced_Quantity>0000005</Invoiced_Quantity>

<Part_Number>1524255</Part_Number>

</Item5>

</Child_Info>

</Item_Details>

</RECORD>

</ns1:MT_Test>

Note: Header (1-1), ItemDetails (1--Unbounded), Child_Info (1-Unbounded)

-Esha

Edited by: esha nadh on Mar 11, 2011 6:02 AM

Accepted Solutions (1)

Accepted Solutions (1)

RKothari
Contributor
0 Kudos

>>My code is working, if all the Items have the quantity info

Please let us know, if you are using standard functions or UDF for this.

>>they may contain null values and some times they dont have nodes as well.

For verifying if node is not present, you can make use of MapwithDefault function with value like 0.

If null values, if you are using UDF you can easily compare it with IF satatement as:

if (quantity.equals(""))

Former Member
0 Kudos

Rahul,

I'm using standard functions.. like exist and length check functions with context change..but its not handling the situation.

-Esha

RKothari
Contributor
0 Kudos

Length, Exist functions should be able to check the null and node presence.

Try using mapWithDefault function and below logic...

quantity--mapWithDefault(0) ---equalS--If Then Else----logic u are using---TargetNode
                   constant[]/

I hope it helps.

Answers (1)

Answers (1)

Former Member
0 Kudos

Try to Use these two node functions to solve your problem

MAPWITHDEFAULT

This function returns to target some default value when a empty context is coming from source side.

EXISTS

Function return true, if node exists else return false.