cancel
Showing results for 
Search instead for 
Did you mean: 

prompt event(s) for scripting?

Former Member
0 Kudos

Hello,

are somewhere events for prompt execution ("OK" / "Cancel" Button) available?

The scenario is: Application with a BEx Query Datasource (DS_1). The BEx Query has an input ready, mandatory, single value variable for 0FISCYEAR. In the application I want to show the selected year in a text box via the Script Code..

TEXT_1.setText(DS_1.getVariableValueExt("Z_VAR_0FISCYEAR_M_SV_M"));

Including this code in the "On Startup" event of the application works fine. The prompt dialog is shown in the beginning and the according text is set after I choose a year and press the OK-Button of the prompt. Unfortunately I am stuck when I want to enable the endusers to refresh the prompt without having to start the application all over again. E.g. by a button with the "On Click" script code..

APPLICATION.openPromptDialog(600, 600);

(like described in http://scn.sap.com/docs/DOC-41393)

First idea was to put the setText-method directly underneath the openPromptDialog-method in the "On Click" event of the button. But then the prompt is shown and the text is refreshed directly after that - with the selected year of the prior(!!!) prompt execution.

Executing the prompt via the button doesn't trigger the "On Startup" event of the application again.

So what I probably need is something like prompt events.. And I cannot find anything like that..

Any ideas are appreciated!

Best regards,

Marco

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Marco,

the thing is that openPromptDialog is not a component (with properties and events to control),

If you use the filterpanel component, you will notice that it has very handy events: "On Apply" and "On Cancel", maybe use this as a workaround?

Or else you could create your own dropdown, there you can also use the event "On Select".

Best regards,

Victor

jeroenvandera
Contributor
0 Kudos

hi Marko,

I think you could use a panel container component with 2 buttons and an inputbox or listbox component in it.

you could also handle it using only the listbox with the on select handler.

with the OK cancel button

the ok button you set the code :

APPLICATION.setVariableValueExt("Z_VAR_0FISCYEAR_M_SV_M", LS_1.getSelectedValue());

TEXT_1.setText(DS_1.getVariableValueExt("Z_VAR_0FISCYEAR_M_SV_M"));

PANEL_1.setVisible(false);


The first line will reset the value of the variable and force all the queries with that variable to reload. The second line will put the new variable value in your textbox as you already know.

The third line will hide the panel again so the prompt screen disappears.

In the cancel button you only put the

PANEL_1.setVisible(false);

hope that would solve it,

Jeroen


Former Member
0 Kudos

Thank you Victor an Jeroen for your answers.

Already thought I would have to create my "own prompt" with design studio functionality..

At least the setVariableValue-method helps a lot. With that I do not have to change the BEx Query(ies). The variable is in the characteristic restrictions and not in the default values (not a free characteristic). Therefore filter panel or dimension filter components wouldnt help (without changing the query)..

I hope that something like a prompt-event functionality is added in a later release.

Does anyone know if something like that is planned?

Imagine a case where we are not talking about the year for which you easily know values to put manually in a list box and use the setVariableValue-method.. When you have a variable in the characteristic restrictions e.g. for cost center theres no way to fill a list box with more values from the data source automatically (e.g. LISTBOX_1.setItems(DS_1.getMemberList(..)) ) and then use the setVariable-method. You would have to manually enter the possible cost center values somewhere or move the filter from the characteristic restrictions to the default values. I can imagine, that there are a lot of SAP customers out there with a huge amount of existing BEx queries with many characteristic restircition variables..

jeroenvandera
Contributor
0 Kudos

Hi Marco,

if you have costcenters, too many to list you can use the inputbox or work with cascaded filters

(see tutorial)

With the inputbox your code would look like something like this

APPLICATION.setVariableValueExt("Z_VAR_0FISCYEAR_M_SV_M", INPUTFIELD_1.getValue());

In this case you can even input something like 800* if you want all the costcenters starting with 800.


Answers (2)

Answers (2)

Former Member
0 Kudos

Marco

Forcing the datasource to load after accepting the prompt but before setting the text should help.

APPLICATION.openPromptDialog(.....);

DS_1.loadDataSource();

TEXT_1.setText(DS_1.getVariableValueText("..."));

murali_balreddy2
Active Participant
0 Kudos

Hi Marco,

Any luck with prompt based actions?

In my case, I cannot use dimension filter or filter panel as I dont want to filter out my data set, but pass a variable through prompt that will be used in a restricted key figure. I wanted to have text changed after the new variable value is submitted through prompt, but no way to do it.

As shown below, I use the prompt to select one country and calculate value for this country and for all other countries.

With the prompt, my gauge works fine with the default prompt value with on startup event

When I change the country with the prompt, my gauge changes, but the % value is not able to change as there is no event to refresh it

Also there is no way to get the prompt value to be used inside the application.

Let me know if you found a way to tweak it.

Thanks,

Murali

Former Member
0 Kudos

Hi Murali,

Jeroen already mentioned the solution: The setVariable-Method.

Instead of opening the prompt, put an inputbox and a button into the application (also a listbox, drobdownbox, etc. and the appropriate event would work).

Then include following script in the onClick-Event of the button:

APPLICATION.setVariableValue("YOUR_BEX_VARIABLE", INPUTFIELD_1.getValue());

TEXT_1.setText(DS_1.getDataAsString("YOURKEYFIGURE", {"opt. SELECTIONS"}));

When you enter the country in the inputbox and press the button you should get what you want. Because the setVariable-method changes the variable and(!) refreshes the DataSource. After that the next scripting line is executed. The openPromptDialaog-method only opens the prompt and after that the next line is evaluated directly (without variable selection and refresh).

Still I think, "prompt-events" should definitely be a functionality in a later patch/release!!

E.g. F4-input help, single value vs. multiple vs. selection option, mandatory vs. optional, etc.

Furthermore with the setVariable-method and a characteristic restriction variable you do not have the oppportunity to fill listbox-, dropdownbox-, etc-values automatically to chosse from (see above). I tried "member access mode: master data" but that didn't work as I wished..

In my opinion without such events the openPromptDialog-method will be worthless in many cases..

Best regards,

Marco

Former Member
0 Kudos

Hi Murali,

by the way: Where is the gauge coming from?

Are you already experimenting with the SDK?

Best regards,

Marco

murali_balreddy2
Active Participant
0 Kudos

Thanks. It worked. I used a radio button to pass prompt.

Anyway, I used piechart to create this gauge. See this blog, I created for you and others.

murali_balreddy2
Active Participant
0 Kudos

One thing I wanted to point out is:

Query response after prompt value submission has to be fast, otherwise, setText from DS in the onclick event does not have the latest data, but the old data prior to the refreshing of the query.

You are correct. openPromptDialog is not of much help without any related events.