For acquired model in SAC for either analysis only or planning, user(story viewer) usually would like to see the data last refreshed(from external data source) time to be confident that data in dashboard is up-to-date.
Until now, there is no out-of-box feature to easily achieve this. This blog is introducing you an option by leveraging pre-delivered system model and SAC Composite.
Prerequisite:
To follow steps described in this blog, you should have a SAC user with Admin role to access system folder and create composites.
Steps:
1. Share system model DM_SCHEDULE
You may already know that SAC pre-delivered a nice performance analysis story “Data Management Jobs Statistics and Analysis”. Live Model DM_SCHEDULE is the main data source used there.
Go to Files -> Views(from left navigation area) -> System -> Common -> SAC Content -> SAC Content Performance -> SAC Content Performance – Models -> Model ‘DM_SCHEDULE’ -> Share this model to users/teams including yourself with ‘View’ right.
2. Create a SAC Composite
a. Add a table and select the model DM_SCHEDULE just shared in last step, you should find it in folder ‘My Files’
b. In table builder, add dimension ‘Log End Time’, ‘Model Name’, ‘Model ID’, ‘Mapping Time’ and ‘Scheduled Status’ into row axis and select any measure for column axis, for example ‘Duration’. You should have something like this(dimension ‘Log End Time’ should be the first one):
c. Add filters
1) Model Name, select the model you want to show last refreshed time in story
2) Schedule Status = ‘SUCCESS’, we only need time of successful import
3) Mapping Type = ‘import’, we only need time of import job, upload job(via trigger) is not the concern here as it’s usually part of planning process which leverage private/public edit version and publishing mechanism.
4) Log End Time, this is optional in sake of performance(actually we only need one last record), if you have frequent import schedule, put a dynamic time range looking back few days or weeks would be good enough. I set 3 months here.
Filters could look like this:
d. Sort table by ‘Log End Time’ -> go table header ‘Log End Time’ -> right click -> Sort Options -> Newest to oldest. Table should look like this, the first row in the table should show the last successful import of your model.
e. Create a script variable
Go Left Side Panel -> Outline -> Scripting -> Script Variables -> Add Script Variable, give a name(‘s_last_update’) and select type ‘String’.
f. Fill the script variable with table first row
Go Left Side Panel -> Outline -> Page -> Table_1 -> fx ‘onResultChanged’ , input blow script
var table_result = Table_1.getDataSource().getResultSet();
s_last_update = table_result[0].LOG_END_TIME.description;
g. Add script variable value as dynamic text
1) Add text widget to the canvas(put it on top of the screen)
2) In text widget, first add some static text for model name
3) Right click -> Add -> Dynamic text
4) In popup -> Filters and Variables -> Script Variables -> mark check box ‘s_last_udate’ (or the script variable name you gave in step e.
The text widget would look like this, dynamic text at this stage is still showing as (No value set), it’s fine.
h. Add an function to explicitly refresh table when composite is used in story
Go Left Side Panel -> Outline -> Interface -> Functions -> add a new function -> give name ‘refresh’, and add below code in scripting area:
Table_1.getDataSource().refreshData();
i. Set table to invisible as we should not show it anywhere in story
Go Left Side Panel -> Outline -> Page -> Table_1 -> click the ‘Visible’ icon( show as an eye)
Composite should look as below.
j. Save the composite with a name.
k. Share this composite with users/teams who should consume it in story. Please note that users to consume this composite should also be granted with ‘Read’ right of composite in security role.
Now we have successfully prepared the composite.
3. Add composite into story
a. Import composite
Go to story edit mode -> Left Side Panel -> Assets -> Composites -> Import composite -> select the composite you created in step 2.
b. Use composite
1) Go to page -> drag the inserted composite from asset section to canvas -> resize the composite to a single line
2) Go Right Side Panel of composite -> Styling -> scroll to bottom section ‘Composite Style’ -> unmark two checkboxes ‘Auto Horizontal Scroll’ and ‘Auto Vertical Scroll’
Story page could look like this:
c. Force table refresh on page loading
Go Left side Panel -> Outlines -> page which used this composite -> fx -> either onInitialization or onActive -> input below code:
Composite_1.refresh();
d. Save story.
We have finished all steps, story in view mode should like this:
Summary:
One time setup of composite, it can be reused in any story where last refreshed time is required.You can have one composite per model for flexibility and reusability.
Notes and limitations:
This approach is only for acquired data model using import connection importing data from supported data source including local file. Live model is out of scope.Acquired model using Data Import API to import data is not verified yet with this approach.Format of the last refreshed date and time is controlled through user preference.Display of last refreshed time might be a little delayed (1 or 2 sec) on initial load as it requires an additional table refresh.
For acquired model in SAC for either analysis only or planning, user(story viewer) usually would like to see the data last refreshed(from external data source) time to be confident that data in dashboard is up-to-date.Until now, there is no out-of-box feature to easily achieve this. This blog is introducing you an option by leveraging pre-delivered system model and SAC Composite. Prerequisite: To follow steps described in this blog, you should have a SAC user with Admin role to access system folder and create composites. Steps: 1. Share system model DM_SCHEDULEYou may already know that SAC pre-delivered a nice performance analysis story “Data Management Jobs Statistics and Analysis”. Live Model DM_SCHEDULE is the main data source used there.Go to Files -> Views(from left navigation area) -> System -> Common -> SAC Content -> SAC Content Performance -> SAC Content Performance – Models -> Model ‘DM_SCHEDULE’ -> Share this model to users/teams including yourself with ‘View’ right.2. Create a SAC Compositea. Add a table and select the model DM_SCHEDULE just shared in last step, you should find it in folder ‘My Files’b. In table builder, add dimension ‘Log End Time’, ‘Model Name’, ‘Model ID’, ‘Mapping Time’ and ‘Scheduled Status’ into row axis and select any measure for column axis, for example ‘Duration’. You should have something like this(dimension ‘Log End Time’ should be the first one):c. Add filters1) Model Name, select the model you want to show last refreshed time in story2) Schedule Status = ‘SUCCESS’, we only need time of successful import3) Mapping Type = ‘import’, we only need time of import job, upload job(via trigger) is not the concern here as it’s usually part of planning process which leverage private/public edit version and publishing mechanism.4) Log End Time, this is optional in sake of performance(actually we only need one last record), if you have frequent import schedule, put a dynamic time range looking back few days or weeks would be good enough. I set 3 months here. Filters could look like this: d. Sort table by ‘Log End Time’ -> go table header ‘Log End Time’ -> right click -> Sort Options -> Newest to oldest. Table should look like this, the first row in the table should show the last successful import of your model. e. Create a script variableGo Left Side Panel -> Outline -> Scripting -> Script Variables -> Add Script Variable, give a name(‘s_last_update’) and select type ‘String’. f. Fill the script variable with table first rowGo Left Side Panel -> Outline -> Page -> Table_1 -> fx ‘onResultChanged’ , input blow script var table_result = Table_1.getDataSource().getResultSet();
s_last_update = table_result[0].LOG_END_TIME.description; g. Add script variable value as dynamic text1) Add text widget to the canvas(put it on top of the screen)2) In text widget, first add some static text for model name3) Right click -> Add -> Dynamic text4) In popup -> Filters and Variables -> Script Variables -> mark check box ‘s_last_udate’ (or the script variable name you gave in step e.The text widget would look like this, dynamic text at this stage is still showing as (No value set), it’s fine. h. Add an function to explicitly refresh table when composite is used in storyGo Left Side Panel -> Outline -> Interface -> Functions -> add a new function -> give name ‘refresh’, and add below code in scripting area: Table_1.getDataSource().refreshData(); i. Set table to invisible as we should not show it anywhere in storyGo Left Side Panel -> Outline -> Page -> Table_1 -> click the ‘Visible’ icon( show as an eye)Composite should look as below.j. Save the composite with a name.k. Share this composite with users/teams who should consume it in story. Please note that users to consume this composite should also be granted with ‘Read’ right of composite in security role.Now we have successfully prepared the composite. 3. Add composite into storya. Import compositeGo to story edit mode -> Left Side Panel -> Assets -> Composites -> Import composite -> select the composite you created in step 2.b. Use composite1) Go to page -> drag the inserted composite from asset section to canvas -> resize the composite to a single line2) Go Right Side Panel of composite -> Styling -> scroll to bottom section ‘Composite Style’ -> unmark two checkboxes ‘Auto Horizontal Scroll’ and ‘Auto Vertical Scroll’Story page could look like this: c. Force table refresh on page loadingGo Left side Panel -> Outlines -> page which used this composite -> fx -> either onInitialization or onActive -> input below code: Composite_1.refresh(); d. Save story. We have finished all steps, story in view mode should like this: Summary:One time setup of composite, it can be reused in any story where last refreshed time is required.You can have one composite per model for flexibility and reusability. Notes and limitations: This approach is only for acquired data model using import connection importing data from supported data source including local file. Live model is out of scope.Acquired model using Data Import API to import data is not verified yet with this approach.Format of the last refreshed date and time is controlled through user preference.Display of last refreshed time might be a little delayed (1 or 2 sec) on initial load as it requires an additional table refresh. Read More Technology Blog Posts by SAP articles
#SAP
#SAPTechnologyblog