cancel
Showing results for 
Search instead for 
Did you mean: 

encoding

Former Member
0 Kudos

Hello experts,

I have recently built a file to file interface, the problem is my trading partner wants the target xml tag as shown below,

<?xml version="1.0" ?>.

But my target message is showing like the one shown below,

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

Now to match my trading partners requirement i want to remove (encoding="UTF-8") part

can any one please tell me how i can do that.

I think my doubt is clear.

Regards

Swetha

Edited by: swethaXI on Jan 8, 2012 6:20 PM

Edited by: swethaXI on Jan 8, 2012 6:20 PM

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Swetha,

I think this is solved already in other thread?

anupam_ghosh2
Active Contributor
0 Kudos

Hi Swetha,

I tried to solve the problem with XSLT mapping but could not do so. Now this the solution code to your problem by java mapping for version of PI 7.1 or above. In case you work in lower versions please let us know.

 
import java.io.FileInputStream; 
import java.io.FileOutputStream; 
import java.io.InputStream; 
import java.io.OutputStream; 
import java.util.Map; 


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 RemoveEncodingName extends AbstractTransformation { 

/** 
* @param args 
*/ 


public void execute(InputStream in, OutputStream out) 
throws StreamTransformationException { 
// TODO Auto-generated method stub 
try 
{ 
byte b[]=new byte[in.available()]; 
String encoding="UTF-8"; 
in.read(b); 
String inputXML=new String(b); 
inputXML="<?xml version=\"1.0\" ?>"+inputXML.substring(inputXML.indexOf('>')+1,inputXML.length()); 
out.write(inputXML.getBytes(encoding)); 
} 
catch(Exception e) 
{ 
e.printStackTrace(); 
} 

} 

public void setParameter(Map arg0) { 
// TODO Auto-generated method stub 

} 
public static void main(String[] args) { 
// TODO Auto-generated method stub 
try{ 
RemoveEncodingName genFormat=new RemoveEncodingName(); 
FileInputStream in=new FileInputStream("C:\\Apps\\my folder\\sdn\\copy.xml";); 
FileOutputStream out=new FileOutputStream("C:\\Apps\\my folder\\sdn\\copy1.xml";); 
genFormat.execute(in,out); 
} 
catch(Exception e) 
{ 
e.printStackTrace(); 
} 
} 

public void transform(TransformationInput arg0, TransformationOutput arg1) 
throws StreamTransformationException { 
this.execute(arg0.getInputPayload().getInputStream(), arg1.getOutputPayload().getOutputStream()); 

} 
} 


You need to import the class and the java file in the same Operation mapping below the current message mapping.Save and activate.

Please ignore rest of this message if you have worked with java mapping earlier. In case you are new to java mapping please try following these steps.

You need to compile this class in eclipse or NWDS. Ensure that you are using j2se 1.5.0 and correct library files for this purpose. These links might be helpful if you are new to java mapping

http://wiki.sdn.sap.com/wiki/display/XI/BeginnersguidetoJavamappingusingDOMparserinSAPXI -


PI 7.0 and PI 7.1

http://wiki.sdn.sap.com/wiki/display/XI/WheretogetthelibrariesforXI+development -


library resource

http://www.saptechnical.com/Tutorials/XI/Mapping/Index.htm -


mapping for PI 7.1

http://eclipse.org/galileo/ -


download eclipse

http://www.oracle.com/technetwork/java/archive-139210.html ; -


Install java

Hope this solves your problem.

Regards

Anupam

Former Member
0 Kudos

AFAIK java and xslt are two options:

former_member184681
Active Contributor
0 Kudos

Hi Swetha,

You should be able to remove the >>encoding="UTF-8"<< attribute using the XSLT mapping. You just need to start your mapping file with <?xml version="1.0" ?> and then follow with your mapping code.

Hope this helps,

Grzegorz

Former Member
0 Kudos

Hello Glowacki, thanks for your help, but i have already done my mapping and every thing, It will take lot of time to re do it since it is a very big mapping.

Regards

Swetha