Skip to Content

Writing a file to NFS server


Could you please suggest how to proceed to the below scenario.

Scenario is from SOAP-IDOC.Client is sending the XML document through SOAP,in which we are sending the payload to ECC as general case.But at the same time they are sending the whole document in one of the fields using BASE 64.

So in PI we have to read that field and have to write it to File and place it in NFS server.

Could you please help how can we write that file using UDF.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 26, 2013 at 04:14 PM

    Hi Santhoshi,

    As you have two scenario; One to generate an Idoc and another to create a file, Use two operations mappings in Interface determination. One mapping to Idoc and another will to Soap to File mapping to map entire field to create file in desired format.



    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 27, 2013 at 08:49 AM

    Hi Santhoshi

    Your requirement can be fulfilled in the below way

    1. Create two operation mapping OM1 and OM2

    2. For OM1 use the mapping for soap idoc to ECC idoc.

    3. For OM2 use a java mapping between soap idoc and the file.

    Please use the java mapping code as below



    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.apache.commons.codec.binary.Base64;

    import org.w3c.dom.Document;

    import org.w3c.dom.NodeList;





    public class JMDecodeDetails extends AbstractTransformation {

    public void transform(TransformationInput arg0, TransformationOutput arg1)

    throws StreamTransformationException {

    try {

    DocumentBuilderFactory factory = DocumentBuilderFactory


    DocumentBuilder builder = factory.newDocumentBuilder();

    Document docOld = builder.parse(arg0.getInputPayload()


    NodeList details = docOld.getElementsByTagName("Details");

    String data = details.item(0).getChildNodes().item(0).getNodeValue();

    byte[] decodedBytes = Base64.decodeBase64(data.getBytes());

    Document docNew = builder.parse(new ByteArrayInputStream(decodedBytes));

    TransformerFactory transformerFactory = TransformerFactory


    Transformer transformer = transformerFactory.newTransformer();

    DOMSource source = new DOMSource(docNew);

    StreamResult result = new StreamResult(arg1.getOutputPayload()


    transformer.transform(source, result);

    } catch (Exception e) {





    Replace the tag 'Details' with the actual field name which will contain the encoded data.

    Download the jar files for import org.apache.commons.codec.binary.Base64; from the below link and use it in the class path

    Codec - Download Apache Commons Codec

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 27, 2013 at 09:05 AM

    Hi Santhoshi,

    Go ahead with Indrajit suggestion. Also, you can check the possibility to make the base64 decoding at adapter module level, developing your own module for this. I agree it will be more complicated but from my point of view it will be more according with PI infrastructure because you do the transformation to XML in the adapter level. Check this link Farooq Farooqui: SAP XI/PI Encode Outgoing Payload using Adapter Module


    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.