Compare commits
8 Commits
openSAP-we
...
openSAP-we
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f28bfbb768 | ||
|
|
7d8ca4d4a1 | ||
|
|
61aa81a806 | ||
|
|
e7c395671b | ||
|
|
cd245c4641 | ||
|
|
d081438a6a | ||
|
|
79c3a22224 | ||
|
|
9c30ad7584 |
@@ -11,7 +11,7 @@ In SAP Business Application Studio, open a terminal.
|
|||||||
Then clone the repo with this specific branch:
|
Then clone the repo with this specific branch:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
git clone https://github.com/sap-samples/cloud-cap-samples projects/cloud-cap-samples -b openSAP-week4-unit1-final
|
git clone https://github.com/sap-samples/cloud-cap-samples projects/cloud-cap-samples -b openSAP-week4-unit2-final
|
||||||
cd projects/cloud-cap-samples
|
cd projects/cloud-cap-samples
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,10 @@
|
|||||||
"requires": {
|
"requires": {
|
||||||
"API_BUSINESS_PARTNER": {
|
"API_BUSINESS_PARTNER": {
|
||||||
"kind": "odata",
|
"kind": "odata",
|
||||||
"model": "srv/external/API_BUSINESS_PARTNER"
|
"model": "srv/external/API_BUSINESS_PARTNER",
|
||||||
|
"--credentials": {
|
||||||
|
"destination": "cap-api098"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using { sap.capire.bookshop as my } from '../db/schema';
|
using { sap.capire.bookshop as my } from '../db/schema';
|
||||||
|
using { API_BUSINESS_PARTNER as external } from './external/API_BUSINESS_PARTNER.csn';
|
||||||
|
|
||||||
@path:'/browse'
|
@path:'/browse'
|
||||||
service CatalogService {
|
service CatalogService {
|
||||||
@@ -7,6 +8,14 @@ service CatalogService {
|
|||||||
author.name as author
|
author.name as author
|
||||||
} excluding { createdBy, modifiedBy };
|
} excluding { createdBy, modifiedBy };
|
||||||
|
|
||||||
|
@readonly entity BusinessPartners as projection on external.A_BusinessPartner {
|
||||||
|
key BusinessPartner as ID,
|
||||||
|
FirstName,
|
||||||
|
MiddleName,
|
||||||
|
LastName,
|
||||||
|
BusinessPartnerIsBlocked
|
||||||
|
};
|
||||||
|
|
||||||
@requires_: 'authenticated-user'
|
@requires_: 'authenticated-user'
|
||||||
@insertonly entity Orders as projection on my.Orders;
|
@insertonly entity Orders as projection on my.Orders;
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
const cds = require('@sap/cds')
|
const cds = require('@sap/cds')
|
||||||
|
|
||||||
/** Service implementation for CatalogService */
|
/** Service implementation for CatalogService */
|
||||||
module.exports = cds.service.impl(function () {
|
module.exports = cds.service.impl(async function () {
|
||||||
const { Books, Orders } = this.entities
|
const { Books, Orders, BusinessPartners } = this.entities
|
||||||
|
const bupaSrv = await cds.connect.to('API_BUSINESS_PARTNER')
|
||||||
this.after('READ', Books, each => each.stock > 111 && _addDiscount2(each, 11))
|
this.after('READ', Books, each => each.stock > 111 && _addDiscount2(each, 11))
|
||||||
this.before('CREATE', Orders, _reduceStock)
|
this.before('CREATE', Orders, _reduceStock)
|
||||||
|
this.on('READ', BusinessPartners, req => bupaSrv.tx(req).run(req.query))
|
||||||
|
|
||||||
/** Add some discount for overstocked books */
|
/** Add some discount for overstocked books */
|
||||||
function _addDiscount2(each, discount) {
|
function _addDiscount2(each, discount) {
|
||||||
|
|||||||
4
packages/bookshop/srv/external/data/API_BUSINESS_PARTNER-A_BusinessPartner.csv
vendored
Normal file
4
packages/bookshop/srv/external/data/API_BUSINESS_PARTNER-A_BusinessPartner.csv
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
BusinessPartner;FirstName;MiddleName;LastName;BusinessPartnerIsBlocked
|
||||||
|
ALICE;Alice;In;Wonderland;false
|
||||||
|
BOB;Bob;The;Builder;false
|
||||||
|
JABBA;Jabba;The;Hutt;true
|
||||||
|
Reference in New Issue
Block a user