Skip to Content
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%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.

52 Comments
You must be Logged on to comment or reply to a post.
  • 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 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 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,

          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

  • 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 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 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 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.

    • 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

       

        • 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

      • 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:

    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!

    • 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 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:

      • 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

       

      • 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