on 2025 Jun 01 7:26 PM
Hi All,
In a SAC planning model, l want to first choose a contract , then create a new member based on this contract for a dimension(planning number), and then copy all measures value of this contract to the rows, with contract and planning number.
Example:
Before duplication:
| Contract Number | Planning Number | Position | Version | Date | Price | Quantity |
| 2025 | - | 1 | Actual | 2025-04-01 | 100 | 1000 |
| 2025 | - | 2 | Actual | 2025-05-01 | 200 | 2000 |
After clicking the button:
| Contract Number | Planning Number | Position | Version | Date | Price | Quantity |
| 2025 | - | 1 | Actual | 2025-04-01 | 100 | 1000 |
| 2025 | - | 2 | Actual | 2025-05-01 | 200 | 2000 |
| 2025 | 2025_001 | 1 | Planning | 2025-04-01 | 100 | 1000 |
| 2025 | 2025_001 | 2 | Planning | 2025-05-01 | 200 | 2000 |
Goal:
When a user select a contract and then clicks a **button**, I want to:
1. Copy all rows for the selected contract (`Contract Number`).
2. Generate a new `Planning Number` using the format: `ContractNumber_0001`, incrementing for each new copy.
3. Set the `Version` to "Planung".
4. Add these new rows back into the dataset.
❓ Questions:
1. How can I implement this row duplication logic in SAC?
2. Can this be done using Data Actions? Or what advanced script should I use?
3. Is there an approach using scripting? But unbooked data can not use setUserinput(), when l show unbooked data, then there is performance problem because of too much unbooked date.
Any help or example code would be greatly appreciated!
l saw this article (https://community.sap.com/t5/technology-q-a/sap-sac-data-action-copy-measure-from-one-row-to-another..., but it did not add new member and copy measures on this newly inserted row.
Thank you,
Iker
#SAP Analytics Cloud for planning
Request clarification before answering.
This requirement has multiple layers to it and its very difficult to provide an exact working code. I am providing some snippets from some similar requirements which you can adjust as per your requirement. Try to break this into parts.
Also I am assuming the Data Action would be already ready as its simply copying from planning number # to newly created one.
I do not have a logic of incrementing the counter every time but you could try reading all members of the dimensions planning number and see what is the last member sequence. Or you could have an attribute called sequence in the dimension and assign sequence number to it while creating the member.
Below is some form of rough scripting. I have not validated it for syntax as I took it from my old work and stitch it together so some syntax might be off.
//Reading the current contract number members from Table row selection
var sel =Table_1.getSelections();
if (sel.length > 0) {
var ContractmemberId = ArrayUtils.create(Type.string);
for(var i=0;i<=sel.length;i++)
{
for (var dimensionId in sel[i]) {
if (dimensionId === 'CONTRACT_NUMBER') {
var currentcontract = sel[i][dimensionId];
if(ContractmemberId.indexOf(currentproduct) === -1 && currentcontract)
{
ContractmemberId.push(currentcontract);
}}
}}}
//Create a script variable MemberId of type planning member before the below
//Creating Planning number member
var planningnumberid=ContractmemberId+'_001' // think about how to increment the counter here
MemberId = ({id: "planningnumberid", description: "planningnumberid"); // you can change description
var result = PlanningModel_1.createMembers('PLANNING_NUMBER',MemberId);
if(result)
{
Application.showMessage(ApplicationMessageType.Success,"Member Successfully Created");
// Assigning the parameter to Data Action
DataAction_1.setParameterValue("P_Planningnumber",planningnumberid); // You need to have a parameter in your Data Action for planning number
Application.showBusyIndicator("Preparing for execution...");
DataAction_1.execute();
Application.refreshData();
Application.hideBusyIndicator();
Application.showMessage(ApplicationMessageType.Success,"Executed Successfully");
}
else
{
Application.showMessage(ApplicationMessageType.Error,'Failed to create Member');
}
Hope this will help !!
Nikhil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 7 | |
| 7 | |
| 7 | |
| 7 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.