Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

JDBC to IDOC scenario with Java mapping

Hi Experts,

I have developed JDBC to IDOC scenario in PI 7.0.

The problem is with the special character '&'

I am getting different fields for Item, in that there is one field 'Item_description'

I am getting the input value like

<Item_Description>specification for electroless nickel plating &#x16;


When ever i got the payload from the sender system as an xml format and the value for 'Item_description" as specified above

because of special character '&' the message is failed in PI.


I am manually removing that special character from payload and again re sending then it is successfully processed to Target system.


I have decided to go for Java mapping and I have developed the code as below.

Java code:

package com.Mapping;

import java.io.InputStream;

import java.io.OutputStream;

import com.sap.aii.mapping.api.AbstractTransformation;

import com.sap.aii.mapping.api.StreamTransformationException;

import com.sap.aii.mapping.api.TransformationInput;

import com.sap.aii.mapping.api.TransformationOutput;

public class Mapping_Java extends AbstractTransformation {

     public void transform(TransformationInput transformationInput,

               TransformationOutput transformationOutput)

               throws StreamTransformationException {

          try {

               InputStream inputstream = transformationInput.getInputPayload()

                         .getInputStream();

               OutputStream outputstream = transformationOutput.getOutputPayload()

                         .getOutputStream();

               byte[] b = new byte[inputstream.available()];

               inputstream.read(b);

               String strContent = new String(b);

              

               if (strContent.contains("&")) {

                    getTrace().addInfo("& is present");

  strContent = strContent.replaceAll(" ", "&");

               }

               outputstream.write(strContent.getBytes());

          } catch (Exception exception) {

               exception.printStackTrace();

          }

     }

}

The above code works for it can replace the "&" by Tab space.

I was stuck here, That I want to remove that '&' symbol only for 'Item_description' field not for remaining fields.

I hope we should write some condition for the above code to replace '&' for only that field.

Please guide me friends,

How to add that condition in that code and how to go for java mapping for PI 7.0 version.

it help full to me a lot.

Thanks in Advance,

Regards,

Teja.

Former Member
Former Member replied

Hi All Thanks for all your replies and Support. Finally the problem has been solved with out using Java mapping and and with out writing any UDF.

Please find the below screenshots.

Tested in Message mapping and Operation Mapping, it is success.

The message is successfully reached target.

Thanks to all

Regards,

Teja.

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question