cancel
Showing results for 
Search instead for 
Did you mean: 

How to generate OData V2 instead of OData V4 service for node?

flachlaender
Explorer
0 Kudos
1,613

I set up a small project using node.js in VSCode based on the bookshop tutorial and deployed it locally on sqlite which worked and I could acces the OData Service on my Host http://localhost:4004/catalog.

I tried then to create a FIORI Master-Detail Screen with the FIORI Template Wizard but I need an OData V2 service for using the wizard.

How can I change the serivice?

Accepted Solutions (0)

Answers (6)

Answers (6)

geert-janklaps
SAP Mentor
SAP Mentor

Hi,

You'll need to use the odata V2 adapter in your project. This is documented here: https://cap.cloud.sap/docs/advanced/odata#odata-v2-support

Best regards,

Geert-Jan Klaps

pfefferf
Active Contributor

Seems like you are using CAP. OData v2 support is described here.

Are you sure you want to use the free style Master Detail Template instead of a Fiori Elements List Report (which supports OData v4 and brings a lot more of advantages)?

flachlaender
Explorer
0 Kudos

Meanwhile its working. I need to install locally (without -g) and in the correct directory, I was outside of the directory when installing.

Thanks for the help.

Michael

flachlaender
Explorer
0 Kudos

8d8214c7f9734f45be69f95cc0d5aeee

I am not sure what about the filewatcher problem. I increased the number of watches just in case. The error message is now:

srv/index.js:

 const proxy = require('@sap/cds-odata-v2-adapter-proxy')
 const cds = require('@sap/cds')
 cds.on('bootstrap', app => app.use(proxy()))
 module.exports = cds.server
> cds watch
 
cds serve all --with-mocks --in-memory? 
( watching: cds,csn,csv,ts,mjs,cjs,js,json,properties,edmx,xml,env... with 200ms delay) 


[ERROR] Cannot find module '@sap/cds-odata-v2-adapter-proxy'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/home/michael/Developments/SAP/tutorial-my-bookshop/my-bookshop/srv/server.js:1:15)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)


I installed the npm module now without "-g"

geert-janklaps
SAP Mentor
SAP Mentor
0 Kudos

Hi,

Did you run the command in the root of your project? Looks like the dependency is still missing inside the project. Do you see the dependency inside the package.json file of your poject?

Best regards,

Geert-Jan Klaps

flachlaender
Explorer
0 Kudos

8d8214c7f9734f45be69f95cc0d5aeee

I tried to install the node.js moduel as mentiones, but is does not seem to work:

> sudo npm install -g  @sap/cds-odata-v2-adapter-proxy -s
> cds watch
 
cds serve all --with-mocks --in-memory? 
( watching: cds,csn,csv,ts,mjs,cjs,js,json,properties,edmx,xml,env... with 200ms delay) 
[ERROR] ENOSPC: System limit for number of file watchers reached, watch '/home/michael/Developments/SAP/tutorial-my-bookshop/Set Up and Generate a New SAP Fiori App Project/project1/node_modules/boxen/node_modules/emoji-regex/es2015'
    at FSWatcher.start (internal/fs/watchers.js:165:26)
    at Object.watch (fs.js:1258:11)
    at /usr/local/lib/node_modules/@sap/cds-dk/node_modules/node-watch/lib/watch.js:369:22
    at hasNativeRecursive (/usr/local/lib/node_modules/@sap/cds-dk/node_modules/node-watch/lib/has-native-recursive.js:61:12)
    at Watcher.watchDirectory (/usr/local/lib/node_modules/@sap/cds-dk/node_modules/node-watch/lib/watch.js:358:3)
    at /usr/local/lib/node_modules/@sap/cds-dk/node_modules/node-watch/lib/watch.js:384:14
    at /usr/local/lib/node_modules/@sap/cds-dk/node_modules/node-watch/lib/watch.js:151:35
    at Array.forEach (<anonymous>)
    at /usr/local/lib/node_modules/@sap/cds-dk/node_modules/node-watch/lib/watch.js:149:13
    at FSReqWrap.args [as oncomplete] (fs.js:140:20)




[cds] - my watch has ended.
geert-janklaps
SAP Mentor
SAP Mentor
0 Kudos

Hi,

You should install the proxy inside your project. With above command you've installed it globally, did you try installing it without the -g parameter inside your current project as mentioned in the documentation?

https://www.npmjs.com/package/@sap/cds-odata-v2-adapter-proxy

EDIT: might be OS related: https://www.codegrepper.com/code-examples/shell/System+limit+for+number+of+file+watchers+reached, (did you try rebooting?)

Best regards,

Geert-Jan

flachlaender
Explorer
0 Kudos

@Florian Pfeffer: I tried the Fiori Elemens List Report before this one but did not really get it working displaying data.