SAP HANA Cloud ODATA Service
SAP HANA Cloud ODATA Service
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
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
GRANT SELECT, SELECT METADATA ON SCHEMA DIS TO "<ApplicationName>_DIS::external_access_g" WITH GRANT OPTION;
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
Create “hdbview”
o In Search tool, type “>SAP HANA >SAP HANA Database Artifacts”
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"
]
}
}
}
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"
}
}
}
_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
{
"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"
]
}
]
}
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
** 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
i.e
Verify & Test Application deployment.
Navigate to “HANA DB” space “Applications” pallet option. Application is in started state.