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
-
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).
-
If you want to copy to a planning area, make sure that a recommended planning area is defined for the model.
-
If the user tries to copy a version that exceeds the resource limits and there are not enough resources available in the system for the copy operation, a correspondent message is displayed.
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:
// 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)
};
//copy public version to private in a planning area
var originalVersion = Table_1.getPlanning().getPublicVersion("publicVersionToCopy");
if (originalVersion) {
originalVersion.copy("Version"+ Date.now().toString(), PlanningCopyOption.PlanningArea));
}
//copy private version to private in a planning area under planning category Forecast
var originalVersion = Table_1.getPlanning().getPrivateVersion("privateVersionToCopy");
if (originalVersion) {
originalVersion.copy("Version"+ Date.now().toString(), PlanningCopyOption.PlanningArea, PlanningCategory.Forecast));
}-
Currently the copy API only supports the options to copy all data, no data or data to planning area..
-
Keep in mind that all versions are copied with the default currency conversion and that you can't change the currency conversion.