Using the copy API

You can copy planning versions by using the PlanningVersion.copy API. This API function only works for SAP Analytics Cloud models.

Before you start
Before you use the copy API make sure you have checked the following:
  • You have created an application that contains a table and planning model for SAP Analytics Cloud.

  • You have assigned the planning model to the table.

  • You've made up your mind on how you want to visualize or expose the copy API to the application user (for example, you want the application user to use a button to copy a version).

Example

The following script shows how you can use the copy API instead of the Copy menu of the Version Management section in the application toolbar at runtime:
Sample Code

// copy private version "privateVersionToCopy" with all data and Category = Budget

var originalVersion = Table_1.getPlanning().getPrivateVersion("privateVersionToCopy");

if (originalVersion) {

    originalVersion.copy("targetVersionName", PlanningCopyOption.AllData, PlanningCategory.Budget)

};

 

// copy public version "publicVersionToCopy" with no data and without changing the category

var originalVersion = Table_1.getPlanning().getPublicVersion("publicVersionToCopy");

if (originalVersion) {

    originalVersion.copy("targetVersionName", PlanningCopyOption.NoData)

};
Note
  • Currently the copy API only supports the options to copy all or no data.

  • Keep in mind that all versions are copied with the default currency conversion and that you can't change the currency conversion.