cancel
Showing results for 
Search instead for 
Did you mean: 

How to set file name from attachment data (payload swap bean)

Former Member
0 Kudos

Hi Experts,

I have a scenario from SOAP proxy to SFTP with attchment. I have used payloadswapbean to consider attachment as main payload.

I can able to successfully send the attachment to Target system. Where as my requirement is,  I need to set file name by using  2 fields of data(Country code and payment type)  from that attachment.

There is no mapping involved in this. Proxy will trigger only sample data(I wont use this data at all) but attachment is the actual content which I will send to client.

As per my knowledge we can use UDF to set dynamic file name, but I don't know how can I apply in my scenario.

Please suggest me on this.

Thanks,

Gayathri.

Accepted Solutions (0)

Answers (2)

Answers (2)

iaki_vila
Active Contributor
0 Kudos

HI Gayathri,

If you don't have ESR development you should try to avoid to create a UDF. Check this thread

If your message payload has the name of the file or you can construct the file name with that information, you can use variable substitution to do it.

Regards.

Former Member
0 Kudos

H Vila,

Thanks for your response.

My requirement is different than your referring thread.

In my case PI will receive main payload and attachment data, using payload swap bean I am sending only the attachment to target using SFTP adapter.

Now my question is, I have to set a file name based on the 2 fields which is present in attachment not from main payload.

I am using PI 7.4 Single stack ICO based scenario.

Thanks,

Gayathri.

iaki_vila
Active Contributor
0 Kudos

Hi Gayathri,

Ok, i misunderstood your scenario. AFAIK you will need to do a mapping to read the attachment (Read attachment content in Mapping | SCN) and to set the filename (Dynamic File Name with PayloadSwapBean | SCN).

Regards

Former Member
0 Kudos

H Vila,

I don't have message mapping here. More over I can able to read the attachment and sent to target directory without any error using payload swap bean.

Now the only thing is I should able to set a file name by using the fields which is present in the attachment.

Thanks,

Gayathri.

sendhil_kumar
Active Participant
0 Kudos

Hi Gayathri,

The file should be parsed in PI, only then the value from the attachment can be read and set for the file name. You would have to introduce mapping to achieve the desired file name.

You can follow threads suggested by Inaki for reading the data from attachment and create file name.

--

Sendhil

Former Member
0 Kudos

Hi All,

Can anyone please respond to this thread.

Thanks,

Gayathri.

former_member182412
Active Contributor
0 Kudos

Hi Gayatri,

Is your attachment text file or xml file??

  • If the attachment if xml file then you can use variable substitution to set the dynamic file name as Inaki already mentioned.
  • If the attachment is text file you cannot use variable substitution to set the dynamic file name. You need to use MessageTransformBean to convert to xml then you need to use variable substitution.

Kind Regards,

Praveen.

Former Member
0 Kudos

Hi Praveen,

Thanks for your quick response.

My source file is of XML type.

Please help with the steps for variable substitution.

Thanks,

Gayathri.

Former Member
0 Kudos

Hi Gayathri,

Please refer to the below thread to achive the file name with variable substitution method.

http://scn.sap.com/community/pi-and-soa-middleware/blog/2013/04/16/variable-substitution-for-directo...

Regards,

Santhi

former_member182412
Active Contributor
0 Kudos

Hi Gayatri,

If the xml look like below:


<?xml version="1.0" encoding="UTF-8"?>

<ns0:PaymentMessage xmlns:ns0="urn:gp:prototype">

   <Payment>

      <PaymentType>PT</PaymentType>

      <CountryCode>US</CountryCode>

   </Payment>

</ns0:PaymentMessage>

Kind Regards,

Praveen.

Former Member
0 Kudos

Hi Praveen,

Thanks for your answer.

It is perfect example. I am not sure about the Source file structure yet, but as per your answer I can achieve  my requirement.

Thanks,

Gayathri.

Former Member
0 Kudos

Hi Praveen,

I have followed your steps and got the below error. Please help me with this.

I have used the data which you have sent as source data.

former_member182412
Active Contributor
0 Kudos

Hi Gayathri,

My payloads look like below:

Module Configuration:

Variable Substitution:

File Name:

Output:

Former Member
0 Kudos

Hi Praveen,

Are you using SFTP as Receiver Adapter or File?

How you got the attachment name as Payment file, Do we need to get this file name from Proxy or do i need to maintain as swap key value in Payloadswapbean module parameter..

I am getting the source payload and attachment through proxy. That is the reason I got BOFA_Attachment from ECC. It is defined in Proxy code and maintained the same in PI.

Thanks,

Gayathri.

former_member182412
Active Contributor
0 Kudos

Hi Gayathri,

  • File or SFTP variable substitution works same
  • I took arbitrary name as PaymentFile, you can use BOFA_Attachment

Regards,

Praveen.

Former Member
0 Kudos

Hi Praveen,

Please find the below screenshots.Still I am facing the error I don't know where I went wrong.