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

19 Comments
You must be Logged on to comment or reply to a post.