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.
Isuru Fernando
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!
Encode Message Payload to Base64 on CPI!
How to use Base64 message encoder in SAP Integration Suite.
It is not possible to use a condition in Variable Substitution. The best way is to go with ASMA. Retrieve the right BELNR based on QUALF in message mapping and set the filename dynamically using UDF. In the Receiver channel enable ASMA parameters to generate dynamic filename.
Thank you Jayaraj, I also agree that in complex scenarios such as this mentioned by Prem, UDF is the better option compared to variable substitution.
Cheers!
Isuru
We use cookies to optimize our website and our service.
Functional
Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Really Very Nice Blog
Thank you Srilakshmi!
Hi Isuru,
Nice blog. I have a scenario where i need to use idoc BELNR in my filename.
But as you know, we have many BELNRs in the idoc and we need to use a particular QUALF to extract right BELNR.
Is it possible to use QUALF check in Variable Substitution like below?
payload:SI_DUMMY,1,INVOIC02,1,IDOC,1,E1EDK02,1,BELNR[QUALF=002],1 ?
Hi Prem,
Very good question but I have not tried complex arguments such as this in variable substitution. Anyone else can help here? 🙂
Cheers!
Isuru
Hi,
It is not possible to use a condition in Variable Substitution. The best way is to go with ASMA. Retrieve the right BELNR based on QUALF in message mapping and set the filename dynamically using UDF. In the Receiver channel enable ASMA parameters to generate dynamic filename.
Regards,
Jay
Thank you Jayaraj, I also agree that in complex scenarios such as this mentioned by Prem, UDF is the better option compared to variable substitution.
Cheers!
Isuru
Really this blog helped a loy.
Thank You
That is great to hear Sunit! Thank you 🙂
Hi ,
Variable substitution works when we use FCC conversion through modules.?
Thanks
Mohan