cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with '&' in Payload.

Former Member
0 Kudos

Hi Experts,

In my sender side payload I have received '&', can we change this in the payload as mapping is giving some error and is not ready to accept this string.

Regards,

Study SAP

Accepted Solutions (1)

Accepted Solutions (1)

aashish_sinha
Active Contributor
0 Kudos

Hi,

refer this thread will help you.

Regards

Aashish Sinha

PS : reward points if helpful

Answers (4)

Answers (4)

stefan_grube
Active Contributor
0 Kudos

Make sure, that your send send valid XML.

Try to convince the sender to change & to & amp; as it is easier to do it there.

Regards

Stefan

former_member238007
Contributor
0 Kudos

Hi,

is this may work out for u try once.. declare that field which accepts & as string, and do the mapping with the string field for the output also, i worked it it is working fine..

regards

Kishore

sunil_singh13
Active Contributor
0 Kudos

Hi ,

You can definetly write java code for that .You can Replace "&" sign with come symbol like "_-#_" when your payload enters in XI for the first time and then again replace

"_-#_" with " &" when it comes out .

Rewards points if helpful

Thanks

Sunil Singh

Former Member
0 Kudos

HI,

can you please eloborate your questinn ....

Praveen Kalwa

Former Member
0 Kudos

This is my XML for mapping,

<MSG>

<MSG01>ALONG WITH PROCTER & GAMBLE</MSG01>

</MSG>

I am receiving error for this string &,

if I am replacing it mannually with and, it is working fine,

How i can replace it during runtime mapping ?

Regards,

Study SAP

GabrielSagaya
Active Contributor
0 Kudos

You should not replace & manually.

You can choose Javamapping by 2 ways.

1) You can use Javamapping to replace & by "&amp;

package sample;

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

import java.io.*;

import java.util.Map;

public class MyJavaMapping implements StreamTransformation {

public void setParameter(Map map) {

}

public void execute(InputStream in, OutputStream out)

throws StreamTransformationException {

try {

int c;

while ((c = in.read()) != -1) {

if (c != '&') {

out.write(c);

} else {

out.write("&amp;".getBytes());

}

} // while

out.flush();

} catch (Exception e) {

throw new StreamTransformationException(e.getMessage(),e);

}

}

}

2) You can choose Javamapping by replacing the encoding UTF-8 to ISO-8859-1 which accepts & as as it is.

For more details check this guide:

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/502991a2-45d9...

Former Member
0 Kudos

CAN WE USE USER DEFINED FUNCTION ?

Give an idea, if possible,

Regards,

Study SAP

aashish_sinha
Active Contributor
0 Kudos

Hi,

try this &amp; in you input xml.. this will help you.

<?xml version="1.0" encoding="UTF-8"?>

<ns0:MT_Tot_Out xmlns:ns0="urn:Aash:JavaMappingTest"><TotalVal>TTTTTTTTT P &amp; Q</TotalVal><Name>MMMM</Name></ns0:MT_Tot_Out>

Regards

Aashish Sinha

PS : reward points if helpful

Former Member
0 Kudos

it is not working,

GabrielSagaya
Active Contributor
0 Kudos

You cant use UDF

Since you are going to transform '&' by using DataInputStream and DataOutputStream

You can use only java mapping........

or other wise you can use XSLT mapping by converting the encoding from UTF-8 to ISO-8859-5

<xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" encoding="ISO-8859-5"/>

<xsl:template match="/">

<xsl:copy-of select="*" />

</xsl:template>

</xsl:stylesheet>

Former Member
0 Kudos

Hi,

I don't think for this kind of operations you need to go for Java Mapping.

& is the Bitwise Operator used in Java, so in String it was giving you the error.

The bitwise & operator performs a bitwise AND operation.

The bitwise ^ operator performs a bitwise exclusive OR operation.

The bitwise | operator performs a bitwise inclusive OR operation.

You could avoid it by adding \&. Please use below UDF

Soruce field (A) --> UDF --> Target

rodrigoalejandro_pertierr
Active Contributor
0 Kudos

Hi,

go to

RSKC and replace de ALL_CAPITAL and add the & and save the changes. also try to replace the enconding to UTF-8