Skip to Content

Automate to Access Documents from Document Management Repository

Automate to access and retrieve documents from DMS
You will learn
  • How to download a document from DMS
celineaudinsapCéline AudinJanuary 19, 2023
Created by
celineaudinsap
November 20, 2022
Contributors
celineaudinsap
  • Step 1

    Once you have completed the Invoice Processing and Approval Using SAP Build Process Automation mission, your process looks like this:

    Process
    1. Choose the +, then Automation, then + New Automation to add a new Automation to the process.

      Add Automation
    2. In the Create Automation window, fill the fields as follows:

      Name Description
      Download Document DMS Download the document from Document Management Repository
    3. Choose Create.

      Add Automation

      A new automation is added to the process.

    4. Double click on the automation to open the flow.

      Automation
  • Step 2
    1. Under the Automation Details, select Input/Output. Choose Add new input parameter.

      InputOutput
    2. Create three input parameters with the following details:

      Name Type
      uploadedFileName String
      folderName String
      outputFilePath String

      This is the result you should expect:

      InputOutput
    3. Save your work.

  • Step 3
    1. Choose Manage the project properties, then Environment Variables. Finally, select + Create.

      Environment Variable
    2. In the Create an environment variable window, fill the fields as follows:

      Field Name Value
      Identifier DocMgmt
      Type Destination
    3. Choose Close.

      Create Destination
  • Step 4
    1. Select Tools.

    2. Search for the data type String, and drag and drop it into the workflow.

      String Variable
    3. For output parameter set myFilepath, and Open the Expression Editor of the value parameter.

      String Variable Output Param
    4. Copy and paste this expression and choose Save Expression:

      "C:\\Users\\Public\\" + Step0.uploadedFileName
      
      String Variable Value
    5. Select Tools.

    6. Search for the control Try, and drag and drop it into the workflow.

      Try Control
    7. Choose the control and select RequestError as Errors to catch. Choose Save.

      Try Control
    8. Go back to the Automation Details panel.

      To go back to the Automation Details panel, you can either close the step panel or click on the flow canvas.

    9. Search for the Log Message activity. Now drag and drop it into the workflow, below the catch.

      Log Message
    10. Select the Log Message activity.

    11. Open the Expression Editor of the message input parameter and choose Variables>1 error>message.

    12. Choose Save Expression.

      Edit message
    13. For the type input parameter select Error.

    14. Open the Expression Editor of the label input parameter and select Variables>1 error>parameters. Choose Save Expression.

    15. Choose Save.

      Input Parameters
    16. Search for the control Custom script and drag and drop it into the workflow below the Try control.

      Custom Script
    17. Choose the control and select Edit Script.

      Edit Script
    18. Copy and paste this script:

    return {
        url : folderName ? folderName + '/' + uploadedFileName : uploadedFileName,
        method: 'GET',
        resolveBodyOnly: true,
        responseType: 'buffer'
    };
    
    1. Create the following Input Parameters:

      Name Type
      uploadedFileName String
      folderName String
      Input
    2. Create the following Output Parameter:

      Name Type
      options Any
    3. Save your work and close the panel.

      Output
    4. For the Input Parameters, select uploadedFileName and folderName.

      Input
    5. Go back to the Automation Details panel.

      To go back to the Automation Details panel, you can either close the step panel or click on the flow canvas.

    6. Search for the HTTP Request: Call Web Services with Destinations. Drag and drop the request into the workflow, just below the Custom script control. Save your work.

      Call Web Services with Destination

      This activity is used to create and send an HTTP request to call a remote service (API call for instance) represented through a destination.

    7. Under Input Parameters, as destination select E DocMgmt and as options select 2 options.

      The environment variable created in step 3 will be consumed here.

      Input Parameters
    8. Go back to the Automation Details panel.

      To go back to the Automation Details panel, you can either close the step panel or click on the flow canvas.

    9. Search for another Try control. Drag and drop the control into the workflow, just below the Call Web Services with Destinations. Save your work.

      Try
    10. Select the control. Choose Error as the Error to catch. Save your work.

      Try Parameters
    11. Go back to the Automation Details panel.

      To go back to the Automation Details panel, you can either close the step panel or click on the flow canvas.

    12. Search for the Custom Script control. Drag and drop the control into the workflow under the Try-2 control. Save your work.

      Custom Script
    13. Select the control.

    14. Change step name to Convert binary to string. Choose Edit Script.

      Edit Script
    15. Copy and paste the following code:

      return
      Copy
      buffer.toString('binary');
      
    16. Create Input and Output parameters as per screenshot below:

      Custom Script
    17. Save your work.

    18. Under Input Parameters, select 3 obj as buffer. Save your work.

      Custom Script
    19. Click on the canvas to back to the Automation Details.

    20. Search for the file Write File. Drag and drop the file into the workflow, under the custom script.

      Write File
    21. Choose the Write File. Fill in the different Input Parameters as per screenshot below:

      Write File Parameters
    22. Click on the canvas to back to the Automation Details panel.

    23. Search for the Log Message activity. Drag and drop it into the workflow, below the second catch.

      Log Message
    24. Select the Log Message activity. Open the Expression Editor. Choose Variables>4 error>message. Choose Save Expression.

      Edit message
    25. For the type parameter select Error and for the label parameter select 4 error.

      Log Message Input Parameters
    26. Select the End automation node. Set the outputFilePath parameter with myFilepath. Check the Design Console if your automation is free of errors. Save your work.

      Automation Output Parameters

    What parameters are mandatory when using Call Web Service with Destinations activity?

Back to top