Skip to Content
Author's profile photo Martin Kolb

Design Studio: “Merged Prompts” and “Parallel Processing”

The “Merged Prompts” feature was initially provided by the SAP Business Warehouse (BW). When using multiple data sources in one connection, the backend (BW) merges the variable values of multiple data sources (using the same variable) into one value.


This has advantages for both the end user of the application as well as for the developer of the application. The end user has the advantage of not being forced to enter the same variable value multiple times in the prompt screen (once for each data source). The application developer has the advantage that setting a variable value once will immediately affect all data sources that are “merged”. There is no need to write script statements setting variable values to all affected data sources.


However there are also scenarios where it is necessary to have different values of the same variable in different data sources. This is the reason why Design Studio also offers the possibility to run an application in “unmerged” mode. This is activated by setting the application’s property “Merge Prompts” to “false”.

Why Does “Parallel Processing” Imply “Unmerged Prompts”?


As mentioned in the previous chapter the merging of prompts is done by the “backend” (BW, HANA). It is not a feature of Design Studio itself. The backend uses its session to store one value of a variable and shares this value among multiple data sources running in the same session.


The parallel processing is achieved by creating multiple sessions in the backend and using them independently to achieve independent/parallel execution. As backend sessions do not share any state, there is no possibility to share variable values.

How Do I Emulate “Merged Prompts”?

Emulate the User Experience of the “Prompts Screen”

When prompts are in “unmerged” mode the prompt screen contains all variables for each data source. If multiple data sources share the same variable, the user is prompted for each of these values:

PromptScreenUnmerge.png

The application offers a property “Prompt Setting” to customize which variable values are shown in the prompts screen. By default all are shown, but this setting allows removing values that shall not be visible as well as changing the sequence of the shown values:

PromptSettings.png

By removing the “duplicates” of each variable and leaving only the first occurrence in the list, the user gets a prompt screen like in “merged” mode: Each variable appears only once.

Setting the Values of the “Other” Data Sources – Part I: At Startup

When users get the adapted screen they obviously enter the variable value for only one of the variable values. However to emulate the behavior of “merged mode” the entered values need to be set also to the “other” data sources which do not occur on the screen any mode.

This is achieved by retrieving the entered value via script and setting them to the “other” data sources. The event when this should be done at application startup is “On Before Prompts Submit” of the application. In this example the prompts of “DS_1” are still on the prompt screen and “DS_2” and “DS_3” were configured not to be shown. This will require script coding transferring the value from DS_1 to DS_2 and DS_3:


var vars = DS_1.getVariables();

vars.forEach(function(element, index) {

  DS_2.setVariableValueExt(element.name, DS_1.getVariableValueExt(element.name));

  DS_3.setVariableValueExt(element.name, DS_1.getVariableValueExt(element.name));

});

This code sequence needs to be there for every affected variable. In this example only the variable “VAR1” was considered.

Setting the Values of the “Other” Data Sources – Part II: After Startup

To get well-performing applications it is best practice to use as few as possible data sources at startup. Whenever possible data sources should use the property “Load In Script” and should be initialized only after the user has “clicked” something (a button, a tabstrip, …).

Loading data sources after the startup sequence is done using the “loadDataSource” function of the data source object or the “loadDataSources” function of the application object. In “merged” mode each newly loaded data source automatically “inherits” variable values of those data sources that are already loaded. To achieve the same behavior in “unmerged” mode it is necessary to set the values of newly loaded data sources directly after they have been loaded. In this example the variable value of “VAR1” is set to the 2 newly loaded data sources DS_2 and DS_3:

APPLICATION.loadDataSources([DS_2, DS_3]);

var vars = DS_1.getVariables();

vars.forEach(function(element, index) {

  DS_2.setVariableValueExt(element.name, DS_1.getVariableValueExt(element.name));

  DS_3.setVariableValueExt(element.name, DS_1.getVariableValueExt(element.name));

});

Conclusion

Using parallel processing requires that “Merge Prompts” is set to “false”. However if the application shall behave like in “merged” mode, this can be achieved by following a few simple patterns shown in this blog.



Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Karol Kalisz
      Karol Kalisz

      good view on this topic, Martin - especially important to point the dependency between those functions.

      @all: more details on those blogs on the functionality:

      Design Studio 1.5: View on Variable Unmerge Scenario

      Design Studio 1.5: View on Parallel Data Source Execution

      Design Studio 1.5: View on Variable "synchronized" Unmerge Scenario

      Karol

      Author's profile photo Dominik Zehentner
      Dominik Zehentner

      The scenario which is described in the linked document "View on Variable “synchronized” Unmerge Scenario" does not work anymore. (I cannot write a comment there)
      This used to work great. But not anymore after Lumira Upgrade. "On before prompts submit" cannot call global scripts anymore. ->  Note 2380308

      Author's profile photo Reiner Hille-Doering
      Reiner Hille-Doering

      Hello Dominik,

      scripts in  “On before prompts submit” and "On Variable Initialization" always had very strict restrictions on APIs that are allowed. Reasons: If prompts are not submitted, almost all API calls would lead to internal errors. This is the case for almost all API on Data Source components but could also affect other standard components, especially if they are data  bound or use Property Binding.

      In all Design Studio and Lumira Designer version the script editor checked those limitations.

      Global Script functions are not allowed, because we don't know from where the function is called, therefore such a function is not checked for the limitations.

      However there were some bugs in some releases that e.g. allowed to call global script functions. Such errors have been fixed in the meantime.

      Regards,

      Reiner.