CAP Plugin SAP Document Management Service is available in Capire. How to utilize it to improve our development efficiency in using SDM. I tried and I want to blog down the key steps to share with our customers to avoid troubles when they use it.
Prerequisites:
Set Up SAP Business Application Studio for DevelopmentCreate a Dev Space for Business ApplicationsEntitlement of Document Management Service, Integration Option with Standard Or Free plan
MainSteps:
Step 1. Create SDM instance and service key by following Initial Setup.
Step 2. Onboarding repository by using tools like postman by using service in Step 1. You can follow Onboard Repository
Note down the repository ID for further use .
Note it is important to use json body as the following content
{
“repository”: {
“displayName”: “incidentmgt”,
“description”: “incidentmgt”,
“repositoryType”: “internal”,
“isVersionEnabled”:”false”,
“isVirusScanEnabled”:”false”,
“skipVirusScanForLargeFile”: “false”,
“isThumbnailEnabled”: “false”,
“isEncryptionEnabled”: “false”,
“isClientCacheEnabled”: “false”,
“hashAlgorithms”:”SHA-256″,
“isContentBridgeEnabled” : “false” }
}
Step 3. Create CAP project with following command :
cds init incidentattach
Step 4. Add schema.cds under folder db with the following code:
using { cuid, managed, sap.common.CodeList } from ‘@sap/cds/common’;
namespace sap.capire.incidents;
/**
* Incidents created by Customers.
*/
entity Incidents : cuid, managed {
customer : Association to Customers;
title : String @title : ‘Title’;
urgency : Association to Urgency default ‘M’;
status : Association to Status default ‘N’;
conversation : Composition of many {
key ID : UUID;
timestamp : type of managed:createdAt;
author : type of managed:createdBy;
message : String;
};
}
/**
* Customers entitled to create support Incidents.
*/
entity Customers : managed {
key ID : String;
firstName : String;
lastName : String;
name : String = firstName ||’ ‘|| lastName;
email : EMailAddress;
phone : PhoneNumber;
incidents : Association to many Incidents on incidents.customer = $self;
creditCardNo : String(16) @assert.format: ‘^[1-9]d{15}$’;
addresses : Composition of many Addresses on addresses.customer = $self;
}
entity Addresses : cuid, managed {
customer : Association to Customers;
city : String;
postCode : String;
streetAddress : String;
}
entity Status : CodeList {
key code: String enum {
new = ‘N’;
assigned = ‘A’;
in_process = ‘I’;
on_hold = ‘H’;
resolved = ‘R’;
closed = ‘C’;
};
criticality : Integer;
}
entity Urgency : CodeList {
key code: String enum {
high = ‘H’;
medium = ‘M’;
low = ‘L’;
};
}
type EMailAddress : String;
type PhoneNumber : String;
Step 5. Add services.cds under folder srv with the following code:
using { sap.capire.incidents as my } from ‘../db/schema’;
/**
* Service used by support personell, i.e. the incidents’ ‘processors’.
*/
service ProcessorService {
entity Incidents as projection on my.Incidents;
entity Customers as projection on my.Customers;
}
/**
* Service used by administrators to manage customers and incidents.
*/
service AdminService {
entity Customers as projection on my.Customers;
entity Incidents as projection on my.Incidents;
}
annotate ProcessorService.Incidents with .draft.enabled;
annotate AdminService.Incidents with .draft.enabled;
Step 6. Add SDM plugin library with the following command in terminal .
npm add -js/sdm
Step 7. Add file attachments.cds under folder db with the following code .
using { sap.capire.incidents.Incidents } from ‘./schema’;
using { Attachments } from ‘@cap-js/sdm’;
extend Incidents with {
attachments: Composition of many Attachments;
};
Step 8. Add the following settings under cds/requires with repository ID from Step 2. This setting is a different from CAPire document. I think it will be updated soon.
“sdm”: {
“settings”: {
“repositoryId”: “repository id from Step 2”
}
Step 9. Add SAP Fiori application.
Step 10. Add hana database and security for production with the following commands in terminal.
cds add hana –production
cds add xsuaa –production
cds add workzone
Step 11. Following Prepare for Deployment in the SAP BTP, Cloud Foundry Runtime and Deploy in SAP BTP, Cloud Foundry Runtime .
Important Note: need to check the mta file for SDM resource to keep the it the same with SDM instance name in Step 1 before deploy the application into BTP Cloud Foundry.
Step 12. Test UI in SAP BTP sub-account.
Step 13. Check the result in SDM repository with CMIS WORKBENCH.
Step 14. You can refer to incidentattach deploy branch .
The end!
Thanks for your time!
Best Regards!
Jacky Liu
CAP Plugin SAP Document Management Service is available in Capire. How to utilize it to improve our development efficiency in using SDM. I tried and I want to blog down the key steps to share with our customers to avoid troubles when they use it.Prerequisites:Set Up SAP Business Application Studio for DevelopmentCreate a Dev Space for Business ApplicationsEntitlement of Document Management Service, Integration Option with Standard Or Free planMainSteps:Step 1. Create SDM instance and service key by following Initial Setup.Step 2. Onboarding repository by using tools like postman by using service in Step 1. You can follow Onboard RepositoryNote down the repository ID for further use .Note it is important to use json body as the following content {
“repository”: {
“displayName”: “incidentmgt”,
“description”: “incidentmgt”,
“repositoryType”: “internal”,
“isVersionEnabled”:”false”,
“isVirusScanEnabled”:”false”,
“skipVirusScanForLargeFile”: “false”,
“isThumbnailEnabled”: “false”,
“isEncryptionEnabled”: “false”,
“isClientCacheEnabled”: “false”,
“hashAlgorithms”:”SHA-256″,
“isContentBridgeEnabled” : “false” }
} Step 3. Create CAP project with following command : cds init incidentattach Step 4. Add schema.cds under folder db with the following code: using { cuid, managed, sap.common.CodeList } from ‘@sap/cds/common’;
namespace sap.capire.incidents;
/**
* Incidents created by Customers.
*/
entity Incidents : cuid, managed {
customer : Association to Customers;
title : String @title : ‘Title’;
urgency : Association to Urgency default ‘M’;
status : Association to Status default ‘N’;
conversation : Composition of many {
key ID : UUID;
timestamp : type of managed:createdAt;
author : type of managed:createdBy;
message : String;
};
}
/**
* Customers entitled to create support Incidents.
*/
entity Customers : managed {
key ID : String;
firstName : String;
lastName : String;
name : String = firstName ||’ ‘|| lastName;
email : EMailAddress;
phone : PhoneNumber;
incidents : Association to many Incidents on incidents.customer = $self;
creditCardNo : String(16) @assert.format: ‘^[1-9]d{15}$’;
addresses : Composition of many Addresses on addresses.customer = $self;
}
entity Addresses : cuid, managed {
customer : Association to Customers;
city : String;
postCode : String;
streetAddress : String;
}
entity Status : CodeList {
key code: String enum {
new = ‘N’;
assigned = ‘A’;
in_process = ‘I’;
on_hold = ‘H’;
resolved = ‘R’;
closed = ‘C’;
};
criticality : Integer;
}
entity Urgency : CodeList {
key code: String enum {
high = ‘H’;
medium = ‘M’;
low = ‘L’;
};
}
type EMailAddress : String;
type PhoneNumber : String; Step 5. Add services.cds under folder srv with the following code: using { sap.capire.incidents as my } from ‘../db/schema’;
/**
* Service used by support personell, i.e. the incidents’ ‘processors’.
*/
service ProcessorService {
entity Incidents as projection on my.Incidents;
entity Customers as projection on my.Customers;
}
/**
* Service used by administrators to manage customers and incidents.
*/
service AdminService {
entity Customers as projection on my.Customers;
entity Incidents as projection on my.Incidents;
}
annotate ProcessorService.Incidents with .draft.enabled;
annotate AdminService.Incidents with .draft.enabled; Step 6. Add SDM plugin library with the following command in terminal . npm add -js/sdm Step 7. Add file attachments.cds under folder db with the following code . using { sap.capire.incidents.Incidents } from ‘./schema’;
using { Attachments } from ‘@cap-js/sdm’;
extend Incidents with {
attachments: Composition of many Attachments;
}; Step 8. Add the following settings under cds/requires with repository ID from Step 2. This setting is a different from CAPire document. I think it will be updated soon. “sdm”: {
“settings”: {
“repositoryId”: “repository id from Step 2”
} Step 9. Add SAP Fiori application. Step 10. Add hana database and security for production with the following commands in terminal. cds add hana –production
cds add xsuaa –production
cds add workzone Step 11. Following Prepare for Deployment in the SAP BTP, Cloud Foundry Runtime and Deploy in SAP BTP, Cloud Foundry Runtime .Important Note: need to check the mta file for SDM resource to keep the it the same with SDM instance name in Step 1 before deploy the application into BTP Cloud Foundry.Step 12. Test UI in SAP BTP sub-account.Step 13. Check the result in SDM repository with CMIS WORKBENCH.Step 14. You can refer to incidentattach deploy branch .The end!Thanks for your time!Best Regards!Jacky Liu Read More Technology Blogs by SAP articles
#SAP
#SAPTechnologyblog