Page tree
Skip to end of metadata
Go to start of metadata

There were few post in the forum asking how to read the Input Text file in to Single field of the structure. Can this be done using a FCC? NO.

Then how this can be done. This scenario is similar to my wiki post Java Mapping- Convert the Input xml to String. Follow the below steps.

 S2S (Steps to Solution):

1. Configure the sender file adapter to read the source file without any FCC.

2. Create the Message Type.

3. Create a Message Interface for the Message Type.

4. Use the following Java code to read the input file and add it to a field of the Message structure. Export this Java Mapping as a Jar file using NWDS and Import the Jar in to IR.

import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import org.w3c.dom.Element;
import org.w3c.dom.Document;
import org.w3c.dom.Text;
* @author santhosh kumar v
public class xmlpayload implements StreamTransformation {

public void setParameter(Map param)
{ Map map = param; }

public void execute(InputStream in, OutputStream out)
throws {
try {

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
TransformerFactory tf = TransformerFactory.newInstance();
Transformer transform = tf.newTransformer();

Document docout = db.newDocument();

Element root = docout.createElement("MT_Trg");

Element stringinp = docout.createElement("stringinp");

//***************\**Code To Read the Input Stream and Convert it to String*\***********************//

BufferedReader inpfile = new BufferedReader(new InputStreamReader(in));
StringBuffer buffer = new StringBuffer();
String line="";
while ((line = inpfile.readLine()) \!= null)
{ buffer.append(line); }
String inptfile=buffer.toString();

Text srcxml = docout.createTextNode(inptfile);

DOMSource domS = new DOMSource(docout);
transform.transform((domS), new StreamResult(out));

} catch (Exception e)
{ System.out.print("Problem parsing the file: " + e.getMessage()); e.printStackTrace(); }

5. In the Interface Mapping select both the Source and Target interface as the same message interface that is created.

6. Select the Mapping Program Type as Java Class and choose the java class mapping program.

Input Payload in SXMB_MONI:

Output Payload in SXMB_MONI:


Hello ,

I did this using graphical mapping and FCC in PI 7.1 ...


  1. Unknown User (1012ormgj)

     Hi Santhosh,

         I did exactly as mentioned in your wiki,but I am getting a Linkage error.see below
    - --
     Request Message Mapping
    - <SAP Error xmlns:SAP="-" xmlns:SOAP="-" SOAP:mustUnderstand="">
      <SAP Category>ApplicationSAP Category>
      <SAP P 1>xmlpayloadSAP P1>
      <SAP P2>test:urn:test_file_to_fileSAP P2>
      <SAP P3>d4224370-e154-11dc-94cd-c763ac1383c5SAP P3>
      <SAP P4>-1SAP P4>
      <SAP AdditionalText />
      <SAP ApplicationFaultMessage namespace="" />
      <SAP Stack>Incompatible class versions (linkage error)SAP Stack>
      <SAP Retry>MSAP Retry>
      SAP Error>

    Can you please guide me how to rectify the error?

  2. Anonymous

    this is possible using FCC

  3. Unknown User (106b7gqby)

    Please remove blog with faulty explanation or notes...why are you misguiding readers??????????????????