Skip to Content

Combining three different aspects of PI (ASMA, AF Module and variable substitution) in one shot

This web log describes how to combine three differentaspects of PI (ASMA, AF Module and variable substitution) in one shot.


Set Receiver File Name as Payload Attribute Value:

Receiver file name should be “ORDERS<order_no>.xml”where <order_no> will be having the value of an attribute named”order_no” from Payload.

Brief Solution:

1. Using dynamic configuration, set the attribute value ofpayload dynamically to ASMA

2. Using AF module, write the value of ASMA in a variable

3. Using the variable substitution, set the receiver filename schema

Step 1: Dynamic Configuration

In message mapping, create a UDF that will store the valueof the attribute “order_no” dynamically in the adapter specific messageattributes named “FileName”

Java Code for UDF is below.

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

DynamicConfigurationKeyFileName = DynamicConfigurationKey.create(“http:/”+”/”,”FileName”);

conf.put(FileName, a);

return “”;


Step 2: AF Modules

Now as we have set the value of an attribute from payload inASMA so we will write its value in a variable “message.interface”

In the receiver CC, under Modules tab, we will call an AFmodule “AF_Modules/DynamicConfigurationBean” before the “Call SAP Adapter”.

In the module configuration, we will set the followinginformation.

key.0 = write FileName

value.0 = message.interface


Step 3: VariableSubstitution

We have the value in “message.interface” so we will assignit to variable substitution.


The value of this variable substitution will be used in thereceiver file name schema.

Receiver File Name Schema = <Fixed text> + % +<variable name> + %.xml

For example: ORDERS%order_no%.xml


Since we are not going to use ASMA in our receiver File nameschema rather we are using the variable substitution so make sure that the ASMAis unchecked in your receiver CC.


Another Simple way

There is a simple way to achieve the above requirement “SetReceiver File Name as Payload Attribute Value” and the way is to write the UDFto store the value dynamically in ASMA.

UDF code will be as below.

String str = “ORDERS”+ a +  “.xml”

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

DynamicConfigurationKeyFileName = DynamicConfigurationKey.create(“http:/”+”/”,”FileName”);

conf.put(FileName, str);

return “”;


You must be Logged on to comment or reply to a post.
  • Thanks for putting all the distributed info in one place. Sometimes, PI has way too many options to achieve one specific goal, don’t you think?
    • Yes, absolutely true!

      PI is vast like an ocean and its every waves are interlinked we just have to make a connection between them.

      Madan Agrawal

  • Hi Madan, thanks for the blog post, this is exactly what I’m trying to do!

    I think I’m almost there, but a little confused on how th variable names are linked. I get the error “Message processing failed… Variable ‘filename’ not found in variable substitution table”

    In your example I don’t see the link from order_no, FileName, message.interface, and message:interface_name

    How is the FileName parameter in the UDF getting passed into the final Variable Substitution field?

    Thank you,


    • Hi Aaron,


      The error you are getting : “Message processing failed… Variable ‘filename’ not found in variable substitution table” is because of the variable name you have mentioned is in Upper Case. Change it to lower case and it will work

  • I think the very last screenshot is not correct. Shouldn’t it show Variable Substitution disabled and ASMA enabled?


    Kudos though for the blog. Cheers