cancel
Showing results for 
Search instead for 
Did you mean: 

Proxy with attachments to File scenario

Former Member
0 Kudos

Hi,

We have a proxy to file scenario. The data is coming from ECC and we have to send it to a target system via SFTP adapter. An attachment will be sent through the ABAP proxy which will contain flat files. So our goal is to somehow send the attachments to the target system and drop it to their SFTP server. I know about the payloadswapbean which can be used in the email adapter. My question is can it be used in the file adapter as well ?

Also, in my scenario should the payloadswapbean reside on the target side i.e on the file adapter ? or on the proxy side ? If it's on the proxy side how do I achieve this - as there is no communication channel for a proxy ?

Any thoughts/ suggestions?

Thanks.

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member181985
Active Contributor
0 Kudos

Hi,

Yes you are in right direction, use payloadswapbean in receiver SFTP file channel with correct entries to swap the payload with attachment.

Regards,

Praveen Gujjeti

Former Member
0 Kudos

Hi Praveen,

The payload swapbean worked fine in the receiver sftp channel. How do I retain the filename though ?

ASMA would not work in this case as the file name it's not a sender file adapter on the source side.

Any thoughts/ suggestions ?

Thanks.

former_member181985
Active Contributor
0 Kudos

Hi Venakta,

Read attachment name via mapping and set FileName via same mapping using Dynamic Configuration code.

Sample code to attachment name

String attachmentID = null;

AbstractTrace trace;

//gets the input attachment from the source message

GlobalContainer globalContainer = container.getGlobalContainer();

InputAttachments inputAttachments = globalContainer.getInputAttachments();

trace = container.getTrace();

ry

{

          //checks for the availability of attachments in the input message

          if(inputAttachments.areAttachmentsAvailable())

          {

                    trace.addInfo("Attachments Available");

                    //gets the attachmentIds and store it in an Object array

                    Collection<String> CollectionIDs = inputAttachments.getAllContentIds(true);

                    Object[] arrayObj = CollectionIDs.toArray();

                     //Loops at the input attachments to get the content of the attachment

                    for(int i =0;i<arrayObj.length;i++)

                    {

                              attachmentID =(String)arrayObj[i];

                              trace.addInfo((i+1) + ") Attachment Name: " + attachmentID);

                    }

          }

}

catch (Exception e)

{

          e.printStackTrace();

}

//Use above attachmentID value to set File Name using Dynamic configuration code

return           "";

Regards,
Praveen Gujjeti

Former Member
0 Kudos

Hi Praveen,

It's not picking the attachment name from the above code. I am getting the value as null.

Does ContentID contain the filename ?? Below is the code that I tried. I have assigned the output of the UDF to the root of the target message, just like we do for regular Dynamic config scenario and checked the ASMA flag in the receiver file channel. I have also tried %FileName% in the filename schema, although that shouldn't matter. Any suggestions ???

String attachmentID = null;

AbstractTrace trace;

//gets the input attachment from the source message

GlobalContainer globalContainer = container.getGlobalContainer();

InputAttachments inputAttachments = globalContainer.getInputAttachments();

trace = container.getTrace();

try

{

          //checks for the availability of attachments in the input message

          if(inputAttachments.areAttachmentsAvailable())

          {

                    trace.addInfo("Attachments Available");

                    //gets the attachmentIds and store it in an Object array

                    Collection<String> CollectionIDs = inputAttachments.getAllContentIds(true);

                    Object[] arrayObj = CollectionIDs.toArray();

                     //Loops at the input attachments to get the content of the attachment

                    for(int i =0;i<arrayObj.length;i++)

                    {

                              attachmentID =(String)arrayObj[i];

                              trace.addInfo((i+1) + ") Attachment Name: " + attachmentID);

                    }

          }

}

catch (Exception e)

{

          e.printStackTrace();

}

//Use above attachmentID value to set File Name using Dynamic configuration code

DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create( "http:/"+"/sap.com/xi/XI/System/File","FileName");

String newfile= attachmentID+".csv";

conf.put(key,newfile);

return newfile;

former_member181985
Active Contributor
0 Kudos

Hi Venkata,

Have you enabled "read attachements" check box in interface/operation mapping level.

Regards,

Praveen Gujjeti

Former Member
0 Kudos

Yes, that seems the issues. Thanks a lot

However, the file name that I am getting is

cid:payload-d9dd4b7417db11e390bd0000122886db@sap.com

The contentID doesn't seem to reflect the filename.  Is there any other method in the API that we can use to get the file name ?

Thanks a lot for your assistance.

former_member181985
Active Contributor
0 Kudos

It seems there is a bug in your PI version, may be it is returning main payload name as well an attachment. What is your PI version.

Hence, check message trace in MONI with "Attachment Name:" and see how many attachments

Regards,

Praveen Gujjeti

Former Member
0 Kudos

Hi Praveen,

We are on PI 7.11. I'll check the trace.

Thanks

0 Kudos

Hi ,

I have an issue while sending a pdf file from proxy to sftp. To read the file attachment i have manintained a proxy structure with filename as field and i have used UDF to read the file name. The SFTP server needs only PDF file but when ever the ECC trigger a message the SFTP server is receiving both PDF and XML structure which i have mainted to read the filename in PI.

former_member181985
Active Contributor
0 Kudos

Hi,

Please follow Praveen Kumar's reply in your thread

//BR,

Praveen Gujjeti