Skip to Content

Calling script inside a flavor from a different flavor

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Jul 17, 2017 at 03:12 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • 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,

  • Jun 29, 2017 at 05:10 PM

    Hi Emanual,

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

    Cheers!

    --

    Tobias Queck, SAP Design

    SAP Screen Personas

    Lead Architect

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 29, 2017 at 05:30 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 14, 2017 at 10:07 AM

    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

    Add comment
    10|10000 characters needed characters exceeded