cancel
Showing results for 
Search instead for 
Did you mean: 

plain text file as attachment to inbound proxy.

Former Member
0 Kudos

Hi All,

can anyone help me with the below requirement.

My scenario is from sender SFTP to Receiver Proxy. Is there any standard bean that can fulfill this requirement ,as i am not interested in Java code. Can we achieve this with standard module bean in SFTP sender channel.

I have gone through some of the blogs but did not found anything to meet my requirement

Note: No mapping involved in this.I have taken both sender and receiver structures with single Data type.

Appreciate the quick reply.

Thanks,

Gayathri.

Accepted Solutions (0)

Answers (3)

Answers (3)

RaghuVamseedhar
Active Contributor
0 Kudos

Gayathri,

Please use this Java Mapping.


package com.test;

import com.sap.aii.mapping.api.*; 
import java.io.*; 
public class MyJavaMapping extends AbstractTransformation { 
    @Override 
    public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput) throws StreamTransformationException { 
        try { 
            InputStream inputstream = transformationInput.getInputPayload().getInputStream(); 
            OutputStream outputstream = transformationOutput.getOutputPayload().getOutputStream(); 

            //Read input content into byte array.  
            byte[] b = new byte[inputstream.available()]; 
            inputstream.read(b); 

            //Make payload as attachment. 
            Attachment newopAttachment = transformationOutput.getOutputAttachments().create("FileName.txt", b); 
            transformationOutput.getOutputAttachments().setAttachment(newopAttachment); 
             
            //Write Message Type XML to proxy. 
            outputstream.write("<root><xml>XML payload to proxy</xml></root>".getBytes()); 
        } catch (Exception exception) { 
            getTrace().addDebugMessage(exception.getMessage()); 
            throw new StreamTransformationException(exception.toString()); 
        } 
    } 

Former Member
0 Kudos

Hi Raghu,

Thanks for the code. I will work on it and will update you the result.

Thanks,

Gayathri.

iaki_vila
Active Contributor
0 Kudos

Hi Gayathri,

Sometimes it's a good idea to pose a workaround that it can reduce considerably the developing time. Why don't do a SFTP - FTP/NFS scenario where the receiver filesystem was accessible for your ECC?, in this way the scenario is a piece of cake and if the PI is in the DMZ with the ECC to share a filesystem via NFS or FTP it will not be a big risk.

Regards.

Former Member
0 Kudos

Hi Inaki,

FTP is not recommended by my client, they are going only with SFTP. My scenario here is SFTP to  SOAP proxy inbound. And more over they don't want to place the files in Application server( AL11) instead of that they want me to pass the text file as it is to ECC as an attachment.

Thanks,

Gayathri.

Harish
Active Contributor
0 Kudos

Hi Gayathri,

Did you tried the payload swap bean in sender channel?

regards,

Harish

Former Member
0 Kudos

Hi Harish,

No, In my case Vendor will place only one .txt file. Could you please explain me how to achieve this with swap bean.

Thanks,

Gayathri.

engswee
Active Contributor
0 Kudos

Hi Gayathri

PayloadSwapBean will only work if you have at least one attachment in the message. For your case, with just one .txt file, you won't have any attachments.

As it is right now, you cannot achieve your requirement (attachment in message to proxy) with standard functionality. You will need Java coding either in a custom module or mapping.

Regards

Eng Swee

Former Member
0 Kudos

Hi Eng,

Thanks for your reply.

Could you please help me with the java code. This is very urgent requirement. It would be very greatfull if you would send the code.

Thanks,

Gayathri.

anupam_ghosh2
Active Contributor
0 Kudos

Hi Gayathri,

                     Please checck this beautiful blog by  Ashutosh Upadhyay.

He has explained java mapping procedure to add the attachment along with payload.

Let me know in case you have issues in implementing this solution.

Regards

Anupam

Former Member
0 Kudos

Hi Anupam,

In my requirement there is now payload involved it is a simple SFTP to Proxy scenario.

Where I need to pick the text file from SFTP location and has to process the same file to ECC with inbound proxy as an attachment.

I have created one dummy source structure, and Receiver structure with one filed like below.

Please let me know the code and where Do i need to insert the same.

Thanks,

Gayathri.