on 12-28-2021 7:11 PM
Hello Experts,
I am trying to consume an external SAP IBP OData service which has credentials as well. I followed this awesome blog from jhodel18 But in my case my service have credentials as well.
In my OData service, there are many entities and I want only some fields from the BTPROMO entity
Here is my OData metadata
There are some associations as well but I don't need anything from there
This is how easily I am able to see data for the required fields from my OData service in JSON format
Using the blog, I started creating my CAP model to consume this external service but that ends up in giving 400 error
my catalog.cds and catalog.js looks like this
This is my package.json
And this is my .cdsrc.json
when I try to run it, I am getting this error in the console, It is saying that a field Transaction_id is undefined, but I am not even asking for this field in my catalog.cds file, Also this field doesn't exist in the entity set BTPPROMO from which I need the data, This field is only available in the association as I mentioned below in the metadata screenshot
console main error looks like this
Full error log is here
user: sap-ibp-promotions $ cds watch
cds serve all --with-mocks --in-memory?
watching: cds,csn,csv,ts,mjs,cjs,js,json,properties,edmx,xml,env,css,gif,html,jpg,png,svg...
live reload enabled for browsers
_______________________
[cds] - model loaded from 2 file(s):
./srv/catalog-service.cds
./srv/external/SapIbp.csn
[cds] - connect using bindings from: { registry: '~/.cds-services.json' }
[cds] - connect to db > sqlite { database: ':memory:' }
[cds] - connect to SapIbp > odata-v2 {
url: 'https://<Host>:<Port>.ondemand.com/sap/opu/odata/IBP/PLANNING_DATA_API_SRV',
authentication: '...',
username: 'BTPUSER',
password: '...'
}
[cds] - serving CatalogService { at: '/catalog', impl: './srv/catalog-service.js' }
[cds] - server listening on { url: 'http://localhost:4004' }
[cds] - launched at 12/28/2021, 6:57:03 PM, in: 1.666s
[cds] - [ terminate with ^C ]
[cds] - GET /catalog/BTPPROMO
[remote] - Error: Error during request to remote service: Request failed with status code 400
at createError (/home/user/projects/sap-ibp-promotions/node_modules/axios/lib/core/createError.js:16:15)
at settle (/home/user/projects/sap-ibp-promotions/node_modules/axios/lib/core/settle.js:17:12)
at IncomingMessage.handleStreamEnd (/home/user/projects/sap-ibp-promotions/node_modules/axios/lib/adapters/http.js:269:11)
at IncomingMessage.emit (events.js:412:35)
at endReadableNT (internal/streams/readable.js:1317:12)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
config: {
url: "/commit?P_TransactionID='undefined'",
method: 'get',
proxy: false,
baseURL: 'https://<Host>:<Port>.ondemand.com/sap/opu/odata/IBP/PLANNING_DATA_API_SRV',
timeout: 60000,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
data: undefined
},
request: {
method: 'GET',
url: "https://<Host>:<Port>.ondemand.com/sap/opu/odata/IBP/PLANNING_DATA_API_SRV/commit?P_TransactionID='undefined'",
headers: {
Accept: 'application/json,text/plain',
authorization: 'Basic ...',
'accept-language': 'en',
'User-Agent': 'axios/0.21.4'
}
},
response: {
status: 400,
statusText: 'Bad Request',
headers: {
'set-cookie': [
'sap-usercontext=sap-client=100; path=/',
'SAP_SESSIONID_BBT_100=lOH6w615_CBUW_uXnXY6-_jctENoDxHsqP36Fj4KKec%3d; path=/; secure; HttpOnly'
],
'content-type': 'application/json;charset=utf-8',
'content-length': '1067',
dataserviceversion: '1.0',
'sap-server': 'true',
'sap-perf-fesrec': '139953.000000',
'x-content-type-options': 'nosniff',
'strict-transport-security': 'max-age=31536000; includeSubDomains',
'x-xss-protection': '1; mode=block'
},
body: {
error: {
code: '/IBP/EXTRACT_MSG/064',
message: {
lang: 'en',
value: 'Transaction ID undefined does not exist.'
},
innererror: {
application: {
component_id: 'SCM-IBP-INT-ODT',
service_namespace: '/IBP/',
service_id: 'PLANNING_DATA_API_SRV',
service_version: '0001'
},
transactionid: '3372965542570250E0061CB5B83B2307',
timestamp: '20211228185715.1964500',
Error_Resolution: {
SAP_Transaction: 'For backend administrators: use ADT feed reader "SAP Gateway Error Log" or run transaction /IWFND/ERROR_LOG on SAP Gateway hub system and search for entries with the timestamp above for more details',
SAP_Note: 'See SAP Note 1797736 for error analysis (https://service.sap.com/sap/support/notes/1797736)'
},
errordetails: [
{
ContentID: '',
code: '/IBP/CX_PLNG_DATA_DI_API',
message: 'Transaction ID undefined does not exist.',
propertyref: '',
severity: 'error',
transition: false,
target: ''
},
{
ContentID: '',
code: '/IWBEP/CX_MGW_BUSI_EXCEPTION',
message: 'Transaction ID BATCH_ID does not exist.',
propertyref: '',
severity: 'error',
transition: false,
target: ''
}
]
}
}
}
},
isAxiosError: true,
correlationId: '913962db-f86f-46ba-a246-69a3139da030'
}
[cds] - Error: Error during request to remote service: Request failed with status code 400
at run (/home/user/projects/sap-ibp-promotions/node_modules/@sap/cds/libx/_runtime/remote/utils/client.js:248:25)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async RemoteService.<anonymous> (/home/user/projects/sap-ibp-promotions/node_modules/@sap/cds/libx/_runtime/remote/Service.js:179:20)
at async next (/home/user/projects/sap-ibp-promotions/node_modules/@sap/cds/lib/serve/Service-dispatch.js:74:17)
at async RemoteService.handle (/home/user/projects/sap-ibp-promotions/node_modules/@sap/cds/lib/serve/Service-dispatch.js:72:10)
at async next (/home/user/projects/sap-ibp-promotions/node_modules/@sap/cds/lib/serve/Service-dispatch.js:74:17)
at async RemoteService.handle (/home/user/projects/sap-ibp-promotions/node_modules/@sap/cds/lib/serve/Service-dispatch.js:72:10)
at async RemoteService.commit (/home/user/projects/sap-ibp-promotions/node_modules/@sap/cds/lib/serve/Transaction.js:66:34)
at async ODataRequest.emit (/home/user/projects/sap-ibp-promotions/node_modules/@sap/cds/lib/req/context.js:55:9)
at async ApplicationService.commit (/home/user/projects/sap-ibp-promotions/node_modules/@sap/cds/lib/serve/Transaction.js:113:7) {
statusCode: 502,
innererror: Error: Error during request to remote service: Request failed with status code 400
at createError (/home/user/projects/sap-ibp-promotions/node_modules/axios/lib/core/createError.js:16:15)
at settle (/home/user/projects/sap-ibp-promotions/node_modules/axios/lib/core/settle.js:17:12)
at IncomingMessage.handleStreamEnd (/home/user/projects/sap-ibp-promotions/node_modules/axios/lib/adapters/http.js:269:11)
at IncomingMessage.emit (events.js:412:35)
at endReadableNT (internal/streams/readable.js:1317:12)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
config: {
url: "/commit?P_TransactionID='undefined'",
method: 'get',
proxy: false,
baseURL: 'https://<Host>:<Port>.ondemand.com/sap/opu/odata/IBP/PLANNING_DATA_API_SRV',
timeout: 60000,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
data: undefined
},
request: {
method: 'GET',
url: "https://<Host>:<Port>.ondemand.com/sap/opu/odata/IBP/PLANNING_DATA_API_SRV/commit?P_TransactionID='undefined'",
headers: {
Accept: 'application/json,text/plain',
authorization: 'Basic ...',
'accept-language': 'en',
'User-Agent': 'axios/0.21.4'
}
},
response: {
status: 400,
statusText: 'Bad Request',
headers: {
'set-cookie': [
'sap-usercontext=sap-client=100; path=/',
'SAP_SESSIONID_BBT_100=lOH6w615_CBUW_uXnXY6-_jctENoDxHsqP36Fj4KKec%3d; path=/; secure; HttpOnly'
],
'content-type': 'application/json;charset=utf-8',
'content-length': '1067',
dataserviceversion: '1.0',
'sap-server': 'true',
'sap-perf-fesrec': '139953.000000',
'x-content-type-options': 'nosniff',
'strict-transport-security': 'max-age=31536000; includeSubDomains',
'x-xss-protection': '1; mode=block'
},
body: {
error: {
code: '/IBP/EXTRACT_MSG/064',
message: {
lang: 'en',
value: 'Transaction ID undefined does not exist.'
},
innererror: {
application: {
component_id: 'SCM-IBP-INT-ODT',
service_namespace: '/IBP/',
service_id: 'PLANNING_DATA_API_SRV',
service_version: '0001'
},
transactionid: '3372965542570250E0061CB5B83B2307',
timestamp: '20211228185715.1964500',
Error_Resolution: {
SAP_Transaction: 'For backend administrators: use ADT feed reader "SAP Gateway Error Log" or run transaction /IWFND/ERROR_LOG on SAP Gateway hub system and search for entries with the timestamp above for more details',
SAP_Note: 'See SAP Note 1797736 for error analysis (https://service.sap.com/sap/support/notes/1797736)'
},
errordetails: [
{
ContentID: '',
code: '/IBP/CX_PLNG_DATA_DI_API',
message: 'Transaction ID undefined does not exist.',
propertyref: '',
severity: 'error',
transition: false,
target: ''
},
{
ContentID: '',
code: '/IWBEP/CX_MGW_BUSI_EXCEPTION',
message: 'Transaction ID BATCH_ID does not exist.',
propertyref: '',
severity: 'error',
transition: false,
target: ''
}
]
}
}
}
},
isAxiosError: true,
correlationId: '913962db-f86f-46ba-a246-69a3139da030'
},
id: '1442039',
level: 'ERROR',
timestamp: 1640717835239
}
I would highly appreciate if someone can suggest what could be the possible solution or workaround for this issue, In logs I can see its trying to fetch entities an services which I even not asked for.
Thanks for providing the metadata.
As assumed, there is a FunctionImport called commit.
<FunctionImport Name="commit" ReturnType="calcview.ValueResult" EntitySet="ValueResultSet" m:HttpMethod="GET">
<Parameter Name="P_TransactionID" Type="Edm.String" Mode="In"/>
This has nothing to do with your implementation or your use case. It's simply a gap in our implementation.
We'll see how we can provide a fix for this.
As a workaround, you can search for the function "commit" within your ".csn" file and remove it.
If that's done, it should work as expected.
Best regards,
Johannes
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi johannesvogel,
Thank you very much, Finally, your workaround helped me to fetch the data, I know it would make issues if I try to Post the data since I have removed the Commit function and I hope SAP will come up with any solution soon, But for time being I can provide something to the user.
many many thanks for all the help to both of you johannesvogel & gregorw
Kind Regards
Ahmed
Hi johannesvogel/ gregorw,
I am also adding some more fields into my cds service which are of "type": "cds.Decimal",
As soon I add them it gives me same error and if i remove them it works fine, Can you suggest some workaround, please.
From my .csn file the measure columns looks like this
"PRICE": {
"type": "cds.Decimal",
"precision": 18,
"scale": 6,
"@sap.aggregation.role": "measure",
"@sap.heading": "Price",
"@sap.label": "Price",
"@sap.quickinfo": "Price",
"@sap.creatable": "false",
"@sap.updatable": "false"
},
"PROMOPRICE": {
"type": "cds.Decimal",
"precision": 18,
"scale": 6,
"@sap.aggregation.role": "measure",
"@sap.heading": "Promotion Price",
"@sap.label": "Promotion Price",
"@sap.quickinfo": "Promotion Price",
"@sap.creatable": "false",
"@sap.updatable": "false"
},
Also, one confirmation "@sap.creatable": "false" and "@sap.updatable": "false" means i cannot do post and update operation on this, but I can read the data from them right?
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.