Automate to Access Documents from Document Management Repository
- How to download a document from DMS
Prerequisites
- Complete Invoice Processing and Approval Using SAP Build Process Automation mission
- Configure Document Management Repository
- Step 1
Once you have completed the Invoice Processing and Approval Using SAP Build Process Automation mission, your process looks like this:
-
Choose the +, then Automation, then + New Automation to add a new Automation to the process.
-
In the Create Automation window, fill the fields as follows:
Name Description Download Document DMS Download the document from Document Management Repository -
Choose Create.
A new automation is added to the process.
-
Double click on the automation to open the flow.
-
- Step 2
Under the Automation Details, select Input/Output. Choose Add new input parameter.
Create three input parameters with the following details:
Name Type uploadedFileName
String folderName
String outputFilePath
String This is the result you should expect:
Save your work.
- Step 3
Choose Manage the project properties, then Environment Variables. Finally, select + Create.
In the Create an environment variable window, fill the fields as follows:
Field Name Value Identifier DocMgmt
Type Destination
Choose Close.
- Step 4
Select Tools.
Search for the data type String, and drag and drop it into the workflow.
For output parameter set
myFilepath
, and Open the Expression Editor of the value parameter.Copy and paste this expression and choose Save Expression:
"C:\\Users\\Public\\" + Step0.uploadedFileName
Select Tools.
Search for the control Try, and drag and drop it into the workflow.
Choose the control and select
RequestError
as Errors to catch. Choose Save.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.
Search for the Log Message activity. Now drag and drop it into the workflow, below the catch.
Select the Log Message activity.
Open the Expression Editor of the message input parameter and choose Variables>1 error>message.
Choose Save Expression.
For the type input parameter select Error.
Open the Expression Editor of the label input parameter and select Variables>1 error>parameters. Choose Save Expression.
Choose Save.
Search for the control Custom script and drag and drop it into the workflow below the Try control.
Choose the control and select Edit Script.
Copy and paste this script:
return { url : folderName ? folderName + '/' + uploadedFileName : uploadedFileName, method: 'GET', resolveBodyOnly: true, responseType: 'buffer' };
Create the following Input Parameters:
Name Type uploadedFileName
String folderName
String Create the following Output Parameter:
Name Type options Any Save your work and close the panel.
For the Input Parameters, select
uploadedFileName
andfolderName
.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.
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.
This activity is used to create and send an HTTP request to call a remote service (API call for instance) represented through a destination.
Under Input Parameters, as destination select
E DocMgmt
and as options select2 options
.The environment variable created in step 3 will be consumed here.
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.
Search for another Try control. Drag and drop the control into the workflow, just below the Call Web Services with Destinations. Save your work.
Select the control. Choose Error as the Error to catch. Save your work.
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.
Search for the Custom Script control. Drag and drop the control into the workflow under the Try-2 control. Save your work.
Select the control.
Change step name to Convert binary to string. Choose Edit Script.
Copy and paste the following code:
returnCopybuffer.toString('binary');
Create Input and Output parameters as per screenshot below:
Save your work.
Under Input Parameters, select
3 obj
as buffer. Save your work.Click on the canvas to back to the Automation Details.
Search for the file Write File. Drag and drop the file into the workflow, under the custom script.
Choose the Write File. Fill in the different Input Parameters as per screenshot below:
Click on the canvas to back to the Automation Details panel.
Search for the Log Message activity. Drag and drop it into the workflow, below the second catch.
Select the Log Message activity. Open the Expression Editor. Choose Variables>4 error>message. Choose Save Expression.
For the type parameter select Error and for the label parameter select 4 error.
Select the End automation node. Set the
outputFilePath
parameter withmyFilepath
. Check the Design Console if your automation is free of errors. Save your work.
What parameters are mandatory when using Call Web Service with Destinations activity?