Skip to Content

Test Automation Challenges – Dynamic SAP GUI screen state (e.g. ME51N)

The following approach is not specific to single test automation tools but applies for most tools in the market like CBTA, eCATT and HP QTP/ HP UFT.

Typical situation when working with dynamic screens

Some transactions like ME51N Create Purchase Requisition remember the state from the last usage of the transaction in the user context. So the start screen in the transaction can have collapsed screen elements


or the screen elements could be expanded


Challenge 1:

You perform a recording for an automated test while all required screen elements are already expanded. When you execute the test script later it might fail because some of the required screen elements can’t be processed as they are not visible. This could happen if same user left the transaction during the last usage in a different state or you are executing the script with a different user or even in a different system.

Challenge 2:

You perform the recording when the required screen element is initially not visible so you record the click on the button that expands it. When you replay the script most likely fails because the initial screen state is now expanded and the related button was replaced by the collapse button (e.g. ME51N).

Recommended Approach:

Before recording:

  1. Check which screen elements are required and get a clear picture of the initial screen state that is required to perform the actual test activities.
  2. Check for shortcuts to prepare the screen to always get to the right state (e.g. to expand the required screen elements). Most times you’ll find the shortcuts with mouse over text for the button (with ME51N) or context menu of right mouse click (ME21N)

During recording:

Shortcuts (e.g. Crtl+F2 and Crtl+F3) should be processed although the necessary screen elements are already expanded to ensure these actions are part of the script.


The recorded script will always ensure that the screen is prepared to meet the expected state and then is able to perform the actual test activities independent from last usage or user context.

You must be Logged on to comment or reply to a post.
  • Great blog Reiner!

    I would also like to add sometimes such kind of situation can also be handled using If-else construct. Such constructs is already present in CBTA - component based test automation.

  • Hello Reiner,

    This is a very smart trick which I had not thought of, thanks for the tip!

    You may already know that SAP has developed custom function patterns, and in particular one which expands all sections of ME2xN and ME5xN transactions.

    See this document from SAP Marketplace (S-user required):

    To use this pattern, all you need to do is:

    - Check-out the RTL

    - Create a new function using the "Code Assistant" button, and select ME21N_ExpandAllSections

    => The corresponding function will be created in a new .vbs file

    - Insert the default component CBTA_GUI_A_INVOKE_FUNCTION at the beginning of your script (usually in second position - after the component CBTA_GUI_A_CHECKTCODE), and call this function

    One step further is to make sure that the tab you are about to fill is already visible - or better, to force to open it first (when you record your script).

    Kind regards,


    • Hello Remi,

      I was contacted for the same kind of problem in transaction MIGO. There are no shortcuts available here and so indeed the use of a custom function is required.

      It is possible to use ME21N_ExpandAllSections as pattern and replace the URI information accordingly in the .vbs file.

      Regards Reiner

      • Hello,

        I am working on CBTA for the recording of the scenarios on the SAP portal.

        I am able to record and execute the simple scenarios.

        But in few cases the recording which I have done on the Portal and when I am trying to execute the recorded scenario again then the values are not getting mapped correctly on the Portal.

        Please let me know how to handle this case.

        Thank you in advance to unblock me.

        Deepanker Mahajan

  • Hello Reiner,

    Very nice document.

    I am looking for similar kind of issue.

    I had tried to resolved similar issue for ME21N for hear detail ( Ctrl+F2) and Item detail, with the addition of default component "CBTA_GUI_A_PRESSKEY" with URI of Hear detail and KEY as Ctrl+F2, but it not work.

    But will try to add shortcut key ( Ctrl+F) in recording itself.

    However just want to ask is there any other alternative for similar kind of issue which we can resolve by adding default component like ( IF, ENDIF, CBTA_GUI_A_PRESSKEY etc.) then please let me know and if any document is available that will be good.



  • Hello, guys

    I have automated many TCE using CBTA, but I am facing some challenges to reuse some transactions,

    for example: there are transactions that were recorded in 2016 and now in 2017 they bring many new warning messages, those messages did not appear when we recorded for first time and making the adaptation of the script takes a lot of time consuming and i think they could apply as Dynamic sap gui

    what is the best way to make a recording considering the warning messages in CBTA?



    Thank you, very nice document.

    We just started using CBTA (SM 7.2 SP6).

    We have a problem. I need advice.

    We save the script, open it and get the error:

    “A row with the index 1 is not in the table.”