Skip Navigation Links
xFDN Home
Contributions

Automate uploading EDI files to FTP site

Author: Kalpana Kamatchi, Software Labs Inc.

Many times, business partners (vendors) exchange important data files via FTP. We all know that xFusion can generate data files in different formats such as text and Excel. However, xFusion can also automate uploading these generated data files to a FTP site. All that you need are proper credentials (username, password, etc.) to connect to the FTP site.

In this article, I will show you how xFusion can be used to extract relevant data from SAP Business One, export it to an excel file, and upload this file to a FTP site.

Step 1: Create connection to SAP Business One

For fetching data, the easiest way of connecting to SAP Business One database is to use a SQL server connection.

Step 2: Extract the data from SBO



Step 3: Export the data to an excel file


Step 4: Create an Integration function to upload the excel file to the ftp site



Here is a brief decription of the code. Function theEngine.Export runs the specified export template from within the integration function. The next couple of lines obtain the complete path of the generated Excel file. The next few variables define connection details such as FTP Server, username and password. A standard .NET class, FTPWebRequest, is used to establish connection to the FTP site. The network credentials are set on the FTP webRequest object. We then read the Excel file as binary data and write the contents to the connection's output stream.

The complete data flow is shown here:

Click here to download the sample fusion pack. After downloading the xFusion pack, just edit the SBO connection and make sure that it points to your database. Modify the query and the export template according to your requirements. Edit the Integration function and change the FTP login details. Now you can run the integration function at any time to upload the file to the FTP site. If you are using xFusion Automator, you can also automate the process such that data can be transferred, for example, once a night.

©2010 Software Labs, Inc.