Skip to Content

Dynamic name for receiver MAIL attachment file

Hi All,

Many times we have requirements like make the attachment name different received via mail adapter.

So here is the blog to resolve the problem:

First write a UDF for the same:


Taks 2 strings for arguments which you want to add in the name of attachement:

ex :Args1,Args2 :


public String Dynamicfilename(String Args1, String Args2, Container container) throws StreamTransformationException{

String tempstart = “string1”;

   DynamicConfigurationKey parmValue;

String tempend = “.txt”;

String hypen = “-“;

String FileName = “XHeaderName3”;

String Subject =  tempstart +hypen+ VBELN +hypen+ GLN;

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

if (conf != null)


DynamicConfigurationKey keyFilename = DynamicConfigurationKey.create(““,  “XHeaderName1”);

String dynaname = tempstart +hypen+ Args1 +hypen+ Args2+tempend;

String dyn1 = “attachment; filename =” +dynaname;

conf.put(keyFilename, dyn1);

parmValue = DynamicConfigurationKey.create( ““, “THeaderSUBJECT“); 

         conf.put(parmValue,  Subject);

container.setParameter(StreamTransformationConstants.DYNAMIC_CONFIGURATION, conf);


return “”;


after writing the UDF,map the root node of output structure with UDF along with 2 input fields.

now go to receive MAIL adapter communication channel.

and make changes like this;

1. Use ASMP-checked

2.Variable Transport Binding-checked


here  THeaderSUBJECT is the value which we have set in UDF.

Now add these modules and values to the communication channel:


I hope this will help .

References : Adding DynamicConfigurationBean in the Module Processor – SAP NetWeaver Process Integration – SAP Library

Happy Learning 🙂


Pooja Tiwari

You must be Logged on to comment or reply to a post.
  • Pooja-

    Hope all is well. I am trying to rename the XML file and used the configuration you have mentioned. When I try to process am receiving Name not found exception 720. Please let me know if you have any idea to resolve this issue. It looks like the message transformation bean is not available in the PI adapter engine. I have attached a screenshot in which you can see more details related to the error and also review my configuration setup.