Skip to Content
avatar image
Former Member

Target field not creating with Null value

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.

Add comment
10|10000 characters needed characters exceeded

  • 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

  • Get RSS Feed

9 Answers

  • Nov 16, 2016 at 01:54 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 18, 2016 at 10:31 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 18, 2016 at 11:09 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 18, 2016 at 11:23 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

    • 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

  • Nov 18, 2016 at 11:40 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 18, 2016 at 12:21 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 18, 2016 at 12:23 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

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

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

    Hi,

    yea, my output is excel only.

    Thanks.

    Add comment
    10|10000 characters needed characters exceeded

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

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

    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.

    Add comment
    10|10000 characters needed characters exceeded