The @cap-js/sdm package is cds-plugin that provides an easy CAP-level integration with SAP Document Management Service. This package supports handling of attachments(documents) by using an aspect Attachments in SAP Document Management Service.
This plugin can be consumed by the CAP application deployed on BTP to store their documents in the form of attachments in Document Management Repository.
npm install -g @sap/cds-dk
)npm install -g mbt
)cf install-plugin multiapps
.In this guide, we use the Incidents Management reference sample app as the base application, to integrate SDM CAP plugin.
[!Note] To be able to use the Fiori uploadTable feature, you must ensure 1.121.0/ 1.122.0/ ^1.125.0 SAPUI5 version is updated in the application's index.html
If you want to use the released version of SDM CAP plugin follow the below steps:
git clone https://github.com/cap-js/incidents-app.git
git checkout incidents-app-deploy
npm add @cap-js/sdm
If you want to use the version under development follow the below steps:
git clone https://github.com/cap-js/sdm.git
npm pack
This will generate a file with name cap-js-sdm-x.y.z.tgz
git clone https://github.com/cap-js/incidents-app.git
git checkout incidents-app-deploy
npm install <path-to-.tgz file>
To use sdm plugin in incidents-app, create an element with an Attachments
type. Following the best practice of separation of concerns, create a separate file db/attachments.cds and paste the below content in it:
using { sap.capire.incidents as my } from './schema';
using { Attachments } from '@cap-js/sdm';
extend my.Incidents with { attachments: Composition of many Attachments }
Create a SAP Document Management Integration Option Service instance and key. Using credentials from key onboard a repository and configure the onboarded repositoryId under cds.requires in package.json. Currently only non versioned repositories are supported.
"sdm": {
"settings": {
"repositoryId": "<repository-Id>"
}
}
Log in to Cloud Foundry space:
cf login -a <CF-API> -o <ORG-NAME> -s <SPACE-NAME>
Bind CAP application to SAP Document Management Integration Option. Check the following reference from mta.yaml
of Incidents Management app
modules:
- name: incidents-srv
type: nodejs
path: gen/srv
requires:
- name: sdm-di-instance
resources:
- name: sdm-di-instance
type: org.cloudfoundry.managed-service
parameters:
service: sdm
service-plan: standard
Build the project by running following command from root folder of incidents-app.
mbt build
Above step will generate .mtar file inside mta_archives folder.
Deploy the application
cf deploy mta_archives/*.mtar
Launch the application
* Navigate to Html5Applications menu in BTP subaccount and open the application (nsincidents v1.0.0) in a browser.
* Click on incident with title Solar panel broken.
The Attachments
type has generated an out-of-the-box Attachments table (see highlighted box) at the bottom of the Object page:
Upload a file by going into Edit mode and either using the Upload button on the Attachments table or by drag/drop. Then click the Save button to have that file stored in SAP Document Management Integration Option. We demonstrate this by uploading the PDF file from xmpl/db/content/Solar Panel Report.pdf:
Open a file by clicking on the attachment. We demonstrate this by opening the previously uploaded PDF file: Solar Panel Report.pdf
Rename a file by going into Edit mode and setting a new name for the file in the filename field. Then click the Save button to have that file renamed in SAP Document Management Integration Option. We demonstrate this by renaming the previously uploaded PDF file: Solar Panel Report.pdf
Delete a file by going into Edit mode and selecting the file(s) and by using the Delete button on the Attachments table. Then click the Save button to have that file deleted from the resource (SAP Document Management Integration Option). We demonstrate this by deleting the previously uploaded PDF file: Solar Panel Report_2024.pdf
To run the unit tests:
npm run test
This project is open to feature requests/suggestions, bug reports etc. via GitHub issues. Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our Contribution Guidelines.
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone. By participating in this project, you agree to abide by its Code of Conduct at all times.
Copyright 2024 SAP SE or an SAP affiliate company and