cancel
Showing results for 
Search instead for 
Did you mean: 

Using Native SAP HANA Artifacts in my Business Application built using CAP model

vishali3
Explorer
0 Kudos

Hi,

I am trying to use my SAP HANA Table in my CDS Model.

I followed this blog (https://blogs.sap.com/2018/03/09/hana-calculation-view-modeling-on-sap-cloud-platform/) to create an SAP HANA Table and calculation View. I would like to use that Table in my CAP Business application..

This is my .hdbcds file that I would like to use in my CAP Application:

Below is my data-model.cds:

When I run the SRV module and open the " {service url} /Sales" , I get this error:

[2020-01-19T18:46:00.594Z | ERROR | 1133960]: invalid table name: Could not find table/view CATALOGSERVICE_SALES in schema ASAMPLE_NODEJSVERSION_ASAMPLE_NODEJSVERSION_DB_HDI_CONTAINER_1: line 1 col 60 (at pos 59).

I am not sure on how to link the existing table to my CAP Business application and also I am not sure if my data-model.cds is defined correctly.

Any pointers or suggestions / example code snippets would be helpful on this topic.

Thanks and Regards,

Vishali

Accepted Solutions (1)

Accepted Solutions (1)

gregorw
Active Contributor

Hi Vishali,

please check out the documentation at: Using Native SAP HANA Artifacts. You have to create a View to interface with the existing table to match the namespace.

Best regards
Gregor

vishali3
Explorer
0 Kudos

Hi Gregor,

Thanks for the input. Following that document, I am able to use the existing table (present in the same Database under the same project name) in my CDS Model.

How do I use my native HANA table (present in the database of a project 'A') in the CDS Model of Project 'B'.

I want to perform CRUD on a table in the database that is different from my CAP Business Application's database - Is that supported by CAP?

If yes, any links/ code snippets that says how to link the databases with my CAP project.

Note that the workspace of both the projects is the same.

(Sorry, I forgot to mention this point in my question - that I want to use the Table from a Database other than my CAP business application)

Thanks and regards,

Vishali

vansyckel
Advisor
Advisor
0 Kudos

Hi Vishali,

You can import definitions via the "using" directive. Please see https://cap.cloud.sap/docs/cds/cdl#using

Best,
Sebastian

vishali3
Explorer
0 Kudos

Hi Sebastian,

Thanks for the reply.

I was getting "this package not found at ... location" kind of errors. I referred many other blogs and tried to import my table using the "using" directive and failed.

1.This is my Sales table definition in "Sales.hdbcds" (path : "XSA_Trial1/db/src/Sales.hdbcds" )

namespace my.sale;
context sales1 {
    entity Sales {
        key Customer_id : String(10);
            Region      : String(10);
            Year        : String(4);
            Revenue     : Integer;
    };
};

Can you give me some example/code snippet regarding how I can import the Table into my CAP project?

Do I have to add any resource location / dependency in my mta.yaml or package.json file to import the table?

Thanks and regards,

Vishali

gregorw
Active Contributor

Hi Vishali,

to access data from a different HDI container you have to use Synonyms in your own HDI container. Check out my project https://github.com/gregorwolf/access-hdi-with-synonyms where I've accessed the project https://github.com/gregorwolf/hdiWithoutXSA using synonyms.

Best regards
Gregor

0 Kudos

Hi gregor,

I have referred your git code but in your case, source HDI container is having Plain SQL mapping so table name is in CAPs without :: whereas, in my case native hana is having table name with hdbcds syntax and i am trying to fetch same in my new container where syntax is plain.

can you suggest how to access the table in this case from different hdi container

Regards

Nelson

Answers (0)