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.
Hi, I am Isuru Fernando, Senior SAP Integration Consultant with 10 years of SAP full-cycle implementation and support project experience.
From the early days, I had a passion for coding, software development, and everything tech-related. I started my carrier as an ABAP developer and soon found my love for system integration when I learned SAP XI 3.0 in 2008. Playing a variety of roles from an offshore technical consultant (ABAP, PI/PO, BW, BOBJ) at the beginning of my career to a technical lead managing a team of consultants in different countries, I have gained immense experience in SAP project implementation life cycle.
Having the opportunity to work on SAP implementation projects in USA, EU, and Asia, I learned valuable ins and outs of global business processors in Sales and Distribution (SD), Material Management, Retail, Customer Relationship Management (CRM), and Finance and Controlling (FICO).
Through this blog, I want to share my expertise in SAP technical areas such as SAP ABAP, PI/PO, AIF, and Basis. I also want to provide a platform for others with similar ambitions who would like to share their SAP technical expertise with the world!