api/v1/dataimport

The Data Import Service is an open API that allows you to import data to SAP Analytics Cloud.

The service offers a PUSH based API that helps importing planning data to SAP Analytics Cloud and enable data integration from SAP Analytics Cloud to SAP Datasphere, SAP BW/4 HANA, SAP S/4 HANA and other third-party tools.

The API is comprised of multiple services:
  • The Models service extracts list of models and their metadata on your SAP Analytics Cloud system

  • The PublicDimensions service exposes the catalog of public dimensions and their associated metadata on your SAP Analytics Cloud system.

  • The CurrencyConversions service is responsible for accessing SAP Analytics Cloud currency tables and retrieve their associated metadata. Similarly to models, each currency conversion table contains an ID, a name, a description and an URL.

  • The UnitConversions service exposes the standard unit conversion tables for import on your SAP Analytics Cloud system, as well as each of the table’s associated metadata.

  • The Jobs service runs import jobs to feed data to SAP Analytics Cloud.

  • The Import service is a synchronous import functionality that pushes fact and master data to your SAP Analytics Cloud models.

The API supports all standard OData parameters, as well as custom parameters.

Prerequisites

  • You must have a SAP Analytics Cloud tenant URL.

  • You must have a SAP Analytics Cloud user.

  • You must have an SAP Analytics Cloud for planning, predictive standard edition or SAP Analytics Cloud for planning, predictive professional edition license.

  • You must configure OAuth to work with your application. The Data Import Service supports three OAuth authentication flows:
    • OAuth 2.0 Client Credentials (2-legged OAuth) – This workflow allows administrators to access and import all data to any given models in machine-to-machine scenarios for example.

    • OAuth 2.0 SAML Bearer Assertion (2-legged OAuth) - This workflow allows administrators to access and export all data from any given models in machine-to-machine scenarios for example.

    • OAuth 2.0 Authorization Code Grant (3-legged OAuth) - This workflow allows business users to import smaller subsets of data while leveraging roles and data access privileges to ensure that they can only access data they have privileges for, at a model level.

    For more information, see Setting Up Authentication.
  • You must set up your OAuth Client to work with the Data Import Service.

Licenses

The Data Import Service requires different licenses depending on the action you want to perform and endpoints you want to access.

License Requirements

Action

SAP Analytics Cloud for business intelligence, predictive edition

SAP Analytics Cloud for planning, predictive standard edition

SAP Analytics Cloud for planning, predictive professional edition

Create Tokens

2 – legged token

x

x

x

3 – legged token

x

x

x

Models

/models (GET)

x

x

x

/models/{modelID} (GET)

x

x

x

/models/{modelID} (POST)

x

x

/models/{modelID}/metadata (GET)

x

x

x

/models/{modelID}/{ImportType} (POST)

x

x

Currency Conversion

/currencyConversions (GET)

x

x

x

/currencyConversions/{currencyConversionID} (GET)

x

x

x

/currencyConversions/{currencyConversionID} (POST)

x

x

x

/currencyConversions/{currencyConversionID}/metadata (GET)

x

x

x

/currencyConversions/{currencyConversionID}/{importType} (POST)

x

x

x

Public Dimensions

/publicDimensions (GET)

x

x

x

/publicDimensions/{publicDimensionID} (GET)

x

x

x

/publicDimensions/{publicDimensionsID}/metadata (GET)

x

x

x

/publicDimensions/{publicDimensionID}/{ImportType} (POST)

x

x

x

Unit Conversion

/unitConversions (GET)

x

x

x

/unitConversions/{unitConversionID} (GET)

x

x

x

/unitConversions/{unitConversionID} (POST)

x

x

x

/unitConversions/{unitConversionID}/metadata (GET)

x

x

/unitConversions/{unitConversionID}/{importType} (POST)

x

x

Jobs

/jobs (GET)

x

x

x

/jobs/{jobID} (POST)

x

x

/jobs/{jobID} (DELETE)

x

x

/jobs/{jobID}/validate (POST)

x

x

/jobs/{jobID}/run (POST)

x

x

/jobs/{jobID}/invalidRows (GET)

x

x

/jobs/{jobID}/status (GET)

x

x

x

Import

/import/{modelID} (POST - CSV)

x

x

/import/{modelID}/{importType} (POST - JSON)

x

x

Job Lifecycle and Retention Policy

An import job goes through several states during its lifecycle:

  • READY_FOR_DATA: The job has been created successfully, and you can now post data to it via the post data endpoint.

  • READY_FOR_VALIDATION: Data has been posted to the job. You can post more data to the job, validate it with the validation endpoint, or perform both validation and execution in one step by using the run endpoint.

  • READY_FOR_WRITE: Data in the job has been validated. You can still post more data to the job or execute it with the run endpoint.

  • PROCESSING: The job has been executed with the run endpoint, and the import is happening in the backend. Once completed the state will change to COMPLETED.

  • COMPLETED: The import job has been completed, and any valid rows have been imported to the SAP Analytics Cloud model.

  • FAILED: There was an error with the job and the import could not be completed.

The Data Import Service has a retention policy for old jobs. The service automatically deletes 15-day-old jobs, and any artifacts associated with the jobs.

Import Types

Model ImportType

The importType of a job determines whether data should be inserted as factData, masterData, masterFactData or privateFactData.

Currency Conversion ImportType

The importType of a job determines whether data should be inserted. For currency conversion table import the only ImportType allowed is CurrencyTable.

Public Dimension ImportType

The importType of a job determines whether data should be inserted. For Public dimension import the only ImportType allowed is publicDimensionData.

Unit Conversion ImportType

The Data Import Service allows you to import to two of the Standard Unit Conversion tables (T006 and T006A), allowing you to maintain custom units which can be used to perform conversions between units of the same type or group (e.g. length). The conversion rate is maintained as the rate between the unit and the Base Unit in the group, in the form of a numerator (ZAEHL) and denominator (NENNR). The numerator and denominator for a Base Unit should always be 1.

Creation, deletion and update of units and unit groups takes place through the T006 table. To create a new group, create an import job to T006, and post a record for the Base Unit of Measure. As long as the unit id (MSEHI), and group id (DIMID) do not already exist, executing this job will attempt to create the group, and Base Unit of Measure. Please note that a Base Unit should have a numerator of 1 and denominator of 1, and the PRIMARY column set to “X”. New units for existing groups can be imported with the column DIMID specifying the desired group.

Units can also be assigned descriptions in each of the 39 supported languages. Creation, deletion and update of these units takes place through the T006A table. To provide the most compatibility with other SAP products, when importing data to the T006A table, only the standard SAP language column SPRAS needs to be specified. This is then used to fill the SAP Analytics Cloud specific language column automatically when executing the import. This is why you will not see the column LANGUAGE when exporting metadata through the Data Import Service, but you will see it when exporting metadata through the Data Export Service.

In the case of deleting data, the DeletedData section requires only the primary keys of the row to be deleted. In the case of the T006 (Unit Conversion Rates) table, this is the column MSEHI (Unit ID), and in the case of T006A (Unit Descriptions), these are the columns MSEHI (Unit ID) and SPRAS (SAP Language). Other columns can be included; however, they will have no effect on what row is deleted.

Mappings

You can map column names in the source data to column names in the target model during the import. When you post data to the job, the service automatically translates the column names according to the mapping you have specified.

You can either pass mappings when you create a job, in which case they are persisted and exist for the lifetime of the job, or when posting data, in which case they only take effect for that request. Mappings you send in the post data request also take precedence over mappings persisted for the job.

Mapping is sent as an object in the request body as shown below. The object lists property to value mappings which represent dimension names and column names. The dimension name on the SAP Analytics Cloud model is the property (on the left-hand side) and is mapped to the source column name as the value (on the right-hand side). This ordering allows you to map multiple dimensions in the target model to single columns in the source data. This means that specifying a single column in the data to be imported will fill the value into multiple dimensions on the target model.

Mapping: { 
	“targetDimension1”: “sourceColumnName”, 
	“targetDimension2”: “sourceColumnName2” 
} 

Default Values

Default values allow you to provide a value for a given column, which is then used for every row where a value for that column is not provided. If every row is to have the same value for a given column, or if you would like some rows to have a default value when none is provided, you can specify this in the default values section of your request when creating a job or when posting data to the job.

Default values provided when posting data to the job only apply during the current POST request and are not applied for subsequent POST requests, whereas default value provided during the job creation are applied to every POST of data. The most recent default value provided for a column is the one used.

DefaultValues: { 
    “targetDimension1”: “defaultValue1”, 
    “targetDimension2”: “defaultValue2” 
} 

Job Settings

You can pass job settings when you create a job to fine-tune how the job behaves and how you interact with it. If you don't pass any job settings, all settings are set to default values.

ImportMethod

Changing the importMethod setting allows you to fine-tune what happens when matching rows are found in the target model.

Update

By default, the import method is set to Update. This method runs an upsert on the target model. If a row in the imported data matches the dimensions of a row in the target model, that row is updated. If there is no match, the source row is inserted as a new row.

Append

Alternatively, you can set the import method to Append. In this case, the values of measures for matching rows are summed to the row in the target model. If there is no match the row is inserted as a new row. For more information about the Append method, see SAP Note 3420998 Information published on SAP site.

CleanAndReplace

You can also set the import method to CleanAndReplace. This allows you to clean or delete subsets of your data before proceeding with the import. The deletion happens according to another job setting, called dimensionScope. This specifies the relevant dimensions, which determine what rows of data are deleted from the target model. The deletion happens according to what data in the target model matches rows in the source data. However, the important distinction in this case is that a match means that only values in the user defined dimensionScope must be the same. As an example, if the dimensionScope has a dimension exampleDimension, and you execute an import job containing a row where exampleDimension has a value of exampleValue, then any row in the target model where the dimension exampleDimension has a value of exampleValue will be deleted. The dimensionScope by default includes the mandatory version dimension, but you can add dimensions by specifying them when you create a job. The dimensionScope is not relevant for the other import methods.

The dimension names specified in dimensionScope property need to match the dimension names in the target system. Custom names cannot be used in this setting.

DeleteAndUpsert & DropAndInsert

Currency conversion tables support two additional methods: DeleteAndUpsert and DropAndInsert.

DeleteAndUpsert is the default import method for currency conversion. It allows you to delete the data specified in the DeletedData part of the request’s JSON body, and upsert data posted to data import service into the currency table. Like for Update, upsert here means if a row in the imported data matches the dimensions of a row in the target model, that row will be updated. If there is no match, the source row is inserted as a new row.

DropAndInsert allows for a drop of the current data in the currency table, and inserts all data posted to the data import service into the currency table.

PivotOptions

The PivotOptions job setting allows you to import pivoted CSV data.

When you create a job, you can also specify properties to define the structure of your pivoted data. Below is an example of the structure of a Pivoted CSV import, starting with the structure of the model.
Country | Generic Dimension 
Product | Generic Dimension 
Date    | Date Dimension 
Costs   | Measure 
Version | Version Dimension 
Here is a structure example of pivoted CSV data you could import to a model. The date dimension is used as the pivotKey and the Costs measure as the pivotValue.
Country,Product,202301,202302,202303,202304 
Ireland,Water,100,200,300,400 
Ireland,Cola,500,600,700,-100 
Before we can write this data, we must create a job first with the following mandatory job settings:
{ 
    "JobSettings": { 
        "pivotOptions": { 
            "pivotColumnStart": 3, 
            "pivotKeyName": "Date", 
            "pivotValueName": "Costs" 
        } 
    } 
} 					
  • pivotColumnStart: This property defines the starting column index, in this case the third column is where the pivot key (Date) begins, any column after this index is expected to be a value of the pivot key “Date” which would be 202301, 202302…

  • pivotKeyName: The name of the column, which is being pivoted, in this case it is the date dimension and we can see that all pivot columns are date values.

  • pivotValueName: The pivotValue name is the column which corresponds to each pivotKey, in this case we selected the measure Costs. This means that for each pivoted column, the value will be the measure value associated with it. For example, if we take the row where Country is “Ireland” and Product is “Water”, then rest of the row is populated with the measure value for each corresponding date (202301 = 100, 202302 = 200).

If the pivotOptions are set correctly you may follow the standard import process (Step-by-Step or One-Click) to import your data to the target model. Each row is validated to ensure the length is consistent.

ExecuteWithFailedRows

The ExecuteWithFailedRows job setting specifies whether the job should go ahead when invalid rows are detected during the import. This setting is set to true by default, and you can edit it setting when creating a job. If set to false, and if invalid rows are detected, the write is canceled.

Here's a JSON example of a sample job creation:
{ 
	"JobSettings": { 
		"executeWithFailedRows": false 
	} 
} 			
If the job detects failed rows in the /jobs/{jobID}/run endpoint returns the following:
{ 
	"error": {  
		"code": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", 
		"message": "One or more failed rows detected. Write cancelled [2903]"    
	} 
} 

Details on which rows failed and why can be found using the /jobs/{jobID}/invalidRows endpoint. The job can still be forced to write regardless of the failed rows by initiating the /jobs/{jobID}/run endpoint with the overrideExecuteWithFailedRows flag set to true.

Here's an example of the /jobs/{jobID}/run endpoint's body with the override flag:
{ 
	"overrideExecuteWithFailedRows": true 
}  

IgnoreAdditionalColumns

The IgnoreAdditionalColumns job setting is used to set the behavior of the job if there are extra rows detected during the import. This setting is set to false by default, and you can edit this setting when creating a job. If set to true, any additional columns that could invalidate the data is ignored, and the data is uploaded without those columns.

Here's a JSON example of a sample job creation:

{ 
	"JobSettings": { 
		"ignoreAdditionalColumns": true 
	} 
} 

CustomDateFormat

This job setting is used to convert the source data date columns format to a format different than that of the target model date dimensions. For example, you can convert “DDMMYYYY” to “MMYYYY”.

This job setting is only available when creating a job using the factData import method.

Here's a JSON example of a sample job creation with dateFormats:

{
	"JobSettings": { 
		"dateFormats": { 
			"SourceDate1": "DD/MM/YYYY", 
			"SourceDate2": "DD/MM/YYYY" 
		} 
	} 
} 

Reverse Sign By Account Type

This job setting allows users to specify if they want to change the sign (+/-) of numeric data in the model from positive to negative or vice versa. This is available for account dimensions only, for members that have the account type of INC and LEQ.

This job setting is only available when creating a job with factData and masterFactData import methods.

Here's a JSON example of a sample job creation with reverseSignByAccountType:

{ 
	"JobSettings": { 
		"reverseSignByAccountType": true 
	} 
} 

API Endpoints and Parameters

The Data Import Service API offers multiple endpoints through its multiple services.

Model Service Requests

Endpoint

Description

/models

Returns a list of models that you can import.

/models/{modelID} (GET)

Returns a list of supported import types for a given model.

/models/{modelID} (POST)

Creates a new import job with a given import type specified automatically.

/models/{modelID}/metadata

Returns the metadata of a model.

/models/{modelID}/importType (POST)

Creates an import job for a given model with the selected import type.

Import Types Available for Models

Import Type

Description

factData

Import data to the fact data table (Data Foundation).

masterData

Import data to all dimensions of the model.

masterFactData

Import data to all dimensions and to the fact data table.

privateFactData

Import data to the fact data table with a specified private version.

Public Dimension Service Requests

Endpoint

Description

/publicDimensions (GET)

Returns a list of all Public Dimensions and their respective properties.

/publicDimensions/{publicDimensionID} (GET)

Returns a list of supported import types for a given Public Dimension, along with URLs to create import jobs for the import types supported, and a URL to retrieve the metadata.

/publicDimensions/{publicDimensionID}/metadata (GET)

Returns a list of metadata for a given Public Dimensions grouped by the import type, providing the structure from which the body to POST data to the app is to be structured.

/publicDimensions/{publicDimensionID}/{ImportType} (POST)

Creates an import job for a given Public Dimension with a selected import type, which can be publicDimensionData only. This endpoint also allows Mapping.

Import Types Available for Public Dimensions

Import Type

Description

publicDimensionData

Allows the import of members to the public dimension.

Currency Conversions Service Requests

Endpoint

Description

/currencyConversions

Returns currency conversion tables on an SAP Analytics Cloud system.

/currencyConversions/{currencyConversionID} (GET)

Returns the available import job types for a given currency conversion table, along with URLs to create import jobs for the import types supported, and a URL to retrieve currency conversion metadata.

/currencyConversions/{currencyConversionID} (POST)

Creates a new import job with a given import type specified automatically.

/currencyConversions/{currencyConversionID}/metadata

Returns a list of metadata for a given currency conversion table on your SAP Analytics Cloud system.

/currencyConversions/{currencyConversionID}/importType

Create an import job for a given currency conversion table with the selected import type.

Import Types Available for Currency Conversions

Import Type

Description

currencyTable

Allows the import of rates to a currency conversion data table.

Unit Conversion Requests

Endpoint

Description

/unitConversions

Returns a list of all unit conversion tables and their respective properties.

/unitConversions/{unitConversionID} (GET)

Returns the available import job types for a given unit conversion table, along with URLs to create import jobs for the import types supported, and a URL to retrieve unit conversion metadata.

/unitConversions/{unitConversionID} (POST)

Creates a new import job, automatically determining the import type based on the unit conversion ID.

/unitConversions/{unitConversionID}/metadata

Returns a list of metadata for a given unit conversion table on your SAP Analytics Cloud system.

/unitConversions/{unitConversionID}/{importType}

Creates an import job for a given unit conversion table with a selected import type.

Import Types Available for Unit Conversions

Import Type

Description

conversionRates

Allows the import of units and rates to the Unit Conversions table T006.

unitDescriptions

Allows the import of unit descriptions to the table T006A.

Job Service Requests

Endpoint

Description

/jobs

Returns a list of all jobs and their respective status.

/jobs/{jobID} (POST)

Add data to an import job.

/jobs/{jobID} (DELETE)

Deletes an import job.

/jobs/{jobID}/validate

Validates an import job and returns a list of rows that failed validation according to model settings.

/jobs/{jobID}/run

Runs an import job.

/jobs/{jobID}/invalidRows

Returns a list of rejected rows and the reason for failure after validation is completed.

/jobs/{jobID}/status

Returns the status of an import job.

Import Service Requests

Endpoint

Description

/import/{modelID}

Runs an import job in one click mode.

/import/{modelID}/{importType}

Runs an import job in one click mode with a specified type for job.

Additional Information

Section

Description

Error Codes and Troubleshooting

A list of error status codes and how to troubleshoot them.

API Restrictions

  • The service currently imposes a limit of 100 active jobs per user, and 100 active jobs per model. Jobs are considered active until a /run call is performed.

  • POST requests must be 300MB or less in size. If you’re importing a large volume of data, we recommend sending it using multiple POST requests before executing the job.

  • Import to public dimensions containing hierarchies is not supported. When doing a masterData or masterFactData import to a model that has a public dimension, the key of the public dimension must be present.

  • When performing a masterData or masterFactData import, you cannot overwrite the same column between multiple rows in the same job.

    {
             	 "Data": [
             	{
                 	    "BikeID": "AB100",
                      "Bicycle___Price": "400.99",
                      "Bicycle___Description": "racing bike",                
                      "Shop_Tienda_ID": "SHP_01",
                      "Shop___City": "Galway",
                      "Shop___Description": "Salthill County Galway",
                      "Date___CALMONTH": "202304"
                 },
                 {
                      "BikeID": "AB101",
                      "Bicycle___Price": "400.99",
                      "Bicycle___Description": "Newest racing bike",
                      "Shop_Tienda_ID": "SHP_01",
                      "Shop___City": "Galway",
                      "Shop___Description": "Salthill Co. Galway",
                      "Date___CALMONTH": "202304"
             }
        ]
     }
    					

    In the above example, we are trying to import to SHP_01 in both rows and overwrite the shop description. This will result in an “INVALID_PRIMARY_KEY [Shop___ID, Shop___Description]” rejection and the import for that column will not complete.

    However, the rest of the data will import correctly as there are no other overwriting columns.

  • Import to the Version dimension is not supported. When doing a MasterData import or a masterFactData, only the Version___ID can be present.

  • Import to the Time Dimension is not supported. When doing a MasterData import or a MasterFactData, only the time key can be present.

  • Importing hierarchies is not supported.

  • Temporary storage for import jobs is capped at a hundred millions of records. Jobs that reach that limit cannot hold additional records and can only allow validation and run endpoints.

  • privateFactData import type is only supported for Business Users.

  • When importing to public account dimensions, the numericShift property, which corresponds to Scale in SAP Analytics Cloud, is stored as a numeric value. You must use the numeric values when importing to this column. The values are mapped as follows:
    • 0 is mapped to 'None'

    • 2 is mapped to 'Percent'

    • -3 is mapped to 'Thousand'

    • -6 is mapped to 'Million'

    • -9 is mapped to 'Billion'

    In the example below, the numericShift value is set to 'Thousand':
    { 
    "ID":"ACC_100", 
    "accType":"AST", 
    "rateType":"Closing", 
    "Description":"Account_100", 
    "numericShift":"Thousand", 
    } 
    But should be set to '-3':
    { 
    "ID":"ACC_100", 
    "accType":"AST", 
    "rateType":"Closing", 
    "Description":"Account_100", 
    "numericShift":-3, 
    }