Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
jorge_sousa
Active Participant
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.
87 Comments
Labels in this area