<?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: SAP scripting with Python: Handle unexpected error messages/pop up window in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/sap-scripting-with-python-handle-unexpected-error-messages-pop-up-window/qaa-p/12246286#M4585656</link>
    <description>&lt;P&gt;there are generally finite places the scripted process will raise an "unexpected pop-up" &lt;BR /&gt;my strategy would be the same as in VBA, &amp;amp; its not on error resume next. &lt;BR /&gt;its functionally test for the presence of something &amp;amp; then have logic to address it. &lt;BR /&gt;For simple cases I'd check the button on the window exists:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;'###catch not existing elements###
    If Not session.findById("wnd[1]/usr/btnBUTTON_2", False) Is Nothing Then
        session.findById("wnd[1]/usr/btnBUTTON_2").press
    End If
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;for more complex stuff: &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Dim pop                         As SAPFEWSELib.GuiModalWindow

Set pop = session.FindById("wnd[1]")&lt;BR /&gt;'check if pop is not nothing
'then do something
pop.FindById("tbar[0]/btn[0]").Press&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;I've even made subroutines just called CheckForUnexpectedPopups() &lt;/P&gt;&lt;P&gt;then pass it the session &amp;amp; then come back for the rest of the flow. &lt;/P&gt;&lt;P&gt;I imagine there is trivial equivalents in python.&lt;/P&gt;</description>
    <pubDate>Wed, 28 Oct 2020 23:07:10 GMT</pubDate>
    <dc:creator>daniel_mccollum</dc:creator>
    <dc:date>2020-10-28T23:07:10Z</dc:date>
    <item>
      <title>SAP scripting with Python: Handle unexpected error messages/pop up window</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-scripting-with-python-handle-unexpected-error-messages-pop-up-window/qaq-p/12246284</link>
      <description>&lt;P&gt;Hello,I'm trying to read out data from diffrent transactions in &lt;STRONG&gt;SAP through the scripting function&lt;/STRONG&gt;.I already did it successfully in &lt;STRONG&gt;VBA&lt;/STRONG&gt;, now I want to do it with &lt;STRONG&gt;Python&lt;/STRONG&gt; to run the scripts outside of the Microsoft Office environment. &lt;/P&gt;
  &lt;P&gt;I am new to Python and realised to handle errors is quite different than in VBA. For some processes I use the try and &lt;CODE&gt;exception&lt;/CODE&gt; handling, there where I know how the code shall process after an error appeared.&lt;/P&gt;
  &lt;P&gt;But what if an unexpected error occurs? My problem is I want to continue with the &lt;CODE&gt;Try&lt;/CODE&gt; block where the error occurs after I handle the error event in the &lt;CODE&gt;exception&lt;/CODE&gt; block but I learnt in Python it is not possible. Something like &lt;CODE&gt;On Error Resume Next&lt;/CODE&gt; doesn't exist. To wrap every code line in &lt;CODE&gt;try&lt;/CODE&gt; &lt;CODE&gt;exception&lt;/CODE&gt; block of the large script can't be the single solution.&lt;/P&gt;
  &lt;P&gt;Is there a possibilty when the main code interrupts, a second event shall be fired to handle the error and after that the main code shall continue?&lt;/P&gt;
  &lt;P&gt;Especially for my problem the main idea is an error/pop up window in SAP should be traced and closes by a second event while the main event is paused and continues when the first event finishes.&lt;/P&gt;
  &lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 17:12:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-scripting-with-python-handle-unexpected-error-messages-pop-up-window/qaq-p/12246284</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2020-10-28T17:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: SAP scripting with Python: Handle unexpected error messages/pop up window</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-scripting-with-python-handle-unexpected-error-messages-pop-up-window/qaa-p/12246285#M4585655</link>
      <description>&lt;P&gt;Thank you for visiting SAP Community to get answers to your questions. Since you're asking a question here for the first time, I recommend that you familiarize yourself with &lt;A href="https://community.sap.com/resources/questions-and-answers" target="test_blank"&gt;https://community.sap.com/resources/questions-and-answers&lt;/A&gt; (if you haven't already), as it provides tips for preparing questions that draw responses from our members. 
Should you wish, you can revise your question by selecting Actions, then Edit.
Finally, if you're hoping to connect with readers, please consider adding a picture to your profile. Here's how you do it: &lt;A href="https://www.youtube.com/watch?v=F5JdUbyjfMA&amp;amp;list=PLpQebylHrdh5s3gwy-h6RtymfDpoz3vDS" target="test_blank"&gt;https://www.youtube.com/watch?v=F5JdUbyjfMA&amp;amp;list=PLpQebylHrdh5s3gwy-h6RtymfDpoz3vDS&lt;/A&gt;. By personalizing your profile with a photo of you, you encourage readers to respond.&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Jennifer&lt;/P&gt;&lt;P&gt;SAP Community moderator&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 17:15:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-scripting-with-python-handle-unexpected-error-messages-pop-up-window/qaa-p/12246285#M4585655</guid>
      <dc:creator>former_member34</dc:creator>
      <dc:date>2020-10-28T17:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: SAP scripting with Python: Handle unexpected error messages/pop up window</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-scripting-with-python-handle-unexpected-error-messages-pop-up-window/qaa-p/12246286#M4585656</link>
      <description>&lt;P&gt;there are generally finite places the scripted process will raise an "unexpected pop-up" &lt;BR /&gt;my strategy would be the same as in VBA, &amp;amp; its not on error resume next. &lt;BR /&gt;its functionally test for the presence of something &amp;amp; then have logic to address it. &lt;BR /&gt;For simple cases I'd check the button on the window exists:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;'###catch not existing elements###
    If Not session.findById("wnd[1]/usr/btnBUTTON_2", False) Is Nothing Then
        session.findById("wnd[1]/usr/btnBUTTON_2").press
    End If
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;for more complex stuff: &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Dim pop                         As SAPFEWSELib.GuiModalWindow

Set pop = session.FindById("wnd[1]")&lt;BR /&gt;'check if pop is not nothing
'then do something
pop.FindById("tbar[0]/btn[0]").Press&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;I've even made subroutines just called CheckForUnexpectedPopups() &lt;/P&gt;&lt;P&gt;then pass it the session &amp;amp; then come back for the rest of the flow. &lt;/P&gt;&lt;P&gt;I imagine there is trivial equivalents in python.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 23:07:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-scripting-with-python-handle-unexpected-error-messages-pop-up-window/qaa-p/12246286#M4585656</guid>
      <dc:creator>daniel_mccollum</dc:creator>
      <dc:date>2020-10-28T23:07:10Z</dc:date>
    </item>
    <item>
      <title>Re: SAP scripting with Python: Handle unexpected error messages/pop up window</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-scripting-with-python-handle-unexpected-error-messages-pop-up-window/qaa-p/12246287#M4585657</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;thanks for your solution, to solve such problems in VB is not a big deal. &lt;/P&gt;&lt;P&gt;Quote: "...then pass it the session &amp;amp; then come back for the rest of the flow..."&lt;/P&gt;&lt;P&gt;That's the issue, I can't pass such functions in the session block because such popup can occurs anytime/anywhere, even if there are only finite places. To find the exact spots in every transaction makes it more complicated. Moreover to jump "back" to the rest of the code after handling an error in python is not possible (or till now I am not aware of it).&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2020 17:54:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-scripting-with-python-handle-unexpected-error-messages-pop-up-window/qaa-p/12246287#M4585657</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2020-11-06T17:54:33Z</dc:date>
    </item>
  </channel>
</rss>

