Technical Articles
SAP Analytics Cloud – How to Change a Model based on Live Connection in a Story
If you need to change a Model based on a live connection in your story, at the moment that I’m publishing this content, there’s no a linear way to change it and you know the effort that is required (Create a new connection, recreate widgets calculations, dimensions, filters, input controls, …).
I found a way that I want to share with you to minimize the effort (10 minutes) to replace a Model based on a live connection.
In our example, lets use a simple story that actually is pointing to a Model that uses a HANA Live connection:
SAC Story Based on a Model with Live Connection
As you can see, you cannot change / replace the actual Model by the new model.
Before to start we need to know the actual and the new model IDs. You can do that just with the option sharing and coping the ID of each one:
SAC Model ID
The workaround is going to Deployment -> Export -> New Export -> Export just the Story and not the dependencies:
SAC Export Story
Upload the file to Linux in a clean folder, decompress the tgz file and after remove the tgz:
tar xvzf <name of the tgz file>
rm <name of the tgz file>
Here is the content of the TGZ file for our example:
SAC TGZ Extracted
After we need to execute from the path where we extracted the TGZ file, next command to replace the actual ID of the MODEL with the new ID:
find <path to the folder TGZ extracted> -type f -exec \
sed -i 's/<Original Model ID>/<Final Model ID>/g' {} +
After replacement of content of Model ID we need to compress the content again:
tar cvzf <name of the TGZ file> *
In SAC, we need to Import the TGZ file: Deployment -> Import -> Upload File overwriting the objects:
SAC TGZ Uploaded
SAC Content Overwrite
We can check in the story that is working and with the new model with live connection mapped:
SAC Model Changed
Note: It can be done also with external tools / plugins or developed in SAP Cloud SDK but with extra costs by the moment.
Model ID with different length:
- It’s also important to have in consideration, if the new model ID length size is different (greater or smallest) than the old one, we need also to change the value of the file size in files where Model ID appears. For example:
Model ID original: C9xht1myjk1olookllp4bla6f4 (length: 26) Model ID final: C3QINITSUXFV5W3VLELZBI1OG (length: 25)
- We need to count how many times appears the string of Model ID:
grep -o <Model ID Original> <File_Name in folders json/export> | wc -l
- Each file where it appears, contains the file size and we need to adjust it to avoid import error:
- In our example if the count was return (n), we need to add (if new Model ID is greater than the old one) or subtract (if new Model ID is shorted than the old one) the number of the file size.
In our example:# n=2 (times that appears). # <size of Model ID original>=26 # <size of Model ID new>=25 # difference -> 26-25=1 # n * difference = 2 * 1 = 2 # Value to replace in file: <file size> - <result> = 5181-2 = 5179
As alternative, request to create an enhancement in SAC to change Models based on Live Connections in a Story: https://apps.support.sap.com/sap/support/knowledge/en/2424376
Tool to Replace Model ID
In the meantime it’s available a script that allows to do in a simple way:
https://sac.rebisconsulting.com/tools
Just introducing the Source Model ID, the Destination Model ID, uploading the TGZ file and the tool returns the new TGZ with the steps mentioned in this blog.
If you have more than one model to replace, you can do recursive this upload and download, by the moment.
Thanks for your time.
Amazing idea but what a sad state that it has to be done like this at the moment.
Very useful tip. Thanks for sharing!
Amazing tip! Thank You!
I can't wait to explain it to end users.
Seriously, thanks for sharing!
There is an existing influence request, you can vote for it:
https://influence.sap.com/sap/ino/#idea/229434
2975957 - How to replace a model in a story in SAP Analytics Cloud or SAP Digital Boardroom - for import modes
It does not work for our BW live stories. We see modell name instead of model id in the tar file. When we import the file (with replaced model name) we get error message.
Hi Sabine,
Did you check the length of the Model ID?
BR,
Jorge
Hi Jorge,
as I wrote we see the model name and not id in the tar file.
"modelId":"BVDR_VIRE001_S_INVOICES_Q01AR"
Length of the names and the IDs differ. Maybe this is the reason of the problem and I have to change file size.
To be honest: I only wanted to try it. I do not want to explain it to our key users.
Regards
Sabine
Totally Agree. It's just for non end-users. I hope shortly we'll have another option. But for me solved many hours of work 🙂
In the mean time, till we have a direct option in SAC, I'll create an script to automatize it or something similar.
BR
Jorge
Hi team,
Once the story is exported without dependencies, where do you find the export file to upload to Linux in a clean folder ?
Brgds,
Olivier
Hi Olivier!
It's download to your computer. Check in Downloads folder. This file has the extension TGZ.
BR,
Jorge
Hi Jorge,
No nothing 🙁
And I double-checked, "Downloads" is my default download folder defined in Edge.
No error, no warning, ... when creating the export. Weird...
Brgds,
Olivier
Hi Olivier,
Did you click in the icon:
If yes, check the history of downloads of your browser.
BR,
Jorge
Hi Jorge,
Yes we did. Then some processing happens:
and this progress bar becomes green, then disappear, then ... nothing... 🙁
Brgds,
Olivier
Hi Olivier,
Are you getting any message error?
Is the option "Enable Job for Export and Import" enabled (System -> Administrator -> System configuration)?
In the monitor menu option, did you get any status error? (Can you check it also?)
Did you checked in the browser the downloads menu option?
BR,
Jorge
Hi Jorge,
No error msg at all on the GUI.
Djeeeez, we didn't know about his setting, sorry 🙁 So, yes, we have now enabled it.
We also enabled the "Allow model export to File Server".
I just tried again but got nothing downloaded locally. 🙁
I also went into the trace and saw this:
Brgds,
Olivier
Hi Olivier,
Let's try later, but anyway, the error is not related to this problem.
Also if you have 15 minutes we can be in touch and check in screen sharing to try to see why you cannot do the download. If you are agree, for sure. My email is accessible from the profile, just drop me an email and we can try.
I'm not promising anything, but we can check together.
BR,
Jorge
Hi Jorge,
Thx for your support!
I sent you a Teams meeting request this morning. Feel free to reschedule.
Brgds,
Olivier
Hello Jorge,
Thanks a lot for the confcall last Tuesday. Damned ZScaler/firewall ^^
Should we care about encoding ? UTF8, ANSI, etc... as we are currently doing the update on Windows via Notepad++.
Should we care about the filename .TGZ that we import?
We will also investigate Cygwin environment in order to do the change in a Unix env.
Ill keep you posted.
Krgds,
Olivier
Hi Olivier,
It's good to know that now it's working, but it's important to be done in Linux as the tgz format has format of Host type "Unix", UTF-8.
I'm finishing a mini portal that runs over Linux (this week will be finished), that allow-us to do in fast way till we'll have the functionality in SAC.
Krgds,
Jorge
Hello Jorge,
I successfully changed a story yesterday. Fyi: I did the archive extract, ID change and archive compress under Cygwin that I installed on my W10 laptop.
Questions:
- how about stories using more than one model ?
- how about "Analytic Applications" ?
Same drill for both, I guess ?
Brgds,
Olivier
Hi Olivier,
Nice to see that works. Yes, Cygwin uses format of Host type Unix and that's enough.
When you have more than one model, you must replace in Linux like the first one and remember to check the length of the string of previous model ID and new model ID to adjust size value.
But anyway, if you want we can see again together.
Brgds,
Jorge
Hi Olivier,
It's available a temporary script that allow us to simplify. I hope it's useful:
https://sac.rebisconsulting.com/tools
Brgds,
Jorge
Hi Jorge,
thank you for the effort. Unfortunately the link you shared is not working. It is showing a "404 Not Found". Is the tool still available?
Kind regards
Felix
Hi Felix,
It's now working.
Unfortunately the tool was created in a server located in the OVH’s Strasbourg Data Center where a fire has destroyed.
Kind Regards,
Jorge
Hi Jorge,
thank you very much for your fast response.
We were also affected by the fire. Our companies social intranet was down for quite some time. One sometimes forgets that even the internet is based on hardware somewhere.
Kind Regards,
Felix
Hi Felix,
You're true. And again, I checked the script and was the old version that I restored from backup that was creating the _new.tgz file incorrectly.
Now, seems the correct one. I hope you can use it.
Kind Regards,
Jorge
Hi Jorge,
it worked. I needed to fix something for tomorrow morning. So you can't imagine how happy I am right now.
Many thanks!
Felix
Hey Jorge,
What about Analytic Application ? Can we export these just like you did for Story and work your magic on them ?
Brgds,
Olivier
Hi Olivier,
I did a test and works for me. Also checked with the script. The model was changed.
Many thanks to ask.
Brgds,
Jorge
Hello Jorge,
Me again 😉
When exporting, you said "just the story (and related folders), not the dependencies".
I got an export proposal with items of type "Dimension" and other items of type "Wrangler". Should I also discard / remove these from export ? Or only discard model(s) and keep everything else ?
Thx for feedback.
Krgds,
Olivier
Hi Olivier,
just the story, it's enough.
Krgds,
Jorge
And from time ot time, the size of the JSON msg in-between "{...}" does not match the size defined at the begining of the file 🙁
Bug ?
Krgds,
Olivier
HI Jorge
Thanks for your post.
Can you post an example of <path to the folder TGZ extraded>?
I can't find the right path.
Hi Jorge!
Here is an example:
So the find to replace the Model ID in my example is:
Is the path were I did the uncompress the file.
But any way, you can use also the tool as many times as models that you need to do the replace for each model in the story:
https://sac.rebisconsulting.com/tools
I hope it can helps.
BR,
Jorge
Thanks Jorge.
The link https://sac.rebisconsulting.com/tools doesn't work, that why I'm trying the workaround.
I'm using Mac OS and maybe why it doesn't work:
"The
-i
flag probably doesn't work for you, because you followed an example for GNU sed while macOS uses BSD sed and they have a slightly different syntax."Can it be the reason?
Hi Jorge,
Maybe, I used it over a CentOS, but can be the reason.
In the meantime, if you have time, we can see why the tool doesn't work with your file as can be good to check from my side, if you are agree.
BR,
Jorge
Sure.
What's your email to change the file and have a better communication?
yes, it's better. Can you get it from my profile?
https://people.sap.com/jorge.sousa#about
Hello Jorge,
We tried to use the tool for changing our second, third and fourth model in our story, but it fails during import of the content to SAC - "An unexpected error occurred during delivery unit upload. Please try". Converted file for the first model works absolutely fine..!
Please help.
Hi Karthik,
Just send me an invitation to my email to do a short screen sharing and check how can I help you.
BR,
Jorge
Jorge,
After analysis, there is another modification to make in another file.
Please see my last comment on Karthik's last post.
Hope it'll help to enhance your app !
Regards,
Sebastien
Hello Jorge,
Thanks for this helpful topic and useful tool.
We used it many times with 1 or N models without any problem.
But since some days, we also have the same problem than Karthik, with same error at upload.
Did you figure out a solution for this point ?
Regards,
Sebastien
Hello Sebastien and Jorge
Our issue was because of the length of the model IDs, which were different. Let me present a scenario for clarity
Our model in "Dev" folder was with ID: C96q7od7d52uisiosshikqrc3k - Length = 26
When we copied the model to "QA" folder within the same tenant, the generated model ID was "C6DOYYB7VX3JL8V5FHLUZHGIR" with length = 25.
When we used the tool to convert the source model to target model, the import of the converted file failed.
Our workaround was:
I hope this helps!
Hello Karthik, Hello Jorge
Thanks for the workaround, even if it's a little bit tricky !
After analysis, I saw there is now another file to modify in addition to the the first one if your model ID has a different length. This is the exact same method Jorge described in his blog, but for another file.
it is stored in "\ti\objects\FPA_EXPORT.t.3.[EXPORT_NAME]_[ID].t.3\json\"
The resource file name depends on your extract but it's always the biggest file of the directory.
For my example, in file "RESOURCE_1_1_155BB049A92B1276C4DA10D00D64273".
After modifying this file, the upload is successful.
Hope it'll help !
Sebastien
Hi Dears,
I modified the app to change also the affected paths 🙂
BR,
Jorge
Hi Jorge Sousa
The thread looks very useful.
Can you please elaborate on the step "Upload the file to Linux in a clean folder, decompress the tgz file and after remove the tgz"
Regards,
Sayed Zubair
Hi Sayed,
I'm not sure if the below explanation is what you need, but here it is:
Just follow the steps and the commands used or if you prefer you can use the link/tool that can do this process by you.
Hope it helps.
BR,
Jorge
Hi Jorge Sousa
Thanks for your quick reply. This helps.
Can this be achieved if we do not have a Linux system?
Is this https://sac.rebisconsulting.com/tools the recommended tool to make this change Just to be more clear from security perspective.
Regards,
Sayed Zubair
Hi Sayed,
Sure and understand. Yes, it's the link. I created the script in my webserver runs on Linux, it's just to help others, but basically it's executing the mentioned steps in this blog.
By the moment is what I'm using to.
BR,
Jorge
Thank You Jorge Sousa
Hello Jorge,
Long time no see 😉
Coming back to you with another brand-new issue... Let me explain.
Next to our HANA DB system, our SAC is also connected to our BW4HANA system.
On this BW4HANA, we have a Data Mart type aDSO.
On top of that datamart aDSO, we have a composite provider.
On top of that composite provider, we have a BW Query.
Within SAC, we have created a model on top of that BW Query.
When shifting the model's datasource from our dev system to our prod system, we get an error saying "System or data source is not available".
As part of the IT dept, I have a SAP_ALL profile, so it is not an authorization issue.
aDSO, composite provider and BW query are all available in both dev and prod systems.
Any idea ?
Krgds,
Olivier
Hi Olivier,
If you have time, we can check together in a session.
KR,
Jorge
Hi Jorge,
Thanks for replying. We found out that simply re-selecting the data source actually solved the issue.
Kr,
Olivier
Hi Jorge,
Thank you.. this is very useful
Kr,
Hussha
Hi Jorge,
Thank you!!! This is very useful
I performed the procedures correctly but I have a problem. When finishing all steps in the import, I get the following error message:
"Objects CUBE:<CUID value> might already be deleted or did not exist in the system."
I researched this message and saw the following:
https://userapps.support.sap.com/sap/support/knowledge/en/2869706
but the model existed in the environment. Can you help me?
Krgds,
Fábio
Hi Fabio,
Sorry to reply you so late, already solved?
If it's saying such message maybe is because the model is located in a private folder and not in a public path. Or permissions. Can you check?
BR,
Jorge
Short answer: The content namespaces of both models (old one and new one) must be the same.
Longer answer: I already used Jorges instructions successfully, but yesterday I ran into the same issue getting the error "Objects CUBE:<CUID value> might already be deleted or did not exist in the system." and I could not understand why. Story and models were in the public folder and I had admin rights.
Then after looking exactly at the error message, I noticed that the content namespace is also displayed in the message befor the model ID number. I remembered reading something about content namespaces in this blog article
https://blogs.sap.com/2020/04/20/sap-analytics-cloud-landscape-architecture-life-cycle-management/
I was trying to replace the current model in the story with a new one which had a different namespace (because I had transported the story to a new tenant and created the new model in the new tenant). The old model hat the content namespace "t.9" and the new one "t.A". So I created the new model in the old system (to get the same content namespace) and transported it to new system, then the model replacement worked. I did the replacement in the test system, because I did not want to mess around with the productive story.
Thanks for posting this. However, does this only work for Linux?
It's the easiest way... On Win10, you can run a linux kernel in another window.
Many thanks Yann to reply to Agata 🙂
Hi Agata,
As mentioned by Yann, you can run over Windows a Linux kernel (using a virtual machine with Linux instance or also with Cygwin.
BR,
Jorge
Thank you both.
Hello everyone,
I would like to ask, if would be possible to duplicate the model query? For Aquired models. And another question is, what exactly is a number - the file size, what needs to by adjust, if the file is changed? I cant figure out.
Thanks in advance,
Have a nice day
Ondrej
Hi Ondrej,
The file size is the "red box" in the picture of the example (in the explanation used as example it's 5181). Is this explanation enough?
This procedure is for models based on live connections, for acquired you don't need to use this approach, just directly in the story.
Hope it can help.
BR,
Jorge
Good job, and an interesting solution given the circumstances.
Unfortunately, this sounds like a very complicated and overly technical solution to what should be a very simple piece of functionality for any BI tool and done with a click of a button. SAP should do better than this.
Hi Agata Lukasiewicz thanks for your interest here.
Please could you add your vote to this enhancement request if you haven't already? https://influence.sap.com/sap/ino/#/idea/229434
Regards, H
Hi Agata!
Many thanks for your commentaries. Totally agree and hope it will be as you mentioned shortly.
In the meantime you can try to use the link (https://sac.rebisconsulting.com/tools) to replace the model easily.
BR,
Jorge
Jorge 4 president! This worked. I used the link https://sac.rebisconsulting.com/tools.
As of 19.11.2021 the enhancement request for this issue has been accepted, but no idea about implementation timeframe
https://influence.sap.com/sap/ino/#/idea/229660/?section=sectionComments
Many thanks Galin!
Finally we'll have it available!
Hi Everyone,
We are following as the blog said to uncompress and compress it again .
After changing the model ids we compressed the file to tgz format again . And while importing it gives the below error . The compressed file is in tgz format:
BR,
A Singh
Hi Jorge,
Thanks for the blog!!
We have tried with the help of the tool you have suggested we can able replace the model but not the dimensions and Measure are getting error in the charts
Before trying this workaround, see if this tutorial helps:
Change the data source for models based on live data connections
Or hier:
SAP Help: Change a Model's Data Source
Hi, here's my explanation for different model IDs.
At first I did not quite understand what to do when the IDs have different lenghts. I struggled a bit and had some failed import attempts, but changed the model sucessfully in the end. Here is my version of the explanation. Thanks to Jorge for the explanation in the first place. And thanks to Sebastien Gourgouras for commenting, that other files must be updated, too. This was a helpful hint.
My starting point:
First some general notes:
I was wondering why we have to change the file size when the model ID lengths are different. Then I realized that we're dealing with ASCII characters and bytes here. One ASCII character needs one byte of memory.
More characters --> more bytes --> bigger file size
Less characters --> less bytes --> smaller file size
To illustrate this I created two empty .txt files and pasted the above model IDs. Here's the result in terms of bytes and file size:
So when the new model ID has more or less characters (= more or less bytes), we have to change the file size accordingly. If the original and the new model ID have the same length, the file size does not change and no
I did the file editting on Windows and used Ubuntu only to create the final .tgz file.
Or to quote Jorge: "we need also to change the value of the file size in files where Model ID appears". But I have to admit that I did not understand what he meant at first.
The files were located in \ti\objects in different subfolders:

There were 4 occurrences of the original ID. I replaced them all. The new ID has one character more. I had to increase the file size by 4 bytes in total as shown on the screenshot:
tar cvzf <name of the TGZ file> *
Many thanks Galin!
Hi Jorge,
Thanks a lot for this blog and utility!
Understood tool https://sac.rebisconsulting.com/tools change model id wherever needed and compress it back in required format.
Does it also perform changing file size string inside file in case of different model Id's
Regards,
Ashish
SAP Data warehouse cloud views plug directly into stories, without building models.
Would the solution proposed here on the blog work in this case?
Hi Jorge,
thank you very much for this Blog and the utility provided.
The described procedure could already be used in two crucial cases.
I am considering writing two blog entries for these cases in order to help fellow users with similiar problems using SAC Live connections.
Is it ok from your side to refer to your Blog and utility?
Kind regards
Eric
Thank you. It worked. Helped us from re-creating the complete report.
Hi Jorge Sousa ,
Did you see that the system export (tar.gz) will be deprecated very soon ? Did you find another way to change the model since you wrote the blog ?
Kind regards,
Yann
Hi Yann, to be honest, I don't understand why this functionality is still not available in SAC. Lets wait and see what SAP is providing and in case of other options, work on it.
By the moment, I'm using the tool.
BR,
Jorge
Hello - right now we would like to create new stories but with different queries (live-models) behind.
Is there - in the meantime - any better solution available than the described one ?
Unfortunately, my initial attempt to use the following hyperlinked tool was not successful.
https://sac.rebisconsulting.com/tools
Especially 2 questions:
Any help or answer is well appreciated.
When trying to use the tool, i ran into the following error:
Error Message when trying to adopt the story
Thanks in advance
Wolfram
Hi Wolfram,
As far it's, by the moment, the only way that I know is replacing with this workarround. In some examples like Galin extend the explanation you can do manually also from your side.
The thing is that this blog was created in 2021 and SAP is still not providing a simple way to change the connection.
I'll take a look in the tool and dedicate some hours to improve and increase the posibilities and back here soon.
BR,
Jorge
Thank you very much for your reply.
It would be really good to - at least - have your tool as a workaround for the keen key-user at least.
But the solution should be to made in a way which enables to change models which are used in Optimized Stories and where the model-ids have also possibly completely different length.
How quickly could you produce such an extended solution ?
Would be really appreciated right now.
Thanks in advance
Wolfram Lewe