cancel
Showing results for 
Search instead for 
Did you mean: 

How to map so that target node is not created if the source value is blank?

gopalkrishna_baliga
Participant
0 Kudos

Hi Experts,

I have to map Qty field from source to Stock element of target XML.

Now if Qty value is 0 it is still generating the target Stock element which is empty (</Stock>). What I need is that if Qty is 0 then <Stock> element should not be generated at all. I am uisng graphical mapping.

How to achieve this? kindly help

Thanks

Gopal

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

In case you are using an UDF, you could use, resultnode.suppress().

This would suppress the creation of the target node and all the subelements under it.

Regards,

Smitha.

gopalkrishna_baliga
Participant
0 Kudos

I have written a UDF and output of this I am splitting by value (SplitByValue).

GetQnty(UDF) ->SplitByValue ->Stock

So how do I change my mapping so that stock is not created for Qnty = 0.

Kindly help

Thanks

Gopal

gopalkrishna_baliga
Participant
0 Kudos

Can I map it like this?

GetQnty(UDF) ->SplitByValue ->

not equals -> Createif ->Stock

Constant[] -


>

Please help!

Thanks

Gopal

Former Member
0 Kudos

In your UDF, check for the quantity value and then use a if condition to check if it is equal to zero. If it is equal then use resultnode.supress with in the code.

Regards,

Jai Shankar

prabhu_s2
Active Contributor
0 Kudos

i hope SplitByValue might be req in this case. just map the source and target node theu the udf and test the mapping in MM or in IM. This will get you the result.

Former Member
0 Kudos

Gopal,

Are you using a simple UDF or an advanced UDF?

You need a advanced UDF to achieve this....

Your code for the advanced UDF should be some thing like this...

int res = Integer.parseInt(a[0]);

if (res==0)

{

result.addSuppress();

}

else

{

//write the logic here

}

Regards,

Jai Shankar

Former Member
0 Kudos

Hi,

If you are using the message mapping, then use createif

qty--if greater than 0 then -- createif -- target node.

here you can check the exist also .but..

if you are using any UDF then you can suppress the value to it if it is 0.

Regards..

Chilla..