Skip to Content

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

Requirement:

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:/”+”/sap.com/xi/XI/System/File”,”FileName”);

conf.put(FileName, a);

return “”;

/wp-content/uploads/2009/05/udf_181876.jpg

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 http://sap.com/xi/XI/System/File FileName

value.0 = message.interface

/wp-content/uploads/2009/05/af_module_181877.jpg

Step 3: VariableSubstitution

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

/wp-content/uploads/2009/05/variable_substitution_181878.jpg

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

/wp-content/uploads/2009/05/filename_181879.jpg

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.

/wp-content/uploads/2009/05/asma_unchecked_181880.jpg

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:/”+”/sap.com/xi/XI/System/File”,”FileName”);

conf.put(FileName, str);

return “”;

/wp-content/uploads/2009/05/asma_unchecked_181880.jpg

To report this post you need to login first.

3 Comments

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

  1. S. Gokhan Topcu
    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?
    (0) 
    1. Madan Mohan Agrawal Post author
      Yes, absolutely true!

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

      Regards,
      Madan Agrawal

      (0) 
  2. Aaron Myers
    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,

    -Aaron

    (0) 

Leave a Reply