Skip to end of metadata
Go to start of metadata

Combining three different aspects of PI in one shot
This web log describes how to combine three different aspects 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 of payload dynamically to ASMA

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

3. Using the variable substitution, set the receiver file name schema 

Step 1: Dynamic Configuration

In message mapping, create a UDF that will store the value of the attribute "order_no" dynamically in the adapter specific message attributes named "FileName" 
Java Code for UDF is below. 

 DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
 DynamicConfigurationKey FileName = 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 in ASMA so we will write its value in a variable "message.interface"

In the receiver CC, under Modules tab, we will call an AF module "AF_Modules/DynamicConfigurationBean" before the "Call SAP Adapter".  
In the module configuration, we will set the following information.

key.0 = write FileName

value.0 = message.interface   


Step 3: Variable Substitution

We have the value in "message.interface" so we will assign it to variable substitution.   

The value of this variable substitution will be used in the receiver 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 name schema rather we are using the variable substitution so make sure that the ASMA is unchecked in your receiver CC.    

Another Simple way

There is a simple way to achieve the above requirement "Set Receiver File Name as Payload Attribute Value" and the way is to write the UDF to store the value dynamically in ASMA. 
UDF code will be as below. 

 String str = "ORDERS" + a +  ".xml"
 DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
 DynamicConfigurationKey FileName = DynamicConfigurationKey.create("http:/"+"/","FileName");
 conf.put(FileName, str);
 return "";
So basically I have just described the possible ways to combine three different aspects of PI (ASMA, AF Module and Variable substitution) in one single shot.


  1. Unknown User (100mplmqb)

    I am trying to do the same thing, however I have an attribute in the Payload of the message which I have pasted below, the value I am trying to extract and put in the variable substitution is the "RR".  How would I use the UDF to read the attribute that is being mapped?  The value is only part of the Target message which is being set through a ValueMapping.

     <ns0:MT_TEST0001 xmlns:ns0=><RECORD FACILITY_CODE="RR">

    The File Name Schema should then be: File%code%.txt

    The actual file should be (after variable substitution): FileRR.txt


  2. In an IDoc2File scenario I have added the IDoc-number to dynamic configuration using the folling code in an UDF

    DynamicConfiguration conf = (DynamicConfiguration)
    DynamicConfigurationKey FileName = DynamicConfigurationKey.create("http:/"+"/","DOCNUM");
    conf.put(FileName, a);

    The information is stored in the SOAP message

    <SAP:DynamicConfiguration SOAP:mustUnderstand="1">
      <SAP:Record namespace="" name="DOCNUM">0000000000012345</SAP:Record>

     How can I access this information in the "variable substitution" section of the CC?

    Thanks in advance