Skip to Content

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

To report this post you need to login first.

14 Comments

You must be Logged on to comment or reply to a post.

  1. 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]);

    }

    (0) 
      1. Former Member

        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

        (0) 
  2. 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

    (0) 

Leave a Reply