Skip to Content
0

Target field not creating with Null value

Nov 16, 2016 at 01:30 PM

196

avatar image
Former Member

Hi All,

I am trying to execute a message mapping, when ever source field contains Null(empty) value, target field is not generating for the same. Can anyone please help me how to insert this null value in target field?

Thanks.

10 |10000 characters needed characters left characters exceeded
Former Member

HI Remo,

I agree with Evgeniy solution and also you are saying that the values are getting jumbled like instead of going the field value into F3 it's going to F2( if i am not wrong). It may happens because of queues handling. check the context of queue.

Regards,

Janardhan

0
* Please Login or Register to Answer, Follow or Comment.

9 Answers

Evgeniy Kolmakov Nov 16, 2016 at 01:54 PM
1

Hi Remo!

NULL value (unlike empty value) means that value is underfined, though target element isn't created. If you need target element to be created you should have any value for it (even if it's an empty string) or use standard functions such as "MapWithDefault".

Regards, Evgeniy.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Nov 18, 2016 at 10:31 AM
0

Hi Evgeniy,

some time that field contains value some times empty. for example in same message 2 records will be coming (ex:consider field as A)

in one record A contains value and in another record A field itself not coming. In this case for first record in output all field values are inserting properly. In second case due to A field not coming in that place next field value is inserting there.

Please help.

Thanks.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Remo!

Use MapWithDefault standard function, for example, to add predefined constant value to target field if source field does not exist.

Regards, Evgeniy.

0
avatar image
Former Member Nov 18, 2016 at 11:09 AM
0

Hi Remo,

Use "exists" node function first and check whether node is comming or not. As its returns value as boolean i.e, true or false. Use an "if-else" condition, and pass the value comming from "exists" and map node in "then" for true and a constant as "" (null) in "else" case(for false).

I used this thing in many MM and it's working perfectly.

Regards,

Anoop Kumar Rai.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Nov 18, 2016 at 11:23 AM
0

Hi Anoop,

I am using same condition, when node is not incoming its not creating empty field in ouput.

Ex:

from abouve, Field1 value is inserted exactly, from paylod F2 is not coming so in that field value is not inserting as "empty" instead of that F3 value '3' is inserting in F2.

<F1>1</F1>

<F3>3</F3>

Thanks.


im1.png (814 B)
Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi,

Are you want blank field in target side? Then change constant value as " " (space) that i told you to use at else in if-else condition.

Actually, as per SAP, if field value is null, then it not populate that field in XML. But as if you want that field in your target XML structure then send a space in if-else condition.

But, its not possible the thing that you specify in last comment. F3 field value never go to F2 field. If F2 is target field and value is null then it will not populate in target XML. Can you share ur Mapping screen shot to understand your requirement in better prospect.

Regards,

Anoop Kumar Rai

0
Evgeniy Kolmakov Nov 18, 2016 at 11:40 AM
0

Hi Remo!

If your structure looks like:

<record>
<fieldA>1</fieldA>
</record>
<record/>
<record>
<fieldA>3</fieldA>
</record>

than fieldA->MapWithDefault("")->targetField will return:

1
""
3

Regards, Evgeniy.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Nov 18, 2016 at 12:21 PM
0

Hi Anoop,

Its working, but in my case when i have more than 1 record incoming in a message:

<abc>

<record1>

<F1> a</F1>

<F2>b</F2>

<F3>c</F3>

</record1>

<record2>

<F1> 1</F1>

<F3>3</F3>

</record1>

</abc>

output is like this:

capture1.png

But it should be:

capture2.png


capture1.png (944 B)
capture2.png (1.1 kB)
Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Nov 18, 2016 at 12:23 PM
0

Hi anoop,

Its working for only 1 record in a message, but in my case when i have more than 1 record incoming in a message:

<abc>

<record1>

<F1> a</F1>

<F2>b</F2>

<F3>c</F3>

</record1>

<record2>

<F1> 1</F1>

<F3>3</F3>

</record1>

</abc>

output is like this:

But it should be:

Please help.

Thanks.


capture1.png (944 B)
capture2.png (1.1 kB)
Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi,

Can you please share your mapping for F2 field.

Everytime you are giving me an Excel table screenshoot as output. Are you saving this file as .xsl/xsls at target?

Regards,

Anoop Rai.

0
avatar image
Former Member Nov 21, 2016 at 07:28 AM
0

Hi,

yea, my output is excel only.

Thanks.

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Remo,

Then use "tab" instead of "space" in constant when field node is not there, means in else condition.

Because space will not going to create new field in Excel. And save that file .xls.

Hope it will work now.

Regards,

Anoop Kumar Rai.

0
avatar image
Former Member Nov 23, 2016 at 08:23 AM
0

Hi Anoop,

thanks alot for your inputs. I have used MapwithDefault in some cases and UseOneAsMany in some fields and now its worked. Its wired which i have faced is some cases UseOneAsMany not worked and in some cases MapwithDefault didnt work.

Anyhow for me its happening.

Thanks.

Share
10 |10000 characters needed characters left characters exceeded