cancel
Showing results for 
Search instead for 
Did you mean: 

How create a empty field mapping?

Former Member
0 Kudos

Dear All,

I am new to PI,I have requirement that is I have one from source side(0 to 1,string) if the field is empty then PI mapping will be failed and throw an error

field is missing.

Could you please help me that how can I do this.

Regards

Kiran

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member187587
Contributor
0 Kudos

A field that its occurrence is 0...1 is not mandatory.

If the schema was generated by you (not imported) then you can change the XSD and make that field mandatory.

Then use schema validation in the Adapter engine to make the message fails when the field restriction is not met.

This way, you will use the standard mechanism of SAP PI.

former_member182412
Active Contributor
0 Kudos

Hi Kiran,

Use below UDF.


public String throwMandatoryFieldException(String fieldName, String fieldvalue, Container container) throws StreamTransformationException{

if (!fieldvalue.equals(""))

  return fieldvalue;

  else

  throw new StreamTransformationException("Mandatory field " + fieldName  + " is missing!");

  }

Mapping:

Testing:

Regards,

Praveen.

bhagya_nayanala
Explorer
0 Kudos

Hi Kiran

Please delete the duplicate thread.

You can use MapwithDefault function from the Graphical mapping editor to avoid error.

Regards

Bhagya