Skip to Content
0

File adapter Sender Attachment xlsx

Dec 23, 2016 at 05:18 PM

63

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Manoj K Dec 23, 2016 at 06:08 PM
1

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

Share
10 |10000 characters needed characters left characters exceeded