Skip to Content
avatar image
Former Member

File adapter Sender Attachment xlsx

Hi Friends,

I have the next integration FTP--> PI-->PROXY SAP

I need Attachment file xlsx from ftp to PROXY.

How I must do this integration on File Sender CC for attachment the xlsx file ?

Help Me Friends.

Regards

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Dec 23, 2016 at 06:08 PM

    Brians,

    The xlsx file can be picked as an attachment only if u mention it under "Additional File" section , so you need two files one the main payload which is picked and another xlsx.

    In Case if u have just xlsx file alone then pick the file as a mainpayload then in mapping use java mapping to make the incoming mainpayload as attachment to outgoing payload.

    A bit of code is as below.

    try{
        
          GlobalContainer globalContainer = container.getGlobalContainer();
          MappingTrace trace=container.getTrace();
          byte[]convertedInput=input.getBytes("UTF-8");
          OutputAttachments outputAttachments = globalContainer.getOutputAttachments();
          Attachment outputAttachment;
          String contentType="application/xml";//<could be changed>
          DynamicConfiguration conf = ( (DynamicConfiguration)container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key =DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
          String fileName = (conf.get(key));
          trace.addInfo("filename used for attachment "+ fileName);
          outputAttachment = outputAttachments.create(fileName,contentType,convertedInput);
          outputAttachments.setAttachment(outputAttachment);
    }
    catch(UnsupportedEncodingException e) {
    e.printStackTrace();
    throw new StreamTransformationException(e.getMessage());
    }
          return "";
    

    Br,

    Manoj

    Add comment
    10|10000 characters needed characters exceeded