Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
MartinKolb
Product and Topic Expert
Product and Topic Expert
9,734

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:

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:

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.



3 Comments