Managing Modeling Objects via the Command Line
You can use the datasphere command line interface to list, read, create, update, and delete modeling objects. You can also organize objects in folders and manage sharing and metadata translation from the command line.
Prerequisites
-
Data Warehouse General (-R------) - To access SAP Datasphere.
-
Space Files (CRUD----) - To create, read, update, and delete objects in your spaces.
-
Data Warehouse Data Builder (CRUD--S-) - To create, edit and delete Data Builder objects.
-
Data Warehouse Data Access Control (CRUD----) - To create, edit and delete these objects.
-
Data Warehouse Business Builder (CRUD----) - To create, edit and delete Business Builder objects.
-
Data Warehouse Business Entity (CRUD----) - To create, edit and delete these objects.
-
Data Warehouse Fact Model (CRUD----) - To create, edit and delete these objects.
-
Data Warehouse Consumption Model (CRUD----) - To create, edit and delete these objects.
-
Data Warehouse Authorization Scenario (CRUD----) - To create, edit and delete these objects.
-
Install the datasphere command line interface (see Install or Update the SAP Datasphere Command Line Interface).
-
Log in to your SAP Datasphere tenant (see Log into the Command Line Interface via an OAuth Client).
datasphere objects <object-type>The following object types are available:
|
Object Type |
Object Documentation |
|---|---|
|
remote-tables |
|
|
local-tables |
|
|
views |
|
|
intelligent-lookups |
|
|
er-models |
|
|
types contexts |
These objects cannot be created manually in SAP Datasphere, but may be imported as necessary along with remote tables or content packages. |
|
data-flows |
|
|
replication-flows |
|
|
transformation-flows |
|
|
task-chains |
|
|
analytic-models |
|
|
business-entities |
|
|
fact-models |
|
|
consumption-models |
|
|
data-access-controls |
|
|
folders |
|
|
packages |
List Objects in a Space
You can list all the objects of a particular type in a space and optionally write the output to a file.
datasphere objects <object-type> list
--space <id>
[--technical-names <name>[,...]]
[--output <file>.json]
[--select "<property[,...]>"]
[--filter "<property operator value>[ and|or ...]"]
[--top <n>]
[--skip <n>]
|
Parameter |
Description |
|---|---|
|
--space <id> |
Enter the Space ID of the space. |
|
--technical-names <name>[,...] |
[optional] Specify the objects to include in your list by technical name, separated by commas. |
|
--output <file>.json |
[optional] Enter a path to a .json file to write the output to. If you do not include this option, the output will be printed to the command line. |
|
--select "<property>[,...]" |
[optional] Specify the properties to include in your list, separated by commas, from among the following:
Default: technicalName |
|
--filter "<property operator value>[ and|or ...]" |
[optional] Specify a filter condition using the standard OData filter syntax. You can use the following comparison operators:
Dates must be entered in the format 'YYYY-MM-DD'. You can combine filter conditions using the and and or keywords and control priority by grouping conditions with parentheses.
For example, to list only objects that were deployed after 31 December 2022, and have a semantic usage of Fact or Dimension, enter
--filter "deployedOn gt '2022-12-31' and (semanticUsage eq Fact or semanticUsage eq Dimension)" |
|
--top <n> |
[optional] List only the first <n> objects, up to a maximum of 200. Default: 25 |
|
--skip <n> |
[optional] Skip the first <n> objects. |
datasphere objects views list --space MySpace --select "technicalName,businessName,semanticUsage,status" --output MySpaceViews.json
|
Property |
Description |
|---|---|
|
technicalName businessName |
Enter an object name. You must use single or double quotes if the name contains spaces.
For example, to list only the objects with technical name Table_1 and Table_2, enter:
--filter "technicalName eq Table_1 or technicalName eq Table_2" |
|
type |
Enter a valid object type:
For example, to list only views, enter:
--filter "type eq View" |
|
semanticUsage |
Enter a valid semantic usage:
For example, to list only objects with a semantic usage of Dimension, enter:
--filter "semanticUsage eq Dimension" |
|
status |
Enter a valid status:
For example, to list only objects with a status of Deployed, enter:
--filter "status eq Deployed" |
|
createdOn changedOn deployedOn |
Enter a date in the format 'YYYY-MM-DD'.
For example, to list only objects deployed after 31 December 2022, enter:
--filter "deployedOn gt '2022-12-31'" |
|
createdBy changedBy |
Enter a valid username.
For example, to list only objects last changed by Lisa, enter:
--filter "changedBy eq Lisa" |
Read Objects
You can read the CSN/JSON definition of an object and optionally write it to a file.
datasphere objects <object-type> read
--space <id>
--technical-name <name>
[--output <file>.json]
[--accept <format>]
|
Parameter |
Description |
|---|---|
|
--space <id> |
Enter the Space ID of the space. |
|
--technical-name <name> |
Enter the Technical Name of the object. |
|
--output <file>.json |
[optional] Enter a path to a .json file to write the output to. Enter the option without any value (--output) to write the output to a file with the defaultFileName for the object. If you do not include this option, the output will be printed to the command line. |
|
--accept <format> |
[optional] Specify the format to return the object definition in. You can choose between:
|
datasphere objects remote-tables read --space MySpace --technical-name MyTable --output
Create Objects
datasphere objects <object-type> create
--space <id>
--technical-name <name>
--file-path <name>.json|--input '<stringified-json>'
[--custom-validation-options <option[,option]>] [--save-anyway]
[--no-deploy]
|
Parameter |
Description |
|---|---|
|
--space <id> |
Enter the Space ID of the space. |
|
--technical-name <name> |
Enter the Technical Name of the object. |
|
--file-path <name> |
[optional] Enter a path to a file with a .json extension containing your object definition. |
|
--input '<stringified-json>' |
[optional] Provide your definition in stringified json format instead of via the --file-path option.
For example, to create a simple table, T1 in MySpace, you could enter:
datasphere objects local-tables create --space MySpace --technical-name T1 --input '{"definitions":{"T1":{"kind":"entity","@EndUserText.label":"T1","@ObjectModel.modelingPattern":{"#":"DATA_STRUCTURE"},"@ObjectModel.supportedCapabilities":[{"#":"DATA_STRUCTURE"}],"elements":{"ID":{"@EndUserText.label":"ID","type":"cds.String","length":100,"key":true,"notNull":true},"Name":{"@EndUserText.label":"Name","type":"cds.String","length":100}}}}}'
|
|
--custom-validation-options <option[,option]> |
[optional] Provide a comma-separated list of custom validation options:
|
|
--save-anyway |
[optional] Save the object, even if there are validation warnings. |
|
--no-deploy |
[optional] Do not deploy the object after saving. |
datasphere objects local-tables create --space MySpace --technical-name MyTable --file-path MyTableDefn.json
Update Objects
datasphere objects <object-type> update
--space <id>
--technical-name <name>
--file-path <name>.json|--input '<stringified-json>'
[--custom-validation-options <option[,option]>]
[--save-anyway]
[--no-deploy]
|
Parameter |
Description |
|---|---|
|
--space <id> |
Enter the Space ID of the space. |
|
--technical-name <name> |
Enter the Technical Name of the object. |
|
--file-path <name> |
[optional] Enter a path to a file with a .json extension containing your object definition. |
|
--input '<stringified-json>' |
[optional] Provide your definition in stringified json format instead of via the --file-path option.
For example, to create a simple table, T1 in MySpace, you could enter:
datasphere objects local-tables create --space MySpace --technical-name T1 --input '{"definitions":{"T1":{"kind":"entity","@EndUserText.label":"T1","@ObjectModel.modelingPattern":{"#":"DATA_STRUCTURE"},"@ObjectModel.supportedCapabilities":[{"#":"DATA_STRUCTURE"}],"elements":{"ID":{"@EndUserText.label":"ID","type":"cds.String","length":100,"key":true,"notNull":true},"Name":{"@EndUserText.label":"Name","type":"cds.String","length":100}}}}}'
|
|
--custom-validation-options <option[,option]> |
[optional] Provide a comma-separated list of custom validation options:
|
|
--save-anyway |
[optional] Save the object, even if there are validation warnings. |
|
--no-deploy |
[optional] Do not deploy the object after saving. |
datasphere objects local-tables update --space MySpace --technical-name MyTable --file-path MyTableDefn.json
Organize Objects In Folders
You can create folders in the same way as any other object (see Create Objects), and then move objects into those folders to organize them.
datasphere objects folders create --space MySpace --technical-name Folder_PROJECTA --input '{"Folder_PROJECTA": {"_kind": "sap.repo.folder","_folderProperties": {"name": "Project A"}}}'
And then enter:
datasphere objects folders create --space MySpace --technical-name Folder_INBOUNDX --input '{"Folder_INBOUNDX": {"_kind": "sap.repo.folder","_folderProperties": {"name": "Inbound","parent": "Folder_PROJECTA"}}}'
datasphere objects <object-type> move-to-folder
--space <id>
--technical-name <name>
--folder <folder-technical-name>
|
Parameter |
Description |
|---|---|
|
--space <id> |
Enter the Space ID of the space. |
|
--technical-name <name> |
Enter the Technical Name of the object. |
|
--folder <folder-technical-name> |
Enter the Technical Name of the target folder. To move the object to the space root, leave the value empty. |
datasphere objects remote-tables move-to-folder --space MySpace --technical-name MyTable --folder Folder_INBOUNDX
Delete Objects
You can delete an object.
datasphere objects <object-type> delete
--space <id>
--technical-name <name>
[--delete-anyway]
[--force]
|
Parameter |
Description |
|---|---|
|
--space <id> |
Enter the Space ID of the space. |
|
--technical-name <name> |
Enter the Technical Name of the object. |
|
--delete-anyway |
[optional] Delete the object, even if other objects depend on it. |
|
--force |
[optional] Suppress the Confirm Deletion dialog and delete the object without confirmation. |
datasphere objects local-tables delete --space MySpace --technical-name MyTable --force
Object Dependencies
When creating (see Create Objects) or updating (Update Objects) objects, any sources or other objects that your object depends on must already be present in the space, or your action will fail.
|
Object Type |
Dependencies |
|---|---|
|
Remote Tables See Import Remote Tables. |
A remote table depends on its connection. |
|
Local Tables |
A local table without delta capture does not have dependencies on any other objects. For local tables with delta capture enabled, you must use the --accept option when reading the object, in order to obtain all the delta capture objects in the output file: datasphere objects local-tables read --space MySpace --technical-name MyDeltaTable --accept application/vnd.sap.datasphere.object.content.design-time+json --output MyDeltaTable.json The file created can then be written back into a space in the normal way: datasphere objects local-tables create --space MySpace2 --technical-name MyDeltaTable --file-path MyDeltaTable.json |
|
Flows See Creating a Data Flow, Creating a Replication Flow, and Creating a Transformation Flow. |
A data flow, replication flow, or transformation flow depends on all its sources and its target tables. |
|
Views |
A view depends on all its sources and any used data access controls. |
|
Intelligent Lookups |
An intelligent lookup depends on its input and lookup entities. |
|
Analytic Models |
An analytic model depends on its fact and dimension sources. |
|
E/R Models |
An E/R model depends on the objects that it visualizes. |
|
Data Access Controls |
The definition of a data access control contains the definition of its permissions entity. When you export a data access control, the permissions entity is exported too. |
|
Task Chains |
A task chain depends on the objects that it automates. |
|
Business Entities / Business Entity Versions |
A business entity depends on its source data entity and any authorization scenarios. |
|
Fact Models |
A fact model depends on all its source fact models and business entities. |
|
Consumption Models |
A consumption model depends on all its source fact models and business entities. |
|
Authorization Scenarios |
An authorization scenario depends on its data access control. |
|
Packages |
A package depends on all its required packages and the objects it contains. |
Object Definition Syntax
|
Section |
Description |
|---|---|
|
definitions |
Contains the structure and core metadata of the object. |
|
editorSettings |
Contains information about the editor associated with the object including, in the case of graphical objects, a serialization of the diagram. |
|
sharing |
[tables and views] Contains a list of the spaces to which the object is shared (see Share Objects to Other Spaces). |
|
i18n |
Contains translations of metadata grouped by language (see Translate Model, Entity, and Column Names). |
Share Objects to Other Spaces
Local tables, remote tables, and views can be shared from their space to other spaces, in which they can be used as sources for flows and views (see Sharing Entities and Task Chains to Other Spaces).
The sharing section lists the spaces to which the entity is shared. You can modify this section to add or remove spaces to which the table or viewed is shared.
"sharing": {
"LocalTable":[
"targetSpaces": [
"SALES_EU",
"SALES_US"
]
]
}
Translate Model, Entity, and Column Names
Business names in your exposed objects can be translated to support display languages in SAP Analytics Cloud (see Translating Metadata for SAP Analytics Cloud).
The i18n section contains translations of the model or entity business name, and the business names of its measures and attributes, grouped by language. You can modify this section to edit translations, or add or remove languages and their translations.
"i18n": {
"en":[
"LocalTable@ENDUSERTEXT.LABEL": "Departments",
"LocalTable#ID@ENDUSERTEXT.LABEL": "Department ID",
"LocalTable#ID@ENDUSERTEXT.LABEL": "Department Name"
],
"fr":[
"LocalTable@ENDUSERTEXT.LABEL": "Départements",
"LocalTable#ID@ENDUSERTEXT.LABEL": "Numéro de département",
"LocalTable#ID@ENDUSERTEXT.LABEL": "Nom du département"
]
}
Modify Generated Objects
-
Time Dimensions - You can only modify business names and values in the timesettings section. See Create Time Data and Dimensions.
-
Currency Conversion Objects - Only modifications to the business names of these objects are supported. See Enabling Currency Conversion with TCUR* Tables and Views.