cancel
Showing results for 
Search instead for 
Did you mean: 

SAP PI : Remove or Ignore special character like #, ~ in file receiver adapter

0 Kudos

Hi Gurus,

   I need to ignore '#' character in file receiver adapter, Do you have any blog or idea to help me on this topic ?

  Thanks in advance.

Regards,

Min Eng.

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member190293
Active Contributor
0 Kudos

Hi Min Eng!

Do you have message mapping in your scenario? If so you could easily remove that characters within message mapping.

Regards, Evgeniy.

0 Kudos

Hi Evgeniy,

   Yes I have mapping.

Regards,

Min Eng.

former_member190293
Active Contributor
0 Kudos

Than you can use standard function "replaceString" in mapping to remove these characters.

Regards, Evgeniy.

Harish
Active Contributor
0 Kudos

Hi Min,

Adding to the Evgeniy's reply, If you have many fields in the input structure where this char needs to replace, then you can use the below code in "Attributes and Methods" in function tab of message mapping. Just replace the string with whatever char you want to replace.

public void transform(TransformationInput in, TransformationOutput out)

  throws StreamTransformationException {

try {

  String sourcexml = ""; String targetxml =""; String line ="";

  InputStream ins =    in.getInputPayload().getInputStream();

  BufferedReader br = new BufferedReader( new InputStreamReader(ins));

  while ((line = br.readLine()) != null) 

  sourcexml +=line+"\n"; 

  br.close();

  targetxml =sourcexml;

  targetxml = targetxml.replaceAll("string", "");

  out.getOutputPayload().getOutputStream().write(targetxml.getBytes());

  } catch (Exception e) {   throw new StreamTransformationException(e.getMessage());   }

}

regards,

Harish