cancel
Showing results for 
Search instead for 
Did you mean: 

Access virtual tables (HANA Smart Data Access) in my CAP project

iperez-sofos
Participant
0 Kudos

Greetings, community experts.

I have the following scenario, which is completely new to me (due to the combination of technologies it has):

I am working on a CAP application on SAP BTP, with the HANA Cloud database and SAP Fiori Elements (technologies that I am familiar with).

However, some of the data tables that my CAP application must use come from an external system, a SAP ECC system, connected to BTP via Cloud Connector, and using HANA Smart Data Access (SDA) to create virtual tables in HANA (duplicates of tables in SAP ECC).

This second one is a new scenario for me. In particular, what I need to know (and be able to do) is how to put those virtual tables inside my CAP application so I can use them to create views and define services?

For example, how do I put or introduce those virtual tables within the HDI Container and Schema of my application?
Is it necessary to do some kind of cross-container access configuration, using synonyms and others, as explained in this post (https://community.sap.com/t5/technology-blogs-by-members/how-to-share-tables-across-different-cap-pr...)?

I understand that I should use CDS annotations like @CDS.persistence.exists which prevent the creation of the corresponding objects in HANA, beyond that I know little.

Thank you in advance for any help and/or comments that may shed light on how to approach this scenario.

View Entire Topic
Willem_Pardaens
Product and Topic Expert
Product and Topic Expert

First question would be if you really want to use direct database tables from ECC, or whether it is possible to retrieve the required data from the application layer instead (gateway odata service)?

In case you want to use the virtual tables directly, then yes, it needs a specific configuration. Your CAP application can only access objects within the HDI container unless you create an explicit access to objects outside of that container. In short you will need to create a Grants file to specify the exact objects/tables the HDI application users should have access to, and then create a User Provided Service in BTP which provides the credentials of a HANA user who is able to grant that access. When your application is then deployed, the HDI application user will receive additional rights (grants), given (granted) by the user mentioned in the UPS.

A synonym is optional, depending on your configuration. If your virtual table has a prefix with underscore (eg. VT_MYTABLE) then in CAP you could define a service 'VT' with a projection 'MYTABLE' so that CAP would look for a view called 'VT_MYTABLE' in HANA. In case you want to use different names, or you use namespaces, or if anything prevents you from following the 'namespace_service_projection' naming, you can use a Synonym to map between the name CAP expects and the actual virtual table name.

Lastly, the '@cds.persistence.exists' is indeed required for every non-HDI object you define in your CDS (both the table structure as well as the projection view thereof) that should not be created when deploying the application.