Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
Showing results for 
Search instead for 
Did you mean: 


SAP Process Automation (SAP PA) is a powerful tool that allows organizations to automate their business processes, increase efficiency, and reduce manual effort. One common task in SAP PA is downloading files from the SAP system or the Web. While seemingly straightforward, there are certain best practices and considerations to keep in mind to ensure a smooth and effective file download process. In this blog, we will explore the right way to download a file in SAP Process Automation.

The file that we will be downloading is saved within the SAP BTP Document Management Service.

How to Download a File


Step 1: Create a variable to hold the name of the folder where your file resides in DMS, Leave it empty if the file is in the root folder.

Step 2: Create a variable to hold the name of the file you want to download.

Step 3: Create a variable to hold the ClientID.

Step 4: Create a variable to hold the ClientSecret

Step 5: Use the Encode String Activity to encode the ClientID and ClientSecret in base64 format.

Step 6: To access the DMS (Document Management Service) system and download the file, it is necessary to acquire authorization. In this stage, we will utilize the Customer Script Activity to set up configurations for calling the Auth Service, enabling us to obtain the necessary authorization.

var authRequestOptions = {
    method: 'GET',
    responseType: 'json',
    headers: {
        'Accept': 'application/json',
        'Authorization': 'Basic '+ base64EncodedUsernamePassword,
        'Content-Type': 'application/json'
    'resolveBodyOnly': true

return authRequestOptions;

Step 7: Now we’ll call the Auth Service using the Call Web Service with Destination Activity which will provide us with an authentication token.

Step 8: In this step, we’ll again use Customer Script Activity to set up configurations to Download the File.

var requestParams = {
    url: folderName ? folderName + '/' + uploadedFileName : uploadedFileName,
    method: 'GET',
    headers: {
        'Authorization': 'Bearer ' +authToken,
    resolveBodyOnly: true,
    responseType: 'buffer'

return requestParams;

Step 9: Finally, we will employ the Download File Activity to carry out the actual downloading of the file from the DMS (Document Management Service). Subsequently, we will save the downloaded file in our system.


Downloading files using SAP Process Automation (SPA) can be a straightforward and efficient process if you follow the right steps. By understanding the download requirements, utilizing the appropriate SPA activities, and ensuring proper authentication and authorization, you can achieve successful file downloads with ease.