sapgui_is_object_available
| Verification and Data Retrieval Functions |
Checks if you can refer to the object in a function.
int sapgui_is_object_available( const char *object_name, [args,] LAST );
| object_name | Object ID Strings |
| args | Optional Arguments |
| LAST | A marker indicating the end of the argument list. Not required if Optional Arguments are used. |
The sapgui_is_object_available verification function checks if the specified object is available for use in a function.
Sometimes, though you recorded a script that refers to an object, it may not be available during relay depending on the results of previous actions. Examples are pop-up windows that only appear under certain conditions or objects that appear on a window depending on the state of another object, like an expand button.
A reference to an unavailable object causes the script to crash. Avoid such script crashes by using sapgui_is_object_available before calling a function that acts on the object.
Return Values
This function returns True (-1) or False (0).
Parameterization
You can parameterize all string (char type) arguments.
Example
The following example uses sapgui_is_object_available to see if a grid is visible. If not, it clicks the expand button that displays it. After ensuring that the grid is visible the script can work with it.
sapgui_set_ok_code("/nme51n", LAST );sapgui_send_vkey(ENTER, LAST );
// Store Grid ID in "ContainerObjectID" to make code more readable
lr_save_string("usr/subSUB0:SAPLMEGUI:0016/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:3212/cntlGRIDCONTROL/shellcont/shell",
"ContainerObjectID");
// Store expand button ID in "ButtonID"
lr_save_string( "usr/subSUB0:SAPLMEGUI:0016/subSUB2:SAPLMEVIEWS:1100/subSUB1:SAPLMEVIEWS:4001/btnDYN_4000-BUTTON", "ButtonID");// If the grid is not available, click the expand button
if ( !sapgui_is_object_available("{ContainerObjectID}", LAST))
sapgui_call_method("{ButtonID}",
"press",
LAST );// It is now certain that the grid is available.

