cancel
Showing results for 
Search instead for 
Did you mean: 

How to remove null from queue context using UDF in SAP PI mapping

jamaic
Explorer
0 Kudos
2,753

Hi There,

I trying to map an ORDERS IDoc to EDI ANSI X12 850 and my message mapping is creating SUPPRESS and <null> values in the context. Specifically, i'm trying to map the IDoc segment E1EDPT1/E1EDPT2/TDLINE to L_PID (X12 850). The <null> values is causing the output L_PID not to be created as desired. I would have used RemoveContext and SplitByValue after the IfwithoutElse, but i don't want to destroy the context. In an attempt to remove the <null> values, i wrote a UDF but it didn't help. Attached are the screenshot of the problem.

This is the mapping:

image.png

These are the SUPPRESS values from the output of the IfwithoutElse

Here i'm trying to delete the SUPPRESS values and it produces the <null> values.

Here i'm trying to remove the <null> values with a UDF, but it still doesn't work.

Here's my UDF. Trust me i've google the internet for sample UDFs.

Regards,

Accepted Solutions (1)

Accepted Solutions (1)

jamaic
Explorer
0 Kudos

Hi, I found a solution for the <null> value problem. Immediately after the IfwithoutElse, use the mapWithDefault and choose a default value like XYZ. As you can see from the Display Queue of the mapWithDefault, all the SUPPRESS values have been replaced with XYZ. After the mapWithDefault, implement your UDF to filter out the default value XYZ as shown below. The Display Queue of the UDF shows the <null> values have all disappeared.

Here's the UDF code:

Answers (3)

Answers (3)

0 Kudos

Hi ,

The UDF works only in your test case. if the XYZ values are populated two or more than two, then if fails to remove the values.

Thanks,

Pradeep.

0 Kudos

Hi Chuo,

Try the below code to remove SUPRESS:

1. Enable KeepSUPRESS for the IfwithoutElse

2. Delete both of your UDFs and replace it with the above code and it should work.

jamaic
Explorer
0 Kudos

Hi Sneha,

Thanks for weighing in. I deleted both of my UDFs, enabled the KeepSUPPRESS and replaced it with your code, but the <null> values are still there. Below is the results that i got.

Regards,

Chuo

PriyankaChak
Active Contributor
0 Kudos

Hi Chuo,

Have you tried using combination of remove context and then format by example?

Regards,

Priyanka

jamaic
Explorer
0 Kudos

Hi Priyanka,

Thanks for your input. I've tried a combination of RemoveContext, SplitByValue and FormatByExample, but the <null> values are still there. Here's the results i got.

Regards,

Chuo