Skip to Content
avatar image
Former Member

Mapping issue

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"?>

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

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Mar 11, 2011 at 05:06 AM

    >>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(""))

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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.

  • avatar image
    Former Member
    Mar 11, 2011 at 05:44 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded