Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How check if exists the field? SAP GUI Scripting

Tags:

sap-gui

How check if exists the field? I tried it:

If session.findById("wnd[1]").setFocus Then
like image 465
Nicholas Giudice Avatar asked Aug 30 '25 16:08

Nicholas Giudice


2 Answers

To avoid using error handling you can use:

If Not session.findById("wnd[1]", False) Is Nothing Then
    session.findById("wnd[1]").setFocus
End If

The key here is the second parameter in FindById which determines if it raises an error or not if the field or any object in SAP exists. If it is set to False there is no error raised and the object is set to Nothing which you can check as in my code.

like image 128
Dávid Jenei Avatar answered Sep 03 '25 23:09

Dávid Jenei


you can try e.g. the following:

on error resume next
session.findById("wnd[1]").setfocus
if err.number = 0 then
   msgbox "The SAP GUI element exists."
else
   msgbox "The SAP GUI element does not exist."
end if
on error goto 0

Regards, ScriptMan

like image 20
ScriptMan Avatar answered Sep 03 '25 23:09

ScriptMan