0% found this document useful (0 votes)
12 views15 pages

SAP HANA Cloud ODATA Service

This document provides a comprehensive guide for exposing On-Premises MSSQL Database Tables/views as OData Services in SAP HANA Cloud using the Cloud Application Programming (CAP) model. It outlines prerequisites, detailed implementation steps including setting up remote sources, creating database roles, virtual objects, and CAP applications, as well as deployment processes. The document also includes instructions for configuring necessary files and verifying the application deployment.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views15 pages

SAP HANA Cloud ODATA Service

This document provides a comprehensive guide for exposing On-Premises MSSQL Database Tables/views as OData Services in SAP HANA Cloud using the Cloud Application Programming (CAP) model. It outlines prerequisites, detailed implementation steps including setting up remote sources, creating database roles, virtual objects, and CAP applications, as well as deployment processes. The document also includes instructions for configuring necessary files and verifying the application deployment.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Contents

Overview...............................................................................................................................................2
Prerequisite:..........................................................................................................................................2
Implementation Steps:......................................................................................................................2
Set up Remote Source:..................................................................................................................2
Create Database role and assign to service user........................................................................3
Create Virtual Object.....................................................................................................................3
Create CAP Application..................................................................................................................4
Create CAP Project.....................................................................................................................4
Create ‘db’ artifacts....................................................................................................................4
Create “hdbsynonym”............................................................................................................4
Create “hdbview”..................................................................................................................5
Create “hdbgrants”................................................................................................................5
Create entity using “hdbview”...............................................................................................6
Create ‘srv’ artifacts...................................................................................................................6
Check “package.json” file...........................................................................................................7
Check and update “MTA.yml” file.............................................................................................8
Create XSUAA definition..........................................................................................................10
Install npm module..................................................................................................................11
Compile CDS............................................................................................................................11
Build MTAR..............................................................................................................................12
Deploy MTAR...........................................................................................................................13
Assign Role Collection to user..................................................................................................13
Verify & Test Application deployment......................................................................................14

Created By Mayank Dubey


Created Date 2023-07-24
Draft Version 1.0
Overview
This documentation draft covering details to expose On-Premises MSSQL Database Table/views as OData
Service in SAP HANA cloud using CAP (Cloud Application Programming).

Prerequisite:
 SAP HANA Cloud Instance
o SAP HANA SERVICE USER i.e DIS_SERVICE
 SDI Agent 2.0
 Business Application Studio Environment
 MSSQL Server Connectivity Details
o SQL Server User Credentials
o SQL server authorization to MSSQL database objects i.e Table/view

Implementation Steps:
Set up Remote Source:
 Open Database Explore (“https://hana-cockpit.cfapps.us21.hana.ondemand.com/hrtt/sap/hana/cst/
catalog/cockpit-index.html?databaseid=C219119”)
 Create Remote Source with below details.
o Adapter Type: MssqlLogReaderAdapter
o Database Server: <MS SQL Server >
o Port Number: <MS SQL Server Port>
o Technical User:
 Username: <MS SQL Server username>
 Password: <MS SQL Server password>
 This is minimal configuration to create Remote. Refer below link to get more insights for all
properties options.
o https://help.sap.com/docs/HANA_SMART_DATA_INTEGRATION/
cc7ebd3f344a4cdda20966a7617f52d8/14a89905349146cf96dfe9ad651aba33.html

 After successful connection, all authorized objects can be accessed.


Create Database role and assign to service user.
 Run below commands to create database roles and assign to service user
** Make sure replacing <ApplicationName> placeholder with your actual application name before running this script

CREATE ROLE "<ApplicationName>_DIS::external_access_g";

CREATE ROLE "<ApplicationName>_DIS::external_access";

GRANT "<ApplicationName>__DIS::external_access_g", "<ApplicationName>_DIS::external_access" TO DIS_SERVICE WITH


ADMIN OPTION;

GRANT SELECT, SELECT METADATA ON SCHEMA DIS TO "<ApplicationName>_DIS::external_access_g" WITH GRANT OPTION;

GRANT SELECT, SELECT METADATA ON SCHEMA DIS TO "<ApplicationName>_DIS:external_access";

 These roles will be used in next step Create “hdbgrants”

Create Virtual Object


1. Select object for which virtual object to be created
2. Select “Create Virtual Object”
a) Select “Create Virtual Object”
b) Enter Virtual Object Name and select schema.

3. Once virtual object created, you can access it catalog under schema where it’s created.
Create CAP Application
Create CAP Project
 Create CAP Multitarget Application

 Fill in details and choose below selected options. Select “Finish”

 Check and review Project structure created as below.


1. app - Folder structure contains app router artifacts.
2. db - Folder structure contains database artifacts.
3. srv – Folder structure contains service-related artifacts.
4. mta.yml – MTA development descriptor builder tool to generate deployment
descriptor
5. package.json - Projects using CAP need to manage dependencies to the respective
tools and libraries in their package.json

Create ‘db’ artifacts


Create “hdbsynonym”
o In Search tool, type “>SAP HANA >SAP HANA Database Artifact”
o Define “Synonym Name” and Object Name (For which we creating synonym)

Create “hdbview”
o In Search tool, type “>SAP HANA >SAP HANA Database Artifacts”

o Define view name using synonym created in previous step.

Create “hdbgrants”
o In Search tool, type “>SAP HANA >SAP HANA Database Artifact
o Define “hdbgrants” name using synonym created in previous step.
 These grants will be used by HDI container to access virtual object with assigned
roles.

{
"<ApplicationName>-db-DIS": {
"object_owner": {
"roles": [
"<ApplicationName>_DIS::external_access_g"
]
},
"application_user": {
"roles": [
"<ApplicationName>_DIS::external_access"
]
}
}
}

o Make sure these roles should be created in HANA DB

Create entity using “hdbview”


o This entity will be used in service layer.
o User @cds.persistence.exists to define this is existing object and deployment module will not
try to create one and use existing

Create ‘srv’ artifacts


Create service definition using entity we created in db artifact.

 Define grant option based on OData behaviour, below is showing read and write
 Attribute “requires :’’authenticated-user” defines service will allow only authenticates user
**Make sure below snippet should be corrected as per requirement if OData service requires read only then only grant read ,
adjust it as per requirement
Check “package.json” file
 Default package.json file will be as follows.

{
"name": "<ApplicationName>",
"version": "1.0.0",
"description": "A simple CAP project.",
"repository": "<Add your repository here>",
"license": "UNLICENSED",
"private": true,
"dependencies": {
"@sap/cds": "^6",
"express": "^4",
"hdb": "^0.19.0"
},
"devDependencies": {
"sqlite3": "^5"
},
"scripts": {
"start": "cds-serve"
},
"cds": {
"requires": {
"db": "hana-cloud"
}
}
}
 Replace with below content.
{
"name": "<Application Name>",
"version": "1.0.0",
"engines": {
"node": "14.x"
},
"dependencies": {
"@sap/audit-logging": "^5",
"@sap/cds-odata-v2-adapter-proxy": "^1",
"@sap/cds": "^6",
"@sap/xsenv": "^3",
"@sap/xssec": "^3",
"express": "^4",
"hdb": "^0.19.0",
"package.json": "^2.0.1",
"passport": "^0.4.1"
},
"scripts": {
"start": "npx cds run"
},
"cds": {
"requires": {
"db": {
"kind": "sql"
},
"uaa": {
"kind": "xsuaa"
}
},
"hana": {
"deploy-format": "hdbtable"
}
}
}

Check and update “MTA.yml” file


 Update default mta.yml . Replace “<ApplicationName>” with your application name

_schema-version: '3.1'
ID: <Application Name>
version: 1.0.0
description: "A simple CAP project."
parameters:
enable-parallel-deployments: true
build-parameters:
before-all:
- builder: custom
commands:
- npx -p @sap/cds-dk cds build --production
modules:
- name: <ApplicationName>-srv
type: nodejs
path: gen/srv
parameters:
memory: 256M
disk-quota: 512M
buildpack: nodejs_buildpack
build-parameters:
builder: npm-ci
provides:
- name: srv-api # required by consumers of CAP services (e.g. approuter)
properties:
srv-url: ${default-url}
requires:
- name: <ApplicationName>-db
- name: <ApplicationName>-uaa

- name: <ApplicationName>-db-deployer
type: hdb
path: gen/db
parameters:
memory: 256M
disk-quota: 512M
buildpack: nodejs_buildpack
requires:
- name: <ApplicationName>-db
- name: <ApplicationName>-db-DIS

- name: <ApplicationName>-app
type: html5
path: app
parameters:
memory: 256M
disk-quota: 512M
requires:
- name: <ApplicationName>-uaa
- name: srv-api
group: destinations
properties:
name: srv
url: ~{srv-url}
forwardAuthToken: true

resources:
- name: <ApplicationName>-uaa
type: org.cloudfoundry.managed-service
parameters:
path: ./xs-security.json
service-plan: application
service: xsuaa
- name: <ApplicationName>-db
type: com.sap.xs.hdi-container
parameters:
service: hana
service-plan: hdi-shared
config:
database_id: '4a90a06d-90d8-41a0-90b6-64a2dc5c1273'
properties:
hdi-service-name: ${service-name}
- name: <ApplicationName>-db-DIS
type: org.cloudfoundry.existing-service
parameters:
service-name: <ApplicationName>-db-DIS

Create XSUAA definition


 Run command “cds add xsuaa --for production” which will add XSUAA modules
 Update “xs-security.json” with below content by replacing <ApplicationName> with your application
name
**Make sure below snippet should be corrected as per requirement if OData service requires read only then only create read role,
adjust it as per requirement

{
"xsappname": "<ApplicationName>",
"tenant-mode": "dedicated",
"scopes": [
{
"name": "$XSAPPNAME.write",
"description": "write access"
},
{
"name": "$XSAPPNAME.read",
"description": "read access"
}
],
"attributes": [],
"role-templates": [
{
"name": "write",
"description": "write access",
"scope-references": [
"$XSAPPNAME.write"
],
"attribute-references": []
},
{
"name": "read",
"description": "read access",
"scope-references": [
"$XSAPPNAME.read"
],
"attribute-references": []
}
],
"role-collections": [
{
"name": "<ApplicationName>_write",
"description": "Write Access",
"role-template-references": [
"$XSAPPNAME.write",
"$XSAPPNAME.read"
]
},
{
"name": "<ApplicationName>_read",
"description": "Read Access",
"role-template-references": [
"$XSAPPNAME.read"
]
}
]
}

Install npm module


 Run command “npm -I install” to install all dependency npm modules

Compile CDS
 Run command “cds build/all --clean” to build cds objects
 Expand and see artifacts details in SAP HANA Projects to check compiled artifacts.

Build MTAR
Run command “mbt build -t mta_archives --mtar <ApplicationName>_<VersionNumber>.mtar” to build
MTAR

o i.e - mbt build -t mta_archives --mtar IPG_EAI_GeoLocation_1.0.0.mtar

** you can choose another folder if you want as well other than default “mta_archives”

OR

 Right click on “mta.yaml” and select “Build MTA Project” which will generate mtar file in
“mta_archives”

o
 Verify mtar file should be generated at default project directory “mta_archive”

Deploy MTAR
 Run command “cf deploy mta_archives/<ApplicationName>_<Version>.mtar” to deploy MTAR
o i.e - cf deploy mta_archives/IPG_EAI_GeoLocation_1.0.0.mtar

Assign Role Collection to user.


 Assign below role collection to user account defined as part of “Create XSUAA definition” step.
**Make sure below snippet should be corrected as per requirement if OData service requires read only then only assign read role,
adjust it as per requirement

i.e
Verify & Test Application deployment.
 Navigate to “HANA DB” space “Applications” pallet option. Application is in started state.

 Click on “<ApplicationName>-app” router service and verify service state as follows


o Click on Application Route

o Check service definition.

o Verify OData service.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy