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:

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

Be the first to leave a comment
You must be Logged on to comment or reply to a post.