Use copy API on Versions

As an application designer or story developer, you can use the PlanningVersion.copy API for creating a private version from an existing version. This function only works for SAP Analytics Cloud models.

Before You Start

Before using the copy API make sure that you've checked the following:
  • You've created an application or optimized story that contains a table and SAP Analytics Cloud planning model.

  • You've assigned the planning model to the table.

  • You've made up your mind on how to visualize or expose the copy API to the end users. For example, you may want them to click on a button to copy a version.

  • If a planning area is to be copied, make sure that a recommended planning area has been defined for the model.

  • If users try to copy a version that exceeds the resource limits and there aren't enough resources available in the system for the copying operation, they'll see a corresponding message.

Note
  • Currently, the copy API only supports the options to copy all data, no data or planning area data.

  • All versions are copied with the default currency conversion, which can't be changed.

Example

The following script copies all data from a private version to create a private one in budget category:
Sample Code
var originalVersion = Table_1.getPlanning().getPrivateVersion("privateVersionToCopy");
if (originalVersion) {
    originalVersion.copy("targetVersionName", PlanningCopyOption.AllData, PlanningCategory.Budget)
};
The following script creates a blank version from a public one without changing the category:
Sample Code
var originalVersion = Table_1.getPlanning().getPublicVersion("publicVersionToCopy");
if (originalVersion) {
    originalVersion.copy("targetVersionName", PlanningCopyOption.NoData)
};
The following script copies the data in planning area from a public version to create a private one with a unique name:
Sample Code
var originalVersion = Table_1.getPlanning().getPublicVersion("publicVersionToCopy");
if (originalVersion) {
    originalVersion.copy("Version"+ Date.now().toString(), PlanningCopyOption.PlanningArea));
}
The following script copies the data in planning area from a private version to create one with a unique name in forecast category:
Sample Code
var originalVersion = Table_1.getPlanning().getPrivateVersion("privateVersionToCopy");
if (originalVersion) {
    originalVersion.copy("Version"+ Date.now().toString(), PlanningCopyOption.PlanningArea, PlanningCategory.Forecast));
}