on 05-21-2021 11:29 AM
Hello Experts,
I am working on CAP based programming model wherein I have consumed external API, API_BUSINESS_PARTNER, and fetching the data from an entity A_BusinessPartner. As below:
@readonly
entity BusinessPartners as projection on external.A_BusinessPartner {
BusinessPartner, LastName, FirstName, Customer, to_BusinessPartnerAddress
};
@readonly
entity BusinessPartnerAddresses as projection on external.A_BusinessPartnerAddress {
BusinessPartner, AddressID, Country
}
However, When I am using $expand to get business Partner Address information, I am not getting any columns for that and the query returns as:
Additionally, Referring to https://github.com/sapmentors/cap-community/issues/61 , I have modified API_BUSINESS_PARTNER.csn file as
"to_BusinessPartnerAddress": {
"type": "cds.Association",
"target": "API_BUSINESS_PARTNER.A_BusinessPartnerAddress",
"on": [{
"ref": [
"BusinessPartner"
]
},
"=",
{
"ref": [
"$self"
]
}
],
"cardinality": {
"max": "*"
}
}
Below is the custom handler for the same
this.on('READ', BusinessPartners, async (req) => {
try {
const tx = service.transaction();
return await tx.send({
query:req.query,
headers: {
"APIKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
})
} catch (err) {
req.reject(err);
}
});
Am I missing something? If anyone has any pointers or faced any such issue, please provide your assistance/feedback on the same.
Regards,
Navneet Kaur
User | Count |
---|---|
65 | |
8 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.