DynamicConfigurationBean in SFTP receiver adapter
Using DynamicConfigurationBean with variable substitution to rename file in receiver SFTP adapter.
Dynamic configuration parameters can be used to modify the filename, path and other parameters on the receiver side. This is generally achieved via UDF / Java mapping. However SAP has provided this functionality through a standard bean. This enables us to do modify these parameters without writing any code.
PI Version : 7.3 dual stack
Our requirement was to transfer file using SFTP adapters from source fileserver to target file system. No mapping required. Additionally, the file also has to be written to an “AUDIT” directory in zip format.
The name of the file in output directory and the name of zip file in AUDIT directory have to be same as source file.
So if the source file name is AB_YYYYMMDD_HHMMSS.txt, then the output file also has to be –
AB_YYYYMMDD_HHMMSS.txt and zip file name in audit directory has to be AB_YYYYMMDD_HHMMSS.zip
For achieving the zip functionality, we used PayloadZipBean.
However the zip file was named as AB_YYYYMMDD_HHMMSS.txt (instead of .zip extension) because ASMA was enabled in receiver adapter.
If we unchecked the ASMA on receiver channel for zip file, then we had to provide a static name in “File name” parameter like “AB.zip” and then use the “Append Timestamp” option. But this did not satisfy our requirement of having zip file name same as source file name.
Also since it was a pass through scenario, we wanted to avoid any kind of graphical / java mapping.
Using OS command option was the last resort, however we wanted to try if we could fulfill this requirement using standard bean.
We were able to achieve our business requirement by using combination of variable substitution and Dynamic configuration bean as below.
- Enable ASMA option in sender file adapter.
- Enable variable substitution in receiver adapter which creates zip file and provide a variable name. In the reference field assign it value of message:interface_name.
- Ensure that ASMA option is disabled in the receiver adapter because, ASMA has higher priority and hence the file will be named as .txt irrespective of all other configurations.
4. Mention the variable used in step 2 in Filename parameter and appends “.zip” as extension.
5. In the module tab, add Dynamic configuration and payload zip bean as shown below.
The write option of dynamic configuration bean, writes the name of source file in the header field – message.interface. This is then substituted in Filename parameter using variable substitution and also since we have “.zip” extension already hardcoded. So we now get a zip file with .zip extension.
Log from communication channel –