Skip to Content
Author's profile photo POOJA TIWARI

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:

d1.JPG

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(“http://sap.com/xi/XI/System/Mail“,  “XHeaderName1”);

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

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

conf.put(keyFilename, dyn1);

parmValue = DynamicConfigurationKey.create( “http://sap.com/xi/XI/System/Mail“, “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

d2.JPG

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

Now add these modules and values to the communication channel:

d3.JPG

I hope this will help .

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

Happy Learning 🙂

Thanks,

Pooja Tiwari

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Vidhya Nizamkar
      Vidhya Nizamkar

      Attachment name is still the same "MainDocument.xml"

      Can you tell me if the screenshot for parameters is complete or something is missing?

      Author's profile photo POOJA TIWARI
      POOJA TIWARI
      Blog Post Author

      Hello,

      everything is complete.

      Please check if you are missing something during configuration.

       

      Thanks,

      Pooja

      Author's profile photo Hari Sonnenahalli
      Hari Sonnenahalli

      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.

      Regards

      HS