When working with optional or dynamic windows or frames, you can use verification functions to determine if the window or object is available. An optional window is a window that does not consistently open during the SAP session. This function allow the Vuser script to continue running even if an optional window opens or an exception occurs.
The first example checks if a window is available. If the window is available, the Vuser closes it before continuing.
if (!sapgui_is_object_available("wnd[1]"))
sapgui_call_method("{ButtonID}",
"press",
LAST,
AdditionalInfo=info1011");
sapgui_press_button(.....)
The next example illustrates a dynamic object in the ME51N transaction. The Document overview frame is optional, and can be opened/closed by the Document overview on/off button.
The code checks the text on the Document overview button. If the text on the button shows Document overview on, click the button to close the Document overview frame.
if(sapgui_is_object_available("tbar[1]/btn[9]"))
{
sapgui_get_text("Document overview on/off button",
"tbar[1]/btn[9]",
"paramButtonText",
LAST);
if(0 == strcmp("Document overview off", lr_eval_string("{paramButtonText}")))
sapgui_press_button("Document overview off",
"tbar[1]/btn[9]",
BEGIN_OPTIONAL,
"AdditionalInfo=sapgui1013",
END_OPTIONAL);
}
Back to top