This commit is contained in:
D065023
2020-01-29 09:55:21 +01:00
parent 9b41615ac8
commit bf162c23cc
3 changed files with 14 additions and 8 deletions

View File

@@ -4,6 +4,7 @@
"description": "A simple bookshop application, build in a self-contained all-in-one fashion, i.e. w/o reusing other packages.", "description": "A simple bookshop application, build in a self-contained all-in-one fashion, i.e. w/o reusing other packages.",
"license": "SAP SAMPLE CODE LICENSE", "license": "SAP SAMPLE CODE LICENSE",
"dependencies": { "dependencies": {
"@sap/xb-msg-amqp-v100": "latest",
"@sap/cds": "latest", "@sap/cds": "latest",
"express": "*" "express": "*"
}, },
@@ -18,10 +19,16 @@
"API_BUSINESS_PARTNER": { "API_BUSINESS_PARTNER": {
"kind": "odata", "kind": "odata",
"model": "srv/external/API_BUSINESS_PARTNER", "model": "srv/external/API_BUSINESS_PARTNER",
"--credentials": { "credentials": {
"destination": "cap-api098" "destination": "cap-api098"
} }
},
"messaging": {
"kind": "enterprise-messaging",
"credentials": {
"prefix": "sap/S4HANAOD/c098/BO"
}
} }
} }
} }
} }

View File

@@ -9,7 +9,7 @@ service CatalogService {
} excluding { createdBy, modifiedBy }; } excluding { createdBy, modifiedBy };
@readonly entity Addresses as projection on A_BusinessPartnerAddress { @readonly entity Addresses as projection on A_BusinessPartnerAddress {
key AddressID, key AddressID as ID,
key BusinessPartner, key BusinessPartner,
StreetName, StreetName,
HouseNumber, HouseNumber,
@@ -18,8 +18,8 @@ service CatalogService {
Country Country
}; };
event OrdersOutdated { event OrderOutdated {
orders: array of my.Orders ID: UUID;
}; };
@requires_: 'authenticated-user' @requires_: 'authenticated-user'

View File

@@ -10,9 +10,8 @@ module.exports = cds.service.impl(async function () {
bupaSrv.on('BusinessPartner/Changed', async msg => { bupaSrv.on('BusinessPartner/Changed', async msg => {
console.log('>> Received message', msg.data) console.log('>> Received message', msg.data)
const BUSINESSPARTNER = msg.data.KEY[0].BUSINESSPARTNER const BUSINESSPARTNER = msg.data.KEY[0].BUSINESSPARTNER
const orders = await cds.tx(msg).run(SELECT.from(Orders).where({ createdBy: BUSINESSPARTNER })) const orders = await cds.tx(msg).run(SELECT('ID').from(Orders).where({ createdBy: BUSINESSPARTNER }))
this.emit('OrdersOutdated', { orders }) orders.forEach(order => this.emit('OrderOutdated', order) && console.log('<< Emitting message', order))
console.log('<< Emitting message', { orders })
}) })
/** Add some discount for overstocked books */ /** Add some discount for overstocked books */