As many of you already know, Variable Substitution, allows you to dynamically set the target file name scheme or target directory location by substituting a variable placeholder with a value from the XI message payload or XI message header. But still, I am posting this document as I faced an issue saying Variable data source exception in variable substitution and after making a slight change I got the solution for the problem. I hope it may help those who are new to SAP PI.
The steps to be taken care while applying variable substitution using message payload are as below:
Note that all the steps for any particular scenario will remain same except the changes to be followed while making the Receiver Communication Channel.
Lets take for an example that you need your output file to be with the name xslt_<dynamic_value_from_the_payload>.xml
In Integration Directory, while configuring the Receiver Communication Channel
1. Give the file name schema as xslt_%var1%.xml wherein var1 is the dynamic value taken from the receiver payload message. Note that var1 must be encapsulated between %%.
2. Now tick the check-box of the Variable substitution in the Advanced section provided in the Receiver Communication Channel to enable variable substitution. Then insert a row to define Variable name and its reference as under.
The variable reference that I am giving is of the receiver payload and not the sender payload. For this I am attaching both of my payloads as under:
The parser searches for the first occurrence of MT_IB_XSLT_F2F of the root element at the first level. It then searches for the first occurrence of Emp_Records at the second level after which for the first occurrence of Personal at the third level and at last for the first of ESN_No at the forth level.
Thats it! You get the output file as below.
I know that there is nothing new but still it will help the freshers like me for sure.
Thanks & Regards,