SAP-archive/com.sap.openSAP.hana5.example

$.hdb.getConnection() undefined

Closed this issue · 3 comments

Hello everyone,

Im facing several issues trying to follow some of tutorial instructions, the first one im facing is this:
1.- Create a template.
2.- Add a new NodeJS Module.
3.- In file called: server.js there're this lines:

try{
  options = Object.assing(options, xsenv.getServices({hana : {tag: "hana"}});
}catch(error){
 console.log("[WARN] : " + error.message);
}

I always got this: "[WARN] : No service matches hana"

Also, i have created this "CreateCountry" function (as tutorial said) in country.xsjs file:

function createCountry(country){
 var conn = $.hdb.getConnection();
 //.... truncated ....
}

And i got this error running Node Application (tinyjs):

"500 Cannot read property 'getConnection' of undefined"

Can someone please, give me a tip ?

If you have no service matches, then the resources definition in your mta.yaml is most likely incorrect. For the second item you mention tinyjs and createCountry. The TinyWorld tutorial is not part of this project. That's a completely separate tutorial.

Hi, Thanks for answer!
I know questions that i have posted, are related to another tutorial, and sorry about that, but i got no answer until now, for that reason, please, let me take this opportunity to ask you the issues that i have face on in different exercices.

I tried to create a node application from cli and then using xs following this documentation: https://help.sap.com/viewer/4505d0bdaf4948449b7f7379d24d0f0d/2.0.02/en-US/32392948cb1844b2a6ed22ad641d4461.html

I have installed node 8.0 in my rhel 7.5 server, now using npm i have installed @sap/xsenv adding a registry from this url: https://npm.sap.com

now, when i try to install xsjs i got several issues with make in the package of fibrous and package xsjs could not install...

Let me paste what i have:

manifest.yaml

application:

  • name: myapp
    path: myapp
    no-route: true
    services:
    • myhana

i have created the service using this line:

xs create-service hana hdi-shared myhana
using this:
xs s
i see this:
myhana hana hdi-shared

now, in the start.js

let xsenv = require('@sap/xsenv');
try{
    let services = xsenv.getServices({hana: {tag: "hana"}});
   /// also tried:  xsenv.getServices({hana: {tag: "myhana"}});
     console.log(services);
}catch(err){
 console.log("Error : " + err.message);
}

And i always got: "Error no service matches hana"


Now, from the tutorial TinyWorld
i have created everything, but with some issues, for example, in order to get sap.ui.table.Table works (show data), i had to run first tinyjs module.
Then, adding some functionality, in the tutorial steps, create a file called country.xsjs and from it add this code:


function createCountry(country){
   var conn = $.hdb.getConnection();
   var outrput = JSON.stringify(country);
   // truncated...
}

Once, running tinyjs application, i got "500 Cannot read property 'getConnection' of undefined"
So, do i need another package in order to get $.hdb , if that so, then what package?
Also, following the documentation tutorial: https://help.sap.com/viewer/4505d0bdaf4948449b7f7379d24d0f0d/2.0.02/en-US/2d970b65462c4ff3bc674f2ddbd5da9f.html

Im sorry for asking you non-related issues, but as i said above, i got no answers from anywhere until now.

I'm sorry but this isn't the appropriate place for your questions. They aren't even related to this project nor are they about a tutorial I created or own.