Lets look at how to configure Variable Substitutions at receiver File adapter. Variables or data elements from xml payload can be assigned to file name at PI/PO runtime using this method.
Receiver file channel has capabilities of defining the file directory and the file name of the output file. Variable substitution method is a great way to define dynamic file names if you want to add message payload information to the file name. Simply define variables and assign them values dynamically from either message header or the payload. Header attributes such as message ID, interface names, sender, receiver etc or application data under message payload could be substituted to the file name using variables.
Assume a scenario where, you have a Purchase Order outbound file interface and file name of the output file should contain Purchase Order number. In this case <poNumber> field in the receiver payload can be assigned to the file name in the format <po number>_Date-Time.XML.
Variable Substitution Configuration Steps.
Step 1 – Find the Variable in the Target Message Type.
First find the element in the target structure which you need to assign to the file name. In this example lets use <poNumber> field under <orderDetail>.
Step 2 – Activate Variable Substitution in Receiver Communication Channel.
Activate variable substitution and Define a variable for the data element in the receiver file communication channel under ‘Advanced’ tab.
Here I have defined a new variable named ‘order_number’. In the ‘Reference’ field add the data element and the correct occurrence of the element.
1, 1, 1 are the occurrence of the data element in the payload. Variable is set from the first occurrence of the poNumber tag of the first occurrence of the orderDetail tag in first order tag.
Step 3 – Configure Dynamic Filename at Receiver Channel.
Assign the variable created in Step 2 to the file name.
Test results of Variable Substitution
PO number of the first occurrence is assigned to the file name.
For information on other methods of creating a dynamic file name at the receiver channel, check out my dynamic file name overview post.