Skip to Content
Technical Articles
Author's profile photo Jorge Sousa

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%20Model%20ID

SAC Model ID

The workaround is going to Deployment -> Export -> New Export -> Export just the Story and not the dependencies:

SAC%20Export%20Story

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%20TGZ%20Extracted

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%20TGZ%20Uploaded

SAC TGZ Uploaded

SAC%20Content%20Overwrite

SAC Content Overwrite

We can check in the story that is working and with the new model with live connection mapped:

SAC%20Model%20Changed

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:SAC%20Export%20File%20Size
  • 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.

Assigned tags

      68 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Fabian Runge
      Fabian Runge

      Amazing idea but what a sad state that it has to be done like this at the moment.

      Author's profile photo Iñigo Montoya
      Iñigo Montoya

      Very useful tip. Thanks for sharing!

      Author's profile photo Katia Cavaloti
      Katia Cavaloti

      Amazing tip! Thank You!

      Author's profile photo Xavier Polo
      Xavier Polo

      I can't wait to explain it to end users.

      Seriously, thanks for sharing!

       

      Author's profile photo Hanna Mazurkevich
      Hanna Mazurkevich

      There is an existing influence request, you can vote for it:

      https://influence.sap.com/sap/ino/#idea/229434

       

       

      Author's profile photo Hanna Mazurkevich
      Hanna Mazurkevich

      2975957 - How to replace a model in a story in SAP Analytics Cloud or SAP Digital Boardroom - for import modes 

      Author's profile photo Sabine Krüger
      Sabine Krüger

      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.

       

      Author's profile photo Jorge Sousa
      Jorge Sousa
      Blog Post Author

      Hi Sabine,

      Did you check the length of the Model ID?

      BR,

      Jorge

      Author's profile photo Sabine Krüger
      Sabine Krüger

      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

      Author's profile photo Jorge Sousa
      Jorge Sousa
      Blog Post Author

      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

      Author's profile photo Olivier Grandhenry
      Olivier Grandhenry

      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

      Author's profile photo Jorge Sousa
      Jorge Sousa
      Blog Post Author

      Hi Olivier!

      It's download to your computer. Check in Downloads folder. This file has the extension TGZ.

      BR,

      Jorge

      Author's profile photo Olivier Grandhenry
      Olivier Grandhenry

      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

      Author's profile photo Jorge Sousa
      Jorge Sousa
      Blog Post Author

      Hi Olivier,

      Did you click in the icon:

      If yes, check the history of downloads of your browser.

      BR,

      Jorge

      Author's profile photo Olivier Grandhenry
      Olivier Grandhenry

      Hi Jorge,

      Yes we did. Then some processing happens:

      and this progress bar becomes green, then disappear, then ... nothing... 🙁

       

      Brgds,
      Olivier

      Author's profile photo Jorge Sousa
      Jorge Sousa
      Blog Post Author

      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

      Author's profile photo Olivier Grandhenry
      Olivier Grandhenry

      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

      Author's profile photo Jorge Sousa
      Jorge Sousa
      Blog Post Author

      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

      Author's profile photo Olivier Grandhenry
      Olivier Grandhenry

      Hi Jorge,

      Thx for your support!

      I sent you a Teams meeting request this morning.  Feel free to reschedule.

      Brgds,
      Olivier

      Author's profile photo Olivier Grandhenry
      Olivier Grandhenry

      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

      Author's profile photo Jorge Sousa
      Jorge Sousa

      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

      Author's profile photo Olivier Grandhenry
      Olivier Grandhenry

      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

      Author's profile photo Jorge Sousa
      Jorge Sousa

      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

      Author's profile photo Jorge Sousa
      Jorge Sousa
      Blog Post Author

      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

      Author's profile photo Felix Steigmeier
      Felix Steigmeier

      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

      Author's profile photo Jorge Sousa
      Jorge Sousa
      Blog Post Author

      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

      Author's profile photo Felix Steigmeier
      Felix Steigmeier

      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

      Author's profile photo Jorge Sousa
      Jorge Sousa
      Blog Post Author

      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

      Author's profile photo Felix Steigmeier
      Felix Steigmeier

      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

      Author's profile photo Olivier Grandhenry
      Olivier Grandhenry

      Hey Jorge,

      What about Analytic Application ? Can we export these just like you did for Story and work your magic on them ?

      Brgds,
      Olivier

      Author's profile photo Jorge Sousa
      Jorge Sousa
      Blog Post Author

      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

      Author's profile photo Olivier Grandhenry
      Olivier Grandhenry

      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

      Author's profile photo Jorge Sousa
      Jorge Sousa
      Blog Post Author

      Hi Olivier,

      just the story, it's enough.

      Krgds,

      Jorge

      Author's profile photo Olivier Grandhenry
      Olivier Grandhenry

      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

      Author's profile photo Jorge Afonso
      Jorge Afonso

      HI Jorge

      Thanks for your post.

      Can you post an example of <path to the folder TGZ extraded>?

      find <path to the folder TGZ extracted> -type f -exec \
          sed -i 's/<Original Model ID>/<Final Model ID>/g' {} +

      I can't find the right path.

      Author's profile photo Jorge Sousa
      Jorge Sousa
      Blog Post Author

      Hi Jorge!

      Here is an example:

      • My Path: /home6/soporteb/tmp/tst
      • My file: FPA_EXPORT_T_6_SAMPLE_HR.tgz

      So the find to replace the Model ID in my example is:

      find /home6/soporteb/tmp/tst -type f -exec \
      sed -i 's/Ce9f2vuh99o6fo32nlnvcc1iio/C85LASPIJF4PDG37DS3G0X94HS/g' {} +

      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

       

      Author's profile photo Jorge Afonso
      Jorge Afonso

      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?

      Author's profile photo Jorge Sousa
      Jorge Sousa
      Blog Post Author

      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

      Author's profile photo Jorge Afonso
      Jorge Afonso

      Sure.

      What's your email to change the file and have a better communication?

      Author's profile photo Jorge Sousa
      Jorge Sousa
      Blog Post Author

      yes, it's better. Can you get it from my profile?

      https://people.sap.com/jorge.sousa#about

      Author's profile photo Karthik Rajendran
      Karthik Rajendran

      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.

      Author's profile photo Jorge Sousa
      Jorge Sousa
      Blog Post Author

      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

      Author's profile photo Sebastien Gourgouras
      Sebastien Gourgouras

      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

      Author's profile photo Sebastien GOURGOURAS
      Sebastien GOURGOURAS

      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

      Author's profile photo Karthik Rajendran
      Karthik Rajendran

      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:

      1. Delete the QA model
      2. Repeat the model copy until the model ID length matches with Dev
      3. Then run the tool to convert with the latest model ID..

      I hope this helps!

      Author's profile photo Sebastien Gourgouras
      Sebastien Gourgouras

      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

      Author's profile photo Sofia Costa
      Sofia Costa

      Hi Dears,

       

      I modified the app to change also the affected paths 🙂

       

      BR,

      Jorge

      Author's profile photo Sayed Zubair D
      Sayed Zubair D

      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

      Author's profile photo Jorge Sousa
      Jorge Sousa
      Blog Post Author

      Hi Sayed,

       

      I'm not sure if the below explanation is what you need, but here it is:

      • It's basically necessary to have access to an environment with Linux, create a VM with Linux or any other.
      • When you have access to a Linux system you can upload to the system the file exported with SAC.
      • In linux, you must uncompress (untar and unzip) the file with the commands mentioned in the blog, in an empty folder.
      • when the uncompress is done, if the file is located in the same folder of the decompress we need to remove the file as after we will compress again.

      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

       

      Author's profile photo Sayed Zubair D
      Sayed Zubair D

      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

      Author's profile photo Jorge Sousa
      Jorge Sousa
      Blog Post Author

      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

      Author's profile photo Sayed Zubair D
      Sayed Zubair D

      Thank You Jorge Sousa

      Author's profile photo Olivier Grandhenry
      Olivier Grandhenry

      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

      Author's profile photo Jorge Sousa
      Jorge Sousa
      Blog Post Author

      Hi Olivier,

      If you have time, we can check together in a session.

      KR,

      Jorge

      Author's profile photo Olivier Grandhenry
      Olivier Grandhenry

      Hi Jorge,

      Thanks for replying.  We found out that simply re-selecting the data source actually solved the issue.

      Kr,
      Olivier

      Author's profile photo Usha Rani Desu
      Usha Rani Desu

      Hi Jorge,

      Thank you.. this is very useful 

       

      Kr,

      Hussha

      Author's profile photo Fabio Melo
      Fabio Melo

      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

       

      Author's profile photo Jorge Sousa
      Jorge Sousa
      Blog Post Author

      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

      Author's profile photo Agata Lukasiewicz
      Agata Lukasiewicz

      Thanks for posting this. However, does this only work for Linux?

      Author's profile photo Yann MIQUEL
      Yann MIQUEL

      It's the easiest way... On Win10, you can run a linux kernel in another window.

      Author's profile photo Jorge Sousa
      Jorge Sousa
      Blog Post Author

      Many thanks Yann to reply to Agata 🙂

      Author's profile photo Jorge Sousa
      Jorge Sousa
      Blog Post Author

      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

      Author's profile photo Agata Lukasiewicz
      Agata Lukasiewicz

      Thank you both.

       

      Author's profile photo Ondrej Horyna
      Ondrej Horyna

      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

       

      Author's profile photo Jorge Sousa
      Jorge Sousa
      Blog Post Author

      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

      Author's profile photo Agata Lukasiewicz
      Agata Lukasiewicz

      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.

      Author's profile photo Henry Banks
      Henry Banks

      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

      Author's profile photo Jorge Sousa
      Jorge Sousa
      Blog Post Author

      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