cancel
Showing results for 
Search instead for 
Did you mean: 

Calling script inside a flavor from a different flavor

former_member182659
Participant
0 Kudos

Hello,

I have a first Flavor (Flavor1) which takes input from a second flavor (Flavor2).

So in Falvor1, I record a script which goes to Flavor2 and retrieve some values.

These values in Flavor2 are calculated with a script.

When runing standalone Flavor2, the values are calculated right.

When running Flavor1, it doesn't retrives the values from Flavor2, it only passed the field name.

Do I have to put all the code inside Flavor1 (without calling Flavor2)?

Or is there a specific way to call a script into another flavor?

Thanks,

Emmanuel.

Accepted Solutions (1)

Accepted Solutions (1)

TobiasQueck
Advisor
Advisor
0 Kudos

Hi Emmanuel,

Could you please clarify 'After inside the scripting of flavor 1, I have some code to check the result of the script 2.'?

You call startTransaction in Flavor 1, which ends the transactional session of your current transaction (this includes empty the values of all custom fields e.g. wnd[0]/usr/lblPersonas_14988158823869), then you are still in the context of your script from flavor 1 but you switch to flavor 2 and fill some fields - all good so far - then you press a script button in flavor 2 which should work (but session.utils.executeScript(<script id>); would be a little cleaner).

What happens next? Is the script moving you back to the transaction with flavor 1 that started all this? And what script is responsible for assigning'OK' to the text property of wnd[0]/usr/lblPersonas_14988158823869?

Is MD12 and flavor 2 ever rendered?

Cheers!

--

Tobias Queck, SAP Design

SAP Screen Personas

Lead Architect

former_member182659
Participant
0 Kudos

Thanks Tobias for your answer, it's more clear now.

I cannot wait the answer of script 2 inside script 1 as I loose the values of customs fields.

So I will continue directly inside the script 2.

Thanks,

Answers (3)

Answers (3)

former_member182659
Participant
0 Kudos

Hello Tobias and Clemens,

this is the script in Flavor 1 (which is inside a flavor based on MD04)

//launch 2nd flavor
session.startTransaction("MD12");
session.utils.changeFlavor("005056A406741ED78EDE3EAC6A4CC114");//put variable from flavor1.
session.findById("wnd[0]/usr/txtRM61P-PLNUM").text = order_h;
session.findById("wnd[0]/tbar[0]/btn[0]").press();
session.findById("wnd[0]/usr/txtPersonas_14976023036234").text = qty_rec;//launch script in flavor2 (behind a script button)
session.findById("wnd[0]/usr/btnPersonas_149760238257568").press();

After inside the scripting of flavor 1, I have some code to check the result of the script 2.

if(session.findById("wnd[0]/usr/lblPersonas_14988158823869").text !== "OK")

this check always failed.

Thanks,

Emmanuel

clemens_gantert
Active Participant
0 Kudos

Hello Emmanuel,

I assume the values in flavor 2 are calculated with an onLoad or onAfterRefresh script. The onLoad and onAfterRefresh events are only fired if the script from flavor 1 ends in flavor 2 and a flavor 2 screen is then rendered. You can however explicitly execute the scripts in flavor 2 that do the calculation via session.utils.executeScript().

The flow in the flavor 1 script should be:

  1. Go to flavor 2's transaction, session.callTransaction()
  2. Switch to flavor 2, if it's not the default flavor for transaction 2 with session.utils.changeFlavor(), The easiest way is to get this script is to record switching the flavor.
  3. Execute the required flavor 2 scripts with session.utils.executeScript();
  4. Go back to transaction 1, by recording of pressing the back button.

Best Regards,

Clemens

former_member182659
Participant
0 Kudos

see my answer below

TobiasQueck
Advisor
Advisor
0 Kudos

Hi Emanual,

Could you please share the script you are using in Flavor 1?

Cheers!

--

Tobias Queck, SAP Design

SAP Screen Personas

Lead Architect

former_member182659
Participant
0 Kudos

see my answer below