cancel
Showing results for 
Search instead for 
Did you mean: 

dynamic filename in mail adapter

Former Member
0 Kudos

Hi,

how can I set the filename of a mail attachment dynamically in a receiver mail adapter (also dynamically configured)?

I had to uncheck the "keep attachment" because of our scenario.

If I check this box I get a .xml file which I can rename with the MessageTransformBean (but not dynamically?) but I get to much files in the mail.

Now I get a .dat file and want to rename it dynamically in e.g. dynamicName.txt.

Can you give me some input how to do that?

Thanks in advance

Dominic

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Dominic !

Have you checked this document:

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/9e6c7911-0d01-0010-1aa3-8e1...

You can also develop your one transformation class for use with the MessageTransformBean and specify it by using the Transform.Class property in the modules tab. That custom transformation class maybe could read a value from the payload (the dynamic attachment filename) and replace the current one (current value of the Transport.ContentDescription).

Regards,

Matias

Former Member
0 Kudos

Hi Matias,

I've chekced the document. The MessageTransformBean seems to work only proper, when the checkbox "Keep Attachment" is enabled. But due to my scenario I can not enable it. I'm getting to much files (all XI-payload files shown in SXMB_MONI). Or is there an opportunity to select the right payload file and discard the others?

regards

Dominic

Former Member
0 Kudos

Hi Dominic !

I think you have to develop your own java transformation class and solve the issues right there (discard the attachment you don't want using the keep attachment option, and assign filename) maybe using some resources of the Michal's weblog.

To use dynamicconfiguration to change the name via UDF, I guess you need to know the dynamic configuration tag name for the receiver, and overwrite this one.

Regards,

Matias.

Answers (3)

Answers (3)

stefan_grube
Active Contributor
0 Kudos

It is not possible to create dynamic attachment names besides writing an adapter module, escpecially when you want to choose the right attachments from many.

Maybe this blog might give you an idea how the adapter module can work (even it describes a Java mapping):

/people/stefan.grube/blog/2007/04/17/xi-mail-adapter-an-approach-for-sending-emails-with-attachment-with-help-of-java-mapping

Regards

Stefan

Former Member
0 Kudos

Hi Dominic,

This might help you...

/people/michal.krawczyk2/blog/2005/03/07/mail-adapter-xi--how-to-implement-dynamic-mail-address

regards,

vasanth

MichalKrawczyk
Active Contributor
0 Kudos

Hi Dominic,

have a look at my blog:

/people/michal.krawczyk2/blog/2006/02/23/xi-dynamic-name-in-the-mail-attachment--pseudo-variable-substitution

it shows how you can do it with adapter module

Regards,

michal

-


<a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

Former Member
0 Kudos

Hi Michal,

good blog, but I don't think it matches my needs.

I want to set the filename of the attachment (.dat-file) dynamically (!!), e.g [sender]_[receiver]_[messageid].txt

As my mail adapter is also dynamically configured, isn't it possible to set the filename of the attachment in the message-mapping?

regards

Dominic

Former Member
0 Kudos

Hi

<i>isn't it possible to set the filename of the attachment in the message-mapping?</i>

--->

Try writing this UDF so to get the name in mapping

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

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

conf.put(key,a); // a - parameter given to UDF that specifies filename

String ourSourceFileName = conf.get(key);

return ourSourceFileName;

Hope this helps

Former Member
0 Kudos

Hi Mugdha,

I tryed it with your code in my UDF (I first tried it with a fix name instead of the "a" in your code) but unfortunately I still get a .dat file with some name att7t7t0.dat.

What did I do wrong?

Regards

Dominic

Former Member
0 Kudos

Hi,

Have u selected Adapter Specific message attributes checkbox in the mail adapter

hope this helps

Former Member
0 Kudos

yes of course.

And I can see the entries in the Dynamic Configuration trace of SXMB_MONI:

<SAP:Record namespace="http://sap.com/xi/XI/System/File" name="FileName">Testfile.txt</SAP:Record>

But the file I get is a .dat file. I can't find this .dat filename in any trace of sxmb_moni. Do you know where it's generated?

Regards

Dominic

Former Member
0 Kudos

Hi all,

I solved the first part of the problem. Now I don't get a something.dat file but a file I named in the modulconfiguration. Thats what I did:

I took the MessageTransformBean with

Transform.ContentDescription - Testfile.edi

Transform.ContentDisposition - attachment;filename="Testfile.edi"

Transform.ContentType - application/edifact;name="Testfile.edi"

Box "Keep Attachment" is unchecked.

But my second problem is, how can I configure this filename dynamically? does it somehow work with the Variable Substitution?

Unfortunately I don know the stepts to develop and use my own adapter module or transformation class. Could anybody provide me some tutorials or similar?

Thanks in advance

Dominic

Former Member
0 Kudos

Hi Dominic !

Great !

You can use this tutorial:

How To…Create Modules for the J2EE Adapter Engine

Link: https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/3bdc14e1-0901-0010-b5a9-a01...

And you can use Michal's weblog that implements the pseudo variable substitution via adaptar module. Conventional Variable substitution is not available in the module tab.

Regards,

Matias.

Former Member
0 Kudos

OK, I'll try it this way. Thanks to all.