<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Check for popup within script in Additional Q&amp;A</title>
    <link>https://community.sap.com/t5/additional-q-a/check-for-popup-within-script/qaa-p/3106825#M18349</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bastian,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;just as an additional reply.... check for "session.ActiveWindow.Type". You can distinguish "GuiMainWindow" and "GuiModalWindow". That's how you catch a popup the easiest way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Werner&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 22 Feb 2016 12:59:49 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2016-02-22T12:59:49Z</dc:date>
    <item>
      <title>Check for popup within script</title>
      <link>https://community.sap.com/t5/additional-q-a/check-for-popup-within-script/qaq-p/3106819</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi folks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am quite new to VBscripting and trying to create a script that automatically mass generates users via SU01.&lt;/P&gt;&lt;P&gt;Everything worked fine so far but now I am stuck because of a stupid popup.&lt;/P&gt;&lt;P&gt;If a user was created and afterwards deleted and I am going to recreate it, SAP will ask me if I want to use his old office data.&lt;/P&gt;&lt;P&gt;If it does my script gets stuck of course because it wants to continue to supply the user details.&lt;/P&gt;&lt;P&gt;Please have a look at the code (problem is &lt;B&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;bold&lt;/P&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dim strFilename, Dialog, fso, conentTextfile&lt;/P&gt;&lt;P&gt;Dim Test&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set Dialog = CreateObject("MSComDlg.CommonDialog")&lt;/P&gt;&lt;P&gt;Set fsobj = CreateObject("Scripting.FileSystemObject")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'Explorer-Dialog zum Öffnen von Dateien&lt;/P&gt;&lt;P&gt;'Titelzeile&lt;/P&gt;&lt;P&gt;Dialog.DialogTitle = "Datei öffnen"&lt;/P&gt;&lt;P&gt;'Suchmaske (hier benutzerdefiniertes Dateikürzel)&lt;/P&gt;&lt;P&gt;Dialog.Filter = "Textdateien-Datei (&lt;STRONG&gt;.txt)|&lt;/STRONG&gt;.txt"&lt;/P&gt;&lt;P&gt;'Filterindex&lt;/P&gt;&lt;P&gt;Dialog.FilterIndex = 1&lt;/P&gt;&lt;P&gt;Dialog.MaxFileSize = 260 &lt;/P&gt;&lt;P&gt;'Flags setzen: Explorer-Dialog mit langen Dateinamen&lt;/P&gt;&lt;P&gt;Dialog.Flags = &amp;amp;H1814&lt;/P&gt;&lt;P&gt;'Datei öffnen&lt;/P&gt;&lt;P&gt;Dialog.ShowOpen&lt;/P&gt;&lt;P&gt;'Ergebnis der Dateianwahl ausgeben&lt;/P&gt;&lt;P&gt;strFilename = Dialog.Filename&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If strFilename &amp;lt;&amp;gt; "" Then&lt;BR /&gt;Set textfile = fsobj.OpenTextFile(strFilename,"1")&lt;BR /&gt; do while not textfile.AtEndOfStream&lt;BR /&gt; 'Zeilen einzeln einlesen&lt;BR /&gt; TextLine = textfile.ReadLine&lt;BR /&gt; UserData = Split(TextLine,",")&lt;BR /&gt;&lt;BR /&gt;If Not IsObject(application) Then&lt;BR /&gt; Set SapGuiAuto = GetObject("SAPGUI")&lt;BR /&gt; Set application = SapGuiAuto.GetScriptingEngine&lt;BR /&gt;End If&lt;BR /&gt;If Not IsObject(connection) Then&lt;BR /&gt; Set connection = application.Children(0)&lt;BR /&gt;End If&lt;BR /&gt;If Not IsObject(session) Then&lt;BR /&gt; Set session = connection.Children(0)&lt;BR /&gt;End If&lt;BR /&gt;If IsObject(WScript) Then&lt;BR /&gt; WScript.ConnectObject session, "on"&lt;BR /&gt; WScript.ConnectObject application, "on"&lt;BR /&gt;End If&lt;BR /&gt;session.findById("wnd[0]").maximize&lt;BR /&gt;session.findById("wnd[0]/usr/ctxtUSR02-BNAME").text = UserData(0)&lt;BR /&gt;session.findById("wnd[0]/usr/ctxtUSR02-BNAME").caretPosition = 7&lt;BR /&gt;session.findById("wnd[0]/tbar[1]/btn[8]").press&lt;BR /&gt;&lt;BR /&gt;'Here is the problem!!!&lt;BR /&gt;&lt;B&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;Test = session.findById("wnd[1]").Type&lt;BR /&gt;if test = "GuiModalWindow" then&lt;BR /&gt;session.findById("wnd[1]/usr/btnBUTTON_1").press&lt;BR /&gt; end if&lt;BR /&gt;'If I check for the popup window (as shown above) and the user didn't exist before (so there is no popup window) the program will exit with an exception because wnd[1] doesn't exist. Is there any possibility to check wether wnd[1] exists?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpADDR/ssubMAINAREA:SAPLSZA5:0900/txtADDR3_DATA-NAME_LAST").text = UserData(1)&lt;/P&gt;&lt;P&gt;session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpADDR/ssubMAINAREA:SAPLSZA5:0900/txtADDR3_DATA-NAME_FIRST").text = UserData(2)&lt;/P&gt;&lt;P&gt;session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpADDR/ssubMAINAREA:SAPLSZA5:0900/txtADDR3_DATA-NAME_FIRST").setFocus&lt;/P&gt;&lt;P&gt;session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpADDR/ssubMAINAREA:SAPLSZA5:0900/txtADDR3_DATA-NAME_FIRST").caretPosition = 10&lt;/P&gt;&lt;P&gt;session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpLOGO").select&lt;/P&gt;&lt;P&gt;session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpLOGO/ssubMAINAREA:SAPLSUU5:0101/pwdG_PASSWORD1").text = UserData(4)&lt;/P&gt;&lt;P&gt;session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpLOGO/ssubMAINAREA:SAPLSUU5:0101/pwdG_PASSWORD2").text = UserData(5)&lt;/P&gt;&lt;P&gt;session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpLOGO/ssubMAINAREA:SAPLSUU5:0101/ctxtUSLOGOND-CLASS").text = UserData(3)&lt;/P&gt;&lt;P&gt;session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpLOGO/ssubMAINAREA:SAPLSUU5:0101/ctxtUSLOGOND-GLTGV").text = UserData(6)&lt;/P&gt;&lt;P&gt;session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpLOGO/ssubMAINAREA:SAPLSUU5:0101/ctxtUSLOGOND-GLTGB").text = UserData(7)&lt;/P&gt;&lt;P&gt;session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpLOGO/ssubMAINAREA:SAPLSUU5:0101/ctxtUSLOGOND-GLTGB").setFocus&lt;/P&gt;&lt;P&gt;session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpLOGO/ssubMAINAREA:SAPLSUU5:0101/ctxtUSLOGOND-GLTGB").caretPosition = 10&lt;/P&gt;&lt;P&gt;session.findById("wnd[0]/tbar[0]/btn[11]").press&lt;/P&gt;&lt;P&gt;loop&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;End If&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set Dialog = Nothing&lt;/P&gt;&lt;P&gt;Set fso = Nothing&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance and kind regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bastian&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Nov 2007 15:13:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/additional-q-a/check-for-popup-within-script/qaq-p/3106819</guid>
      <dc:creator>bastian_schneider2</dc:creator>
      <dc:date>2007-11-26T15:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: Check for popup within script</title>
      <link>https://community.sap.com/t5/additional-q-a/check-for-popup-within-script/qaa-p/3106820#M18344</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;You can have error handling code to write the error in log and continue the program running. make On Error Resume Next statement in the beginning of the code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jan 2008 06:36:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/additional-q-a/check-for-popup-within-script/qaa-p/3106820#M18344</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-31T06:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: Check for popup within script</title>
      <link>https://community.sap.com/t5/additional-q-a/check-for-popup-within-script/qaa-p/3106821#M18345</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it is an error in VB/VBA, you should work with errorhandlers. If it is an error (msgbox) in SAPGUI, then you should turn this off by:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Property messageAsPopup As Boolean (Read only)
Description:	Some message may be displayed not only on the
		statusbar but also as a pop-up window. In such
		cases, this property is set to True so that a 
		script knows it has to close a pop-up continue.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good Luck&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Feb 2008 09:47:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/additional-q-a/check-for-popup-within-script/qaa-p/3106821#M18345</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-07T09:47:54Z</dc:date>
    </item>
    <item>
      <title>Re: Check for popup within script</title>
      <link>https://community.sap.com/t5/additional-q-a/check-for-popup-within-script/qaa-p/3106822#M18346</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bastian,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also came across similar scenario need to handle unexpected popup. I have found a simple solution as below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    If Session.ActiveWindow.Name = "wnd[1]" Then&lt;/P&gt;&lt;P&gt;        If Session.findbyid("wnd[1]").Text Like "Delete*" Then Session.findbyid("wnd[1]/usr/btnSPOP-OPTION1").press&lt;/P&gt;&lt;P&gt;    End If&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 May 2010 06:45:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/additional-q-a/check-for-popup-within-script/qaa-p/3106822#M18346</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-26T06:45:44Z</dc:date>
    </item>
    <item>
      <title>Re: Check for popup within script</title>
      <link>https://community.sap.com/t5/additional-q-a/check-for-popup-within-script/qaa-p/3106823#M18347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi HanKeat,&lt;/P&gt;&lt;P&gt;Thank you!&amp;nbsp; I have been looking for a simple way to do this for years and I stumbled across this.&amp;nbsp; It works perfectly!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Jan 2016 20:56:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/additional-q-a/check-for-popup-within-script/qaa-p/3106823#M18347</guid>
      <dc:creator>former_member863284</dc:creator>
      <dc:date>2016-01-19T20:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: Check for popup within script</title>
      <link>https://community.sap.com/t5/additional-q-a/check-for-popup-within-script/qaa-p/3106824#M18348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks HanKeat&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It helped me lot&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 Feb 2016 12:45:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/additional-q-a/check-for-popup-within-script/qaa-p/3106824#M18348</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-02-21T12:45:19Z</dc:date>
    </item>
    <item>
      <title>Re: Check for popup within script</title>
      <link>https://community.sap.com/t5/additional-q-a/check-for-popup-within-script/qaa-p/3106825#M18349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bastian,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;just as an additional reply.... check for "session.ActiveWindow.Type". You can distinguish "GuiMainWindow" and "GuiModalWindow". That's how you catch a popup the easiest way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Werner&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Feb 2016 12:59:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/additional-q-a/check-for-popup-within-script/qaa-p/3106825#M18349</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-02-22T12:59:49Z</dc:date>
    </item>
  </channel>
</rss>

