Skip to Content
Author's profile photo Bogdan Toma

Working with FTP folders in SAP Sourcing 9.x

One of the recurring inquiries in SAP Sourcing has been the use of FTP within scripts. While this might be a simple task in Java, the biggest problem is that Sourcing 9.x doesn’t use the all-too-familiar Apache Commons FTPClient.

In this blog post I will explain how to make use of the internal functions available in SAP Sourcing 9.x to facilitate working with FTP folders.

**WARNING**– this blog post will make use of Internal APIs. Even if I have tested and confirmed them working in 9.x versions, great care should be taken while implementing and supporting these APIs.

  • Prerequisites:
    • Check and confirm that your FTP integration System Properties are defined and access is granted to respective directory.

Screen Shot 2015-06-02 at 12.13.04 AM.png

The fun part: scripting

  • Import some classes

import java.util.*;

  • Define your FTP Server

String FTP_SERVER = "";
String FTP_USER = "MyFtpUsername";
String FTP_PASSWORD = "MyFtpPassword";
String FTP_OUTBOUND_DIRECTORY = "my/outbound/directory";

  • Prepare your file
    • Let’s assume you have an AttachmentIfc you want to push to FTP location

File exportFile = attachmentIfc.getFileData(session);

String xmlString = "sample XML text";
tempDirectory = IntegrationConfig.getEnterpriseProperty(session, "ftp.temp_dir");
File exportFile = new File(tempDirectory + File.separator + "my_file.xml");
writer = new OutputStreamWriter(new FileOutputStream(exportFile), "UTF-8");

  • Finally, write your File to FTP

SapIntUtil.instance().ftpFile(session, exportFile.getParent(), FTP_OUTBOUND_DIRECTORY, FTP_SERVER, FTP_USER, FTP_PASSWORD, exportFile.getName());

**PS** For SAP Sourcing 10.x a different post will follow because the changes introduced allow for a better implementation with the use of File Transfer Configuration

Bogdan Toma

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Kushagra Agrawal
      Kushagra Agrawal

      Thanks Bogdan! Its quite helpful.


      Kushagra A

      Author's profile photo Former Member
      Former Member

      Hi Bogdan Toma ,

      We have SAP Sourcing 9. Is there a way we can create directories on ftpServer through scripting using internal APIs. We want to push our Contract Documents to FTP server and to be able to distinguish between documents of different MAs we need to create a directory at run time and then push the documents to the newly created directory.





      Author's profile photo Mahesh Damodar
      Mahesh Damodar

      Hi Guys ,


      Can you please look into the issue and help me?