Skip to Content
Technical Articles
Author's profile photo Seshadri Sreenivas Ramanarayanan

How to handle attachments in SAP Cloud Platform Workflow

Many business processes have documents (or paperwork) like sales orders, deliveries, payments, reports, and other collected forms involved in the day-to-day operations. These documents pass across the different departments and/or people in a business process and could play a crucial role in the outcome of approval. Hence these documents should be readily available in the workflow for the approver to make an informed decision.

I have explained in one of my blogs on how to enable collaboration and document management capabilities in SAP Cloud Platform Workflow using SAP Jam. In that, I have described how multiple approvers can collaboratively approve a single document. However, if the use case is only to store documents (without a need for collaboration) and later access them in SAP Cloud Platform Workflow to support the decision-making process, then you have come to the right place. In this blog, I shall explain how to manage document in SAP Cloud Platform Workflow using the SAP Cloud Platform Document Service.

SAP Cloud Platform Document Service is an implementation of the CMIS standard and is the primary interface to a reliable and safe store for content on SAP Cloud Platform. It can store and manage unstructured and semi-structured data like documents, images, videos, presentations, and other files. The consumption of CMIS-enabled document repositories is easy using the Apache Chemistry libraries. Apache Chemistry provides libraries for several platforms to consume CMIS using Java, PHP, Python or .Net. Since the SAP Cloud Platform Document service API includes OpenCMIS Java library, applications can be built on SAP Cloud Platform that is independent of a specific content repository.

The Approach

The digital documents required for an approval workflow are uploaded to SAP Document Service repository. The URL to access these documents is persisted in the workflow context. This URL can be used from the workflow task UI to access the available document. To persist the documents and access them later, we would need to build and deploy a java based proxy-bridge application. The objective of this application is to enable access to the document repository from an external application (like My Inbox or any SAPUI5 application accessed from Portal).

Step-by-step guide

1. Create a document repository

Create a document repository in the subaccount area of SAP Cloud Platform Cockpit. You can refer to the help documentation for the detailed steps.

2. Deploy proxy-bridge application

Create and deploy a simple CMIS proxy-bridge java application in your SAP Cloud Platform subaccount. Refer to the help documentation on how to achieve this.

3. Access CMIS URL

Once you have deployed & started the proxy-bridge application, note down the URL of the app. For my app (with name dbrRepoService) the cockpit shows the following URL:

https://dbrreposervicexxxxxxxx.hana.ondemand.com/dbrRepoService

 

To access the CMIS repository, add /cmis/json to the end of the application URL and execute that in a browser.

 

4. Access the document repository

Now that you have successfully accessed the CMIS URL to get the repository details, copy the repositoryId property and append it to the URL and follow it with /root to access your repository, as shown in the image below.

You have now accessed the document repository to get the metadata of all the objects that are available in the repository. If you do not see any output for this API, then it is probably because your document repository is empty. You can follow step 4 & 5 of this help document to create a sample HTML5 application to upload documents to the repository.

 

5. Access a particular document from the repository

Observe that for each document uploaded to the repository you have an Object node that contains different properties of the particular content. To access a specific document from the repository, add the value of the property cmis:name.value to the CMIS repository root URL as shown in the image below.

 

So, the URL to access a particular document would be:

https://<javaApplicationURL>/cmis/json/<repositoryID>/root/<cmisDocumentName>

 

6. Accessing the document from SAP Cloud Platform Workflow task UI

Now that we are aware of how to locate a document using the CMIS repository URL, the same can be persisted in the workflow context and later accessed from a task UI. In the below image you can see that under the Attachments tab, a link to the document is provided. On click of the link, you can open the document in a new tab/window or in an iframe or any native controls like PDFViewer.

Though it might seem simple to add a link in the task UI, keep in mind that the CMIS URL needs to be accessed via SAP Cloud Platform destination and all URLs are routed through Fiori Launchpad (since MyInbox is accessed from FLP). If I need to access the CMIS URL from the task UI, then URL would look like below:

https://<FioriLaunchpadHost>/sap/fiori/<taskUIApplicationID>/<destinationMapping>/<javaServiceName>/cmis/json/<repositoryID>/root/<documentName>

Hence the CMIS URL with the above format was persisted in the workflow context.

Finally, you should also add a route in the neo-app.json of the task UI that maps the ‘destinationMapping’ in the above URL (/destinations/CMIS) to the actual destination in SAP Cloud Platform (CMIS).

Conclusion

Points to Note

  1. The documents uploaded to the document service repository should contain a unique name. If there is a chance that more than one document could have the same name, then it is necessary to generate a unique file name.
  2. If you have multiple task UIs that requires to access the CMIS URL, then you don’t need to add the route in neo-app.json of each application. Instead, you can add the route to the neo-app.json of one SAPUI5 application and use that applicationID across.
  3. SAP Cloud Platform Document Service is a repository to store your data (documents), and it does not come with any user interface to manage documents and requires you to build a custom user interface for the same. You could optionally use SAP Document Center to overcome this hurdle.
  4. In this blog, I have explained how you can use SAP Cloud Platform Document Service for storing the document and accessing the same from an SAP Cloud Platform Workflow. The same approach can also be used to access a document from any document management system.

 

I believe that this blog shows you how simple it is to handle attachments in SAP Cloud Platform Workflow. Do try it out bearing in mind that the same principle can be used to attach a document from any other document management system.

Assigned Tags

      16 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Phil Cooley
      Phil Cooley

      Thanks for sharing this Seshadri Sreenivas R - I believe heaps of customers would implement the workflow service as well as the Document handling via the SAP Document Service. The only thing stopping this is the fees for both the Java quota (required for the Java application) and the workflow service which does not make it a cheap solution. Hopefully both of these get revised soon so that it is more enticing for customers to implement these solutions.

      There is no question around the value it would add!

      Thanks

      Phil Cooley

      Author's profile photo Nabheet Madan
      Nabheet Madan

      +1 I believe soon we will have this sorted out with more features being brought to the workflow service. Basic forms have already come up fingers crossed:)

      Author's profile photo Cristian Rolando Castañeda Gonzalez
      Cristian Rolando Castañeda Gonzalez

      Hello Seshadri;

      Very useful information!

       

      I just wonder if there is another alternative to add attachments to SCP Workflows without the need of Java quota/components?

      Regards!

      Author's profile photo Seshadri Sreenivas Ramanarayanan
      Seshadri Sreenivas Ramanarayanan
      Blog Post Author

      Hi Cristian,

      Since SAP Document Service exposes the CMIS repo with Java APIs, it is mandatory to have the Java component in order to consume them.

      Regards,

      Sesh

      Author's profile photo Karla Cecilia Cantu Facio
      Karla Cecilia Cantu Facio

      Hello Seshadri

      I've tried to add files to my repository with the SAP Document Center but I just don't quite understand how it works. Can you please light me up?

       

      Regards,

      Karla.

      Author's profile photo Seshadri Sreenivas Ramanarayanan
      Seshadri Sreenivas Ramanarayanan
      Blog Post Author

      Hello Karla,

      Sure, I can help. Do want know about how SAP document works in general or how it works together with SAP cloud platform Workflow? We're you able to set up the document center repo and successfully upload/read documents?

      Regards,

      Seshadri Sreenivas

      Author's profile photo Karla Cecilia Cantu Facio
      Karla Cecilia Cantu Facio

      Hello Seshadri,

      I followed the tutorials you mentioned about how to creat a Hello World app, but when I add “/cmis/java” nothing happens.  And yes, I did set up the Document Center and created a repo with files as well, but I can not see how can I access it from the Java app.

      Regards,

      Karla Cantu

      Author's profile photo Seshadri Sreenivas Ramanarayanan
      Seshadri Sreenivas Ramanarayanan
      Blog Post Author

      Hi Karla,

      Did you mean cmis/json and not cmis/java?

      With cmis/json, retrieve the repository ID and form the following URL:

      https://<javaApplicationURL>/cmis/json/<repositoryID>/root/<cmisDocumentName >

      Let me if it worked.

      Regards

      Sesh

      Author's profile photo Turkia Golli
      Turkia Golli

      hello , i have created a repository and i can access it but i can not upload files to it from my html app can u help me please ?

      Author's profile photo Nikhila Moreira
      Nikhila Moreira

      Hello Seshadri,

       

      So as you have mentioned, I tried to get the repository details by adding

      "https://<javaApplicationURL>/cmis/json/"

      But I am getting "404 - Not Found" error

       

       

      Also, if we want to access a particular document from our UI5 application, do we have to sent the request to the java application in the format

      "https://<javaApplicationURL>/cmis/json/<repositoryID>/FolderName/<cmisDocumentName>"

       

      Author's profile photo Michael Ong
      Michael Ong

      I wonder if you've resolved this issue, as I'm encountering the same.

      When pointing the browser to the ../cmis/json end-point, I get prompted for a username and password.  Once I login with an EdmDeveloper user, I get an HTTP Status 404 Error as well.

      I can't get enough insight on the issue from the server response and have hit a dead-end.

      Author's profile photo Midhun VP
      Midhun VP

      Hi Seshadri,

      Document Service is not available on CF. So, if a customer running WF on CF what is the recommended approach?

      Regards,

      Midhun VP

      Author's profile photo Seshadri Sreenivas Ramanarayanan
      Seshadri Sreenivas Ramanarayanan
      Blog Post Author

      Hi Midhun,

      The approach documented here is not limited to SAP document service alone. That means it doesn't matter where the document management service is available - neo, CF or external service. You can have the workflow in CF, and the document service in neo (or CF, when it is available) or you could use any other service like SharePoint.

      Regards,

      Seshadri

      Author's profile photo Pablo Costantini
      Pablo Costantini

      This is not working with cloud foundry, right?

      Regards.

       

      Author's profile photo Seshadri Sreenivas Ramanarayanan
      Seshadri Sreenivas Ramanarayanan
      Blog Post Author

      For Cloud Foundry, you can use the Workflow Management live process template for Document Centric Approval Process (consume the package content or use that as a reference).

      Author's profile photo Pieter Janssens
      Pieter Janssens

      In this sample SAP is showing how we can use SAP Jam Work Zone to store the attachment.

      https://github.com/SAP-samples/workzone-workflow-journey-app-template

      Besides that the sample isn't working (we end up with blank documents), I am worried about the visibility of the uploaded attachment. It seems that this content is showing up in all members of the group workspace...