SAP Analytics Cloud is an extremely useful business tool for data analysis. It consists of various components, each with individual features to facilitate analysis. In the realm of data analysis, we employ stories and analytical applications. Today, we will focus on understanding how to create, read, update, and delete (CRUD) with model master data using Planning Model scripting
There is four main functions for Planning Model Scripting Object
Note: Planning Model Script Object only supports Generic dimensions, its not support date, version, account and organization dimensions.
Before staring scripting, you need to create Planning Model Script Object, Follow this blog to know how to create Planning Model step by step.
Video is also available with full guidance step by step
For creating new master data in model, we have to use createMembers function.
dimensionId
(Type: string)
members
(Type: PlanningModelMember JSON | PlanningModelMember[] JSON
)
boolean
true
if the update operation was successful, and false
otherwise.var dimensionId = "CARS";
This line declares a variable dimensionId
and assigns it the value “CARS.” This variable represents the ID of the dimension where the new member will be created.
members = {
id:"Audi",
description:"Audi Car",
properties:{
car_model:"A4"
}
};
PlanningModelMember
members
object is defined with properties for the new member. It has an ID (“Audi”), a description (“Audi Car”), and additional properties, such as “car_model” with a value of “A4.”PlanningModel_1.createMembers(dimensionId, members);
This line calls the createMembers
function of the PlanningModel_1
object, passing the dimensionId
and members
as parameters. This function is responsible for creating planning model members. If the operation is successful, it typically returns true
; otherwise, it returns false
.
Result:-
dimensionId
(Type: string)
memberId
(Type: string)
PlanningModelMember
PlanningModelMember
, which likely contains information about the specified planning model member.Here’s how you might use this function in a practical example:
/* Get single master data */
var dimensionId = "CARS";
var memberId = "Audi";
var member = PlanningModel_1.getMember(dimensionId, memberId);
// Now 'member' contains information about the specified planning model member.
// You can access properties of the member object as needed.
/* Get all master data */
var all_members = PlanningModel_1.getMembers(dimensionId);
//Now 'all_members' contains information about the all planning model member.
In this example, the function is called with a specific dimensionId
(“CARS”) and memberId
(“Audi”). The returned member
object likely contains details such as the member’s ID, description, and other relevant properties specific to the planning model in SAP Analytics Cloud.
//Output of member variable
{
"id": "Audi",
"description": "Audi Car",
"properties": {
"car_model": "A4"
},
"hierarchies": {}
}
//Output of all_members varibale
[
{
"id": "#",
"description": "Unassigned",
"properties": {
"car_model": ""
},
"hierarchies": {}
},
{
"id": "Audi",
"description": "Audi Car",
"properties": {
"car_model": "A4"
},
"hierarchies": {}
},
{
"id": "Bugatti",
"description": "Bugatti Chiron",
"properties": {
"car_model": "Sport 110 Ans"
},
"hierarchies": {}
}
]
dimensionId
(Type: string)
members
(Type: PlanningModelMember JSON | PlanningModelMember[] JSON
)
boolean
true
if the update operation was successful, and false
otherwise.DataSource.refreshData()
or Application.refreshData()
) to ensure that charts or tables reflect the updated members in subsequent operations.PlanningModelMember
Here’s how you might use this function in a practical example:
var dimensionId = "CARS";
members = {
id: "Audi",
description: "Audi New Car",
properties: {
car_model: "Q3"
}
};
var isUpdateSuccessful = PlanningModel_1.updateMembers(dimensionId, members);
// Now 'isUpdateSuccessful' indicates whether the update operation was successful.
// You can handle further logic based on this result.
In this example, the function is called with a specific dimensionId
(“CARS”) and an data of memebers. The returned isUpdateSuccessful
variable indicates whether the update operation was successful.
dimensionId
(Type: string)
members
(Type: string | string[]
)
boolean
true
if the delete operation was successful, and false
otherwise.DataSource.refreshData()
or Application.refreshData()
) to ensure that charts or tables reflect the deleted members in subsequent operations.Here’s how you might use this function in a practical example:
var dimensionId = "CARS";
var membersToDelete = ["Audi"]; //or "Audi"
//if you want to delete multiple data just pass as array ex ["Audi","BMW"....]
var isDeleteSuccessful = PlanningModel_1.deleteMembers(dimensionId, membersToDelete);
// Now 'isDeleteSuccessful' indicates whether the delete operation was successful.
// You can handle further logic based on this result.
In this blog post, we explored the powerful capabilities of SAP Analytics Cloud for data analysis, focusing on the manipulation of planning model members through CRUD operations. We learned how to create, read, update, and delete members using scripting functions such as createMembers
, getMember
, updateMembers
, and deleteMembers
.
These operations provide a flexible framework for managing data within specific dimensions, offering a seamless experience for users leveraging SAP Analytics Cloud. Whether you are adding new members, retrieving information, updating existing data, or removing members, the scripting functionalities enable efficient interaction with planning models.