3 hours ago
I am new to SAP CAP and I try to connect to an OData (API_BUSINESS_PARTNER) which provides data from our own system.
At the moment the whole app is readonly which works perfectly fine. But as soon as I try to add the possibility to edit fields of a business partner I get an error that the ressource "HasActiveEntity" is missing.
[remote] - Error: Error during request to remote service: Ressource für Segment 'HasActiveEntity' nicht gefunden
at run (.\apisample\node_modules\@sap\cds\libx\_runtime\remote\utils\client.js:238:31)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async RemoteService.on_handler (.\apisample\node_modules\@sap\cds\libx\_runtime\remote\Service.js:274:20)
at async next (.\apisample\node_modules\@sap\cds\lib\srv\srv-dispatch.js:69:17)
at async RemoteService.handle (.\apisample\node_modules\@sap\cds\lib\srv\srv-dispatch.js:67:10)
at async RemoteService.handle (.\apisample\node_modules\@sap\cds\libx\_runtime\remote\Service.js:286:16)
at async RemoteService.handle (.\apisample\node_modules\@sap\cds\libx\_runtime\remote\Service.js:294:16)
at async ApplicationService.<anonymous> (.\apisample\srv\external-service-bp.js:5:10)
at async next (.\apisample\node_modules\@sap\cds\lib\srv\srv-dispatch.js:69:17)
at async ApplicationService.handle (.\apisample\node_modules\@sap\cds\lib\srv\srv-dispatch.js:67:10) {
statusCode: 502,
reason: AxiosError: Request failed with status code 404
at settle (.\apisample\node_modules\axios\dist\node\axios.cjs:2019:12)
at IncomingMessage.handleStreamEnd (.\apisample\node_modules\axios\dist\node\axios.cjs:3135:11)
at IncomingMessage.emit (node:events:529:35)
at endReadableNT (node:internal/streams/readable:1400:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
at Axios.request (.\apisample\node_modules\axios\dist\node\axios.cjs:4287:41)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async run (.\apisample\node_modules\@sap\cds\libx\_runtime\remote\utils\client.js:227:16)
at async RemoteService.on_handler (.\apisample\node_modules\@sap\cds\libx\_runtime\remote\Service.js:274:20)
at async next (.\apisample\node_modules\@sap\cds\lib\srv\srv-dispatch.js:69:17)
at async RemoteService.handle (.\apisample\node_modules\@sap\cds\lib\srv\srv-dispatch.js:67:10)
at async RemoteService.handle (.\apisample\node_modules\@sap\cds\libx\_runtime\remote\Service.js:286:16)
at async RemoteService.handle (.\apisample\node_modules\@sap\cds\libx\_runtime\remote\Service.js:294:16)
at async ApplicationService.<anonymous> (.\apisample\srv\external-service-bp.js:5:10)
at async next (.\apisample\node_modules\@sap\cds\lib\srv\srv-dispatch.js:69:17) {
message: "Error during request to remote service: Ressource für Segment 'HasActiveEntity' nicht gefunden",
code: 'ERR_BAD_REQUEST',
config: {
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
method: 'get',
baseURL: 'https://myXXXXXX-api.s4hana.cloud.sap/sap/opu/odata/sap/API_BUSINESS_PARTNER',
proxy: false,
url: '/A_BusinessPartner?$select=BusinessPartner,BusinessPartnerName,CreatedByUser,FirstName,HasActiveEntity,IsActiveEntity,LastName,TradingPartner&$orderby=BusinessPartner%20asc&$filter=(IsActiveEntity%20eq%20false%20or%20SiblingEntity%2FIsActiveEntity%20eq%20null)&$inlinecount=allpages&$top=30',
data: undefined
},
request: {
method: 'GET',
url: 'https://myXXXXXX-api.s4hana.cloud.sap/sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner?$select=BusinessPartner,BusinessPartnerName,CreatedByUser,FirstName,HasActiveEntity,IsActiveEntity,LastName,TradingPartner&$orderby=BusinessPartner%20asc&$filter=(IsActiveEntity%20eq%20false%20or%20SiblingEntity%2FIsActiveEntity%20eq%20null)&$inlinecount=allpages&$top=30',
headers: [Object [AxiosHeaders]]
},
response: {
status: 404,
statusText: 'Not Found',
headers: [Object [AxiosHeaders]],
body: [Object]
},
status: 404,
toJSON: [Function (anonymous)]
}
}
[cds] - Error: Error during request to remote service: Ressource für Segment 'HasActiveEntity' nicht gefunden
at run (.\apisample\node_modules\@sap\cds\libx\_runtime\remote\utils\client.js:238:31)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async RemoteService.on_handler (.\apisample\node_modules\@sap\cds\libx\_runtime\remote\Service.js:274:20)
at async next (.\apisample\node_modules\@sap\cds\lib\srv\srv-dispatch.js:69:17)
at async RemoteService.handle (.\apisample\node_modules\@sap\cds\lib\srv\srv-dispatch.js:67:10)
at async RemoteService.handle (.\apisample\node_modules\@sap\cds\libx\_runtime\remote\Service.js:286:16)
at async RemoteService.handle (.\apisample\node_modules\@sap\cds\libx\_runtime\remote\Service.js:294:16)
at async ApplicationService.<anonymous> (.\apisample\srv\external-service-bp.js:5:10)
at async next (.\apisample\node_modules\@sap\cds\lib\srv\srv-dispatch.js:69:17)
at async ApplicationService.handle (.\apisample\node_modules\@sap\cds\lib\srv\srv-dispatch.js:67:10) {
statusCode: 502,
reason: AxiosError: Request failed with status code 404
at settle (.\apisample\node_modules\axios\dist\node\axios.cjs:2019:12)
at IncomingMessage.handleStreamEnd (.\apisample\node_modules\axios\dist\node\axios.cjs:3135:11)
at IncomingMessage.emit (node:events:529:35)
at endReadableNT (node:internal/streams/readable:1400:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
at Axios.request (.\apisample\node_modules\axios\dist\node\axios.cjs:4287:41)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async run (.\apisample\node_modules\@sap\cds\libx\_runtime\remote\utils\client.js:227:16)
at async RemoteService.on_handler (.\apisample\node_modules\@sap\cds\libx\_runtime\remote\Service.js:274:20)
at async next (.\apisample\node_modules\@sap\cds\lib\srv\srv-dispatch.js:69:17)
at async RemoteService.handle (.\apisample\node_modules\@sap\cds\lib\srv\srv-dispatch.js:67:10)
at async RemoteService.handle (.\apisample\node_modules\@sap\cds\libx\_runtime\remote\Service.js:286:16)
at async RemoteService.handle (.\apisample\node_modules\@sap\cds\libx\_runtime\remote\Service.js:294:16)
at async ApplicationService.<anonymous> (.\apisample\srv\external-service-bp.js:5:10)
at async next (.\apisample\node_modules\@sap\cds\lib\srv\srv-dispatch.js:69:17) {
message: "Error during request to remote service: Ressource für Segment 'HasActiveEntity' nicht gefunden",
code: 'ERR_BAD_REQUEST',
config: {
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
method: 'get',
baseURL: 'https://myXXXXXX-api.s4hana.cloud.sap/sap/opu/odata/sap/API_BUSINESS_PARTNER',
proxy: false,
url: '/A_BusinessPartner?$select=BusinessPartner,BusinessPartnerName,CreatedByUser,FirstName,HasActiveEntity,IsActiveEntity,LastName,TradingPartner&$orderby=BusinessPartner%20asc&$filter=(IsActiveEntity%20eq%20false%20or%20SiblingEntity%2FIsActiveEntity%20eq%20null)&$inlinecount=allpages&$top=30',
data: undefined
},
request: {
method: 'GET',
url: 'https://myXXXXXX-api.s4hana.cloud.sap/sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner?$select=BusinessPartner,BusinessPartnerName,CreatedByUser,FirstName,HasActiveEntity,IsActiveEntity,LastName,TradingPartner&$orderby=BusinessPartner%20asc&$filter=(IsActiveEntity%20eq%20false%20or%20SiblingEntity%2FIsActiveEntity%20eq%20null)&$inlinecount=allpages&$top=30',
headers: [Object [AxiosHeaders]]
},
response: {
status: 404,
statusText: 'Not Found',
headers: [Object [AxiosHeaders]],
body: [Object]
},
status: 404,
toJSON: [Function (anonymous)]
}
}
[error] - 502 > {
code: '502',
message: "Error during request to remote service: Ressource für Segment 'HasActiveEntity' nicht gefunden"
}
This is external-service-bp.cds where I intended to use @odata.draft.enabled
using {cap.apitest as api} from '../db/schema';
service BusinessPartnerService {
@odata.draft.enabled
entity BusinessPartners as
projection on api.BusinessPartners {
*
}
}
This is external-service-bp.js
module.exports = async service => {
const BusinessPartnerService = await cds.connect.to("API_BUSINESS_PARTNER");
service.on("READ", "BusinessPartners", async context => {
return await BusinessPartnerService.run(context.query);
});
};
This is schema.cds which makes it possible to use the entitySet in the Fiori-App
using {API_BUSINESS_PARTNER} from '../srv/external/API_BUSINESS_PARTNER';
namespace cap.apitest;
entity BusinessPartners as
projection on API_BUSINESS_PARTNER.A_BusinessPartner {
*
};
This is fiori-service.cds where I adjust the UI
using {BusinessPartnerService} from '../../srv/external-service-bp.cds';
annotate BusinessPartnerService.BusinessPartners with @(
UI : {
SelectionFields: [
BusinessPartner,
BusinessPartnerName
],
LineItem : [
{Value: BusinessPartner},
{Value: BusinessPartnerName},
{Value: FirstName},
{Value: LastName},
{Value: CreatedByUser},
{Value: TradingPartner}
],
Facets : [{
$Type : 'UI.ReferenceFacet',
Label : '{i18n>GeneralInformation}',
Target: '@UI.Identification'
}],
Identification : [
{Value: BusinessPartner},
{Value: BusinessPartnerName},
{Value: FirstName},
{Value: LastName},
{Value: BusinessPartnerFullName},
{Value: OrganizationBPName1},
{Value: OrganizationBPName2},
{Value: OrganizationBPName3},
{Value: OrganizationBPName4},
{Value: OrganizationFoundationDate},
{Value: OrganizationLiquidationDate}
],
HeaderInfo : {
TypeName : '{i18n>TypeName}',
TypeNamePlural: '{i18n>TypeNamePlural}',
Title : {Value: BusinessPartnerName},
Description : {Value: OrganizationBPName1}
},
DeleteHidden : true,
UpdateHidden : false
},
Capabilities: {
UpdateRestrictions: {Updatable: true},
Updatable : true
}
);
annotate BusinessPartnerService.BusinessPartnersAlias with @(
UI : {
SelectionFields: [
BusinessPartner,
BPAliasPositionNumber
],
LineItem : [
{Value: BusinessPartner},
{Value: BPAliasPositionNumber},
{Value: BusinessPartnerAliasName}
],
Facets : [{
$Type : 'UI.ReferenceFacet',
Label : '{i18n>GeneralInformation}',
Target: '@UI.Identification'
}],
Identification : [
{Value: BusinessPartner},
{Value: BPAliasPositionNumber},
{Value: BusinessPartnerAliasName}
],
HeaderInfo : {
TypeName : '{i18n>TypeName}',
TypeNamePlural: '{i18n>TypeNamePlural}',
Title : {Value: BusinessPartner},
Description : {Value: BusinessPartnerAliasName}
},
DeleteHidden : true,
UpdateHidden : false
},
Capabilities: {
UpdateRestrictions: {Updatable: true},
Updatable : true
}
);
I hope I provided all necessary information to help you help me. I can't find a proper solution to access CRUD operations for a ODataV2 Service. I also tried using @Rizing/cds-extension, but gave up after I found out that the latest version of @sap/cds makes it unusable.
Do I have a chance to have an Edit Button in the Details View of a Business Partner?
User | Count |
---|---|
68 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.