cancel
Showing results for 
Search instead for 
Did you mean: 

How to ignore null values in a filed

0 Kudos

Hi folks,

Kindly suggest me for below issue.

i am getting null values in my field . but i should need to ignore null values and need to send the remaining values for my target.

Kindly request you to provide me any UDF or how to solve this issue.

Best regards,

Hari.

Accepted Solutions (1)

Accepted Solutions (1)

iaki_vila
Active Contributor
0 Kudos

Hi Hari,

Check this logic, i think it could be helpful for you:

Regards,

0 Kudos

Hi Iñaki Vila,

thanks for your quick reply.

currently my project is using sap pi 7.0.

with the using above logic i am getting the error. and in the mapping RemoveDuplicates is the UDF.

Kindly sugguest me to resolve the issue.

thank you so much inadvance.

Best regards,
Hari.

iaki_vila
Active Contributor
0 Kudos

Hi Hari,

First of all on the THEN input you are EXT_LOC.. without the same context that the begging of the mapping and seems that the output is wrong because is getting always the same value.

In your source XML i can't see any duplicate, at least in your example and may be the UDF removeDuplicates was not necessary.

Regards.

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Hari,

Use this logic EXT_LOC -> removeDuplicates -> ifWithoutElse logic by Inaki and then after that use removeContext.

Regards,

Mark

0 Kudos

Hi Iñaki Vila,

Kindly look into below one.

here my requirement is need to ignore null values as well duplicate values.

Kindly suggest me any UDF or any alternate way to resolve the issue .

Thanks in advance.

best regards,

Hari.

iaki_vila
Active Contributor
0 Kudos

Hi Hari,

If you can change the order of the elements, you can avoid the duplicates without own UDF:

Regards.

0 Kudos

Hi Iñaki Vila,

thank you so much ...

issue got resolved.

iaki_vila
Active Contributor
0 Kudos

Hi

Answers (1)

Answers (1)

yeeloon-khoo
Explorer
0 Kudos

Hi Hari,

some suggestion:

input --> passIfHasValue(UDF1) --> output1 -->  removeSuppress(UDF2)  --> output2

UDF1 to act as filter to remove empty/null value, and pass value from source to target:

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

  String value = contextValues[i];

 
  if (value != null && value.trim().length() > 0){

      result.addValue(value);

  }

  else{

      result.addSuppress();

  }
}


UDF2. If you don't want suppress at later stage, feed to another UDF removeSuppress

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

  String value = contextValues[i];


  if (!ResultList.SUPPRESS.equalsIgnoreCase(value)){

      result.addValue(value);

  }

}

Regards,

Yee Loon