How to upload files to DMS using SAP Build Apps and use them in SAP Build Process Automation:Part2

Estimated read time 9 min read

*This article is a continuation of Part 1.

2. Creating SAP Build Apps side

First, set two variables as Application Variables.

FolderId and FolderName. Create these two in text type. There is no problem with using Page Variable instead of Application Variable, so please use the appropriate one according to the actual purpose.

SAP Build Apps has prepared a simple screen like this.

 

There are only two buttons. You can probably guess what the button does from the contents of its label, but let’s create the logic for each button.

Before that, let’s install the new features of SAP Build Apps explained in Part 1.
Go to MARKET PLACE and search for “HTTP destination”

Install the module called “HTTP destination request”. Follow the same steps to also search for “Pick Files” and install the “Pick Files” component as well.

3.Creating the logic for the Upload File button

Now let’s create the logic for the Upload File button.
As explained in Part 1, in order to use files uploaded to DMS with SAP Build Process Automation, it is necessary to create a folder and upload the files there. So this button

Select files to uploadCreate a folder in DMS (& get folder ID)Upload the file to the folder created in above

We will write the logic. The entire logic is below.

It would be too long to explain everything, so I will only explain the parts that I think are important.

1. Let the Pick Files control select files.
Here, please change “Pick multiple files?” in OPTIONAL INPUTS to False so that only one file can be selected.

2. Create(Generate) a folder name on DMS and set it to variable: FolderName.

For Assigned value, use Formula and set it as follows this time.

Make the folder name the timestamp value with the preposition “FromBuildApps-“. I think this will probably be unique.

3. Create a folder on DMS using an HTTP destination request.
Create a folder on the DMS using an HTTP destination request.

For Destination, specify “sap_process_automation_document_store_ForApps” created in Part 1, for HTTP Method, specify POST, and for Request body type, specify multipart/form-data.
Specify the Request body using “List of values” as shown in the table below. If there is no cautionary note, set it as Static Text.

keyvaluecmisactioncreateFolderpropertyId[0]cmis:namepropertyValue[0]Select application variables : FolderNamepropertyId[1]cmis:objectTypeIdpropertyValue[1]cmis:foldersuccincttrue

4.Obtain the FolderId value from the return value of the folder creation API.
If the folder is created on DMS in Step 3 (if successful), the following value will be returned from the API.

 

 

{
“succinctProperties”:
{
“cmis:objectId”: “fWtCFDH4ah2BGeFqzoorOLETNNq65cmp82KfYUSpWxA”,
“sap:parentIds”: [“5daf1b700094ead661934376”],
“cmis:name”: “FromBuildApps-1737086879955”,
“cmis:lastModifiedBy”: “sb-ab7437c3-137b-4c58-ac6f-a0fe26232136!b141614|sdm-di-sdm_di_prod-prod!b41064”,
“cmis:objectTypeId”: “cmis:folder”,
“cmis:lastModificationDate”: 1737086882353,
“cmis:createdBy”: “sb-ab7437c3-137b-4c58-ac6f-a0fe26232136!b141614|sdm-di-sdm_di_prod-prod!b41064”,
“cmis:baseTypeId”: “cmis:folder”,
“cmis:parentId”: “5daf1b700094ead661934376”,
“sap:owner”: “sb-ab7437c3-137b-4c58-ac6f-a0fe26232136!b141614|sdm-di-sdm_di_prod-prod!b41064”,
“cmis:creationDate”: 1737086882353,
“cmis:changeToken”: “0”,
},
“exactACL”: false,
}

 

 

The ObjectId of the folder that must be sent to the SAP Build Process Automation process is the value of “cmis:objectId”. Assign this value to the variable FolderId.
This uses Formula,

 

STRING(<Output of HTTP destination request to create folder>.resBodyParsed.succinctProperties[“cmis:objectId”])

 

You can obtain it by specifying . “<Output of HTTP destination request to create folder>.resBodyParsed” is correct if you select it from output of another node in Variables displayed on the left.

5. Upload files to DMS
Similar to Step 3, this uses the HTTP destination request to operate the DMS file upload API.
For Destination, specify “sap_process_automation_document_store_ForApps” created in Part 1, for HTTP Method, specify “POST”, and for Request body type, specify “multipart/form-data”.

Specify the Request body using “List of values” as shown in the table below. If there is no cautionary note, set it as Static Text.

keyvaluecmisactioncreateDocumentpropertyId[0]cmis:namepropertyValue[0]

Use Formula:
Specify files[0].name of PickFiles – which created step1.

propertyId[1]cmis:objectTypeIdpropertyValue[1]cmis:documentfilenamesame as PropertyValue[0]_charset_UTF-8includeAllowableActionstruesuccinctfalsemediaUse Formula:
Specify files[0] of PickFiles – which created step1.

An important point to note is that in DMS, when uploading files to a folder, you must specify the path. This is a form in which the path name (folder name) is included in the API endpoint. Therefore, open the OPTIONAL INPUTS of the HTTP destination request and use the formula for Path to use the folder name added in the form “/”+appVars.FolderName.

OK, It will be able to upload to DMS.

The logic for the File Upload button is now complete. Next, we will develop the logic for the Execute Workflow button that will link to the SAP Build Process Automation process with the information of this uploaded file.

This is getting too long, so I’ll continue with Part 3.

 

​ *This article is a continuation of Part 1.2. Creating SAP Build Apps sideFirst, set two variables as Application Variables.FolderId and FolderName. Create these two in text type. There is no problem with using Page Variable instead of Application Variable, so please use the appropriate one according to the actual purpose.SAP Build Apps has prepared a simple screen like this. There are only two buttons. You can probably guess what the button does from the contents of its label, but let’s create the logic for each button.Before that, let’s install the new features of SAP Build Apps explained in Part 1.Go to MARKET PLACE and search for “HTTP destination”Install the module called “HTTP destination request”. Follow the same steps to also search for “Pick Files” and install the “Pick Files” component as well.3.Creating the logic for the Upload File buttonNow let’s create the logic for the Upload File button.As explained in Part 1, in order to use files uploaded to DMS with SAP Build Process Automation, it is necessary to create a folder and upload the files there. So this buttonSelect files to uploadCreate a folder in DMS (& get folder ID)Upload the file to the folder created in aboveWe will write the logic. The entire logic is below.It would be too long to explain everything, so I will only explain the parts that I think are important.1. Let the Pick Files control select files.Here, please change “Pick multiple files?” in OPTIONAL INPUTS to False so that only one file can be selected.2. Create(Generate) a folder name on DMS and set it to variable: FolderName.For Assigned value, use Formula and set it as follows this time.Make the folder name the timestamp value with the preposition “FromBuildApps-“. I think this will probably be unique.3. Create a folder on DMS using an HTTP destination request.Create a folder on the DMS using an HTTP destination request.For Destination, specify “sap_process_automation_document_store_ForApps” created in Part 1, for HTTP Method, specify POST, and for Request body type, specify multipart/form-data.Specify the Request body using “List of values” as shown in the table below. If there is no cautionary note, set it as Static Text.keyvaluecmisactioncreateFolderpropertyId[0]cmis:namepropertyValue[0]Select application variables : FolderNamepropertyId[1]cmis:objectTypeIdpropertyValue[1]cmis:foldersuccincttrue4.Obtain the FolderId value from the return value of the folder creation API.If the folder is created on DMS in Step 3 (if successful), the following value will be returned from the API.  {
“succinctProperties”:
{
“cmis:objectId”: “fWtCFDH4ah2BGeFqzoorOLETNNq65cmp82KfYUSpWxA”,
“sap:parentIds”: [“5daf1b700094ead661934376”],
“cmis:name”: “FromBuildApps-1737086879955”,
“cmis:lastModifiedBy”: “sb-ab7437c3-137b-4c58-ac6f-a0fe26232136!b141614|sdm-di-sdm_di_prod-prod!b41064”,
“cmis:objectTypeId”: “cmis:folder”,
“cmis:lastModificationDate”: 1737086882353,
“cmis:createdBy”: “sb-ab7437c3-137b-4c58-ac6f-a0fe26232136!b141614|sdm-di-sdm_di_prod-prod!b41064”,
“cmis:baseTypeId”: “cmis:folder”,
“cmis:parentId”: “5daf1b700094ead661934376”,
“sap:owner”: “sb-ab7437c3-137b-4c58-ac6f-a0fe26232136!b141614|sdm-di-sdm_di_prod-prod!b41064”,
“cmis:creationDate”: 1737086882353,
“cmis:changeToken”: “0”,
},
“exactACL”: false,
}  The ObjectId of the folder that must be sent to the SAP Build Process Automation process is the value of “cmis:objectId”. Assign this value to the variable FolderId.This uses Formula, STRING(<Output of HTTP destination request to create folder>.resBodyParsed.succinctProperties[“cmis:objectId”]) You can obtain it by specifying . “<Output of HTTP destination request to create folder>.resBodyParsed” is correct if you select it from output of another node in Variables displayed on the left.5. Upload files to DMSSimilar to Step 3, this uses the HTTP destination request to operate the DMS file upload API.For Destination, specify “sap_process_automation_document_store_ForApps” created in Part 1, for HTTP Method, specify “POST”, and for Request body type, specify “multipart/form-data”.Specify the Request body using “List of values” as shown in the table below. If there is no cautionary note, set it as Static Text.keyvaluecmisactioncreateDocumentpropertyId[0]cmis:namepropertyValue[0]Use Formula:Specify files[0].name of PickFiles – which created step1.propertyId[1]cmis:objectTypeIdpropertyValue[1]cmis:documentfilenamesame as PropertyValue[0]_charset_UTF-8includeAllowableActionstruesuccinctfalsemediaUse Formula:Specify files[0] of PickFiles – which created step1.An important point to note is that in DMS, when uploading files to a folder, you must specify the path. This is a form in which the path name (folder name) is included in the API endpoint. Therefore, open the OPTIONAL INPUTS of the HTTP destination request and use the formula for Path to use the folder name added in the form “/”+appVars.FolderName.OK, It will be able to upload to DMS.The logic for the File Upload button is now complete. Next, we will develop the logic for the Execute Workflow button that will link to the SAP Build Process Automation process with the information of this uploaded file.This is getting too long, so I’ll continue with Part 3.   Read More Technology Blogs by SAP articles 

#SAP

#SAPTechnologyblog

You May Also Like

More From Author