cancel
Showing results for 
Search instead for 
Did you mean: 

Validation of optional fields in mappings

Former Member
0 Kudos

Hi Experts,

We are using SAP PI 7.0 and my requirement is pretty simple.

We have certain optional fields at target side and my requirement is whenever there is no value/if the source field doesn't exists then some mapping error should be display in SXMB_MONI or in simple words mapping should not be executed at all and it should display error message.

I tried by using the below UDF but it is not working as expected (by using MapWithDefault and TRIM standard functions)

if (a.equals(""))

{

throw new RuntimeException ("SRC_FIELD1 is empty")

}

else

return a;

Your help is highly appreciated

Regards

Faisal

Accepted Solutions (0)

Answers (2)

Answers (2)

RaghuVamseedhar
Active Contributor
0 Kudos

Abdul,

If target field occurrence is 1..1, and source is missing then error will be created.

FYI, you can also try this.

        if (var1.equals("false")) {

            throw new StreamTransformationException("Field is missing in input");

        }

        return var1;

Former Member
0 Kudos

Yep what Raghu said. This will check if the element is supplied on the source side. You also need to check in the UDF when the element is supplied and it's blank so add another parameter to the UDF and pass in the value of source element also. Check if this value is equal to empty string ("")

Former Member
0 Kudos

can you try as Michals blog - include the dynamic variable assignment in IF condition

or

If you want to error/ ignore the message  in receiver determination by using xpath condition with Exist or !="" send to receiver