cancel
Showing results for 
Search instead for 
Did you mean: 

File adapter Sender Attachment xlsx

brian_briones
Participant
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

manoj_khavatkopp
Active Contributor

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