const cds = require('@sap/cds');
module.exports = async srv => {
const { Objects } = srv.entities // entities from myService.cds
srv.on("myAction", async req => {
const query = SELECT.one.from(Objects).where({ id: req.data.myId })
const srv = await cds.connect.to('myService')
const data = await srv.run(query)
console.log(data)
return data
})
srv.on("READ", Objects, async req => {
console.log("Objects called")
// Select data from db or forward query to external system
// ...
// return data
})
}
Tag: Entity
[ABAP] Parse SF Entity Key from URI
METHOD get_entitykey_from_uri.
" Pattern: Entity\((.*)\),
DATA(pattern) = iv_entity && `\((.*)\)`.
TRY.
DATA(matcher) = cl_abap_matcher=>create( pattern = pattern
text = iv_uri
ignore_case = abap_true ).
CATCH cx_sy_invalid_regex.
ENDTRY.
TRY.
DATA(lt_matches) = matcher->find_all( ).
ASSIGN lt_matches[ 1 ] TO FIELD-SYMBOL(<s>).
rv_entity_key = substring( val = iv_uri off = <s>-offset len = <s>-length ).
CATCH cx_sy_no_current_match.
ENDTRY.
ENDMETHOD.
[HR] SuccessFactors – Fetch Entity Metadata
https://launchpad.support.sap.com/#/notes/2668887
https://help.sap.com/viewer/d599f15995d348a1b45ba5603e2aba9b/2011/en-US/505856f7d9814f76a8894ec4f0d9e16e.html
https://help.sap.com/viewer/d599f15995d348a1b45ba5603e2aba9b/2011/en-US/2212e86cb3854718904db333e7b0be33.html
# To fetch the entire metadata of an instance
https://<hostname>.successfactors.com/odata/v2/?$metadata
# Fetch the metadata of specific entity
https://<hostname>.successfactors.com/odata/v2/PerPersonRelationship/?$metadata
# Fetch metata of specific entity including navigation properties
https://<hostname>.successfactors.com/odata/v2/Entity('PerPersonRelationship')/?$metadata