Skip to Content
Author's profile photo Daniel Graversen

null in the SAP PI mapping context queue

One of the things that really can get me up the red field is when I get an <null> element when working with a SAP PI mapping. Or I would say rather debugging, because of some strange incoming data. Why not give me something that I can us in way mapping to check for. The <null> gives a lot of issues for figuring out if the values work.

I’m not sure what causes this to be like it is. It may be a null string or something like it.

The build in function “isNil” delivered this result. I guess it checks if the values is XSI:Nil. I would have guess that this delivered a false value for this input.

So I had to create my own function to check for this.

The isNull function that I created looks like this:

for(int i=0;i<var1.length;i++){
if (var1[i]==null){
result.addValue(“true”);
}else{
result.addValue(“false”);
}
}

If I then want to do an OR function after this, where on input can be null then it does not solve my problem. false or <null> does give <null>. Dam. So I cannot use the function that I wanted.

So I just have to build in the length check into my null function, so it does support the extra function. I could also build an OR function to support this extra features, but that will not add a lot of extra value. I’m only using this

So the new function looks like this.

for(int i=0;i<var1.length;i++){
String tmp  = var1[i];
if (tmp == null){
   result.addValue(“false”);
}else{
  result.addValue(tmp.length()>0);
}
}

I do hope that you find this helpful and it solve some of your problems. I’m working on creating a course around how to use SAP PI/PO. I have created some free videos around creating your first scenario that you can get on http://picourse.com

Assigned Tags

      14 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Sunil Mavachee
      Sunil Mavachee

      Hello Daniel

      Nice info. Looking ahead for some more mapping blogs from you in coming days... 🙂

      Have a great day.!

      Regards,

      Sunil

      Author's profile photo Daniel Graversen
      Daniel Graversen

      Hi Sunil.

      Glad you liked it.

      Author's profile photo Former Member
      Former Member

      Hi Daniel.

           Nice info... Thanks for the new concept... Hav a good day... :):)

      Author's profile photo Daniel Graversen
      Daniel Graversen

      Most welcome. You too.

      Author's profile photo Former Member
      Former Member

      Hi Daniel


      One add on....

      UDF To remove this <Null>

      public void removeNull(String[] input,ResultList result,Container container){

      for (int i = 0; i < input.length; i++) {

        result.addValue(input[i]);

      }

      Author's profile photo Daniel Graversen
      Daniel Graversen

      Thanks for sharing.

      Yes it removed null. But then you dont have any values after it. So It could make challenges in your contexts if they should are important.

      Author's profile photo pavan thiruveedula
      pavan thiruveedula

      Hi Daniel,

      thanks for nice blog, i am new to PI ,while creating this UDF which type we need to choose value, context or queue ?

      Thanks & regards

      Pavan

      Author's profile photo Daniel Graversen
      Daniel Graversen

      Hi

      It needs to be context otherwise you will not have the array.

      daniel

      Author's profile photo Naveen Kumar Reddy chichili
      Naveen Kumar Reddy chichili

      Hi Daniel,

      Its really Nice blog, Thank you very much for the blog.. 🙂

      Regards,

      Naveen

      Author's profile photo Stefan Hilpp
      Stefan Hilpp

      Hi Daniel,

      looks very good...thank you for the effort

      Regards

      Stefan

      Author's profile photo Tulasiram Donkena
      Tulasiram Donkena

      Hi Daniel,

      Thanks for the nice information. We are waiting for new updates...

      Author's profile photo Carlos Ocampos
      Carlos Ocampos

      Hi Daniel,

      Congratulations!! Thanks for sharing!

      Kind regards

      Carlos

      Author's profile photo Former Member
      Former Member

      Hi Daniel,

      Thanks for sharing.

      Regards

      Nurhan

      Author's profile photo Former Member
      Former Member

      Hi Daniel,

      How to check xsi:nil using the same UDF. I don't want to use built in "isNil" since it does not return true or false when the value is <null>. so I want to make use of above UDF along with xsi:nil validation.

      Could you please help me with this.

      Thanks,

      Suman