<?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>topic EXIT statement not working in program in Background Processing in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/exit-statement-not-working-in-program-in-background-processing/m-p/8277580#M1633476</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have an requirement where job is scheduled every 3minutes and it calls program ZTEST. But, ZTEST might take more than 3 minutes to complete execution. My requirement is that I want o run the jobs sequentially. I mean 2nd job should start only when 1st job ends. I tried using 'After job' in SM37 but it doesnot work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So,as an alternative, I used funstion module 'TH_GET_WPINFO' to get the if more than one instances of the same program are running or not. Below is the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CALL FUNCTION 'TH_GET_WPINFO'&lt;/P&gt;&lt;P&gt;    TABLES&lt;/P&gt;&lt;P&gt;      wplist     = lit_wpinfo&lt;/P&gt;&lt;P&gt;    EXCEPTIONS&lt;/P&gt;&lt;P&gt;      send_error = 1&lt;/P&gt;&lt;P&gt;      OTHERS     = 2.&lt;/P&gt;&lt;P&gt;  IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;    MOVE sy-repid TO lw_report.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    DELETE lit_wpinfo WHERE wp_report &amp;lt;&amp;gt; lw_report.          "lw_report has REPORTNAME in it.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    DESCRIBE TABLE lit_wpinfo LINES lw_count.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    IF lw_count &amp;gt; 1. " Here I check if 2nd job is executing the same program or not.&lt;/P&gt;&lt;P&gt;      EXIT.    "Here I want to exit from the program.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But, the problem that I am facing is that, the EXIT is not working in background if I write it inside IF statement. I tried using STOP and CHECK statements as well. But, none are working if I write it inside IF statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But,if I write EXIT. outside IF statement, it works. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please let me know,if any one has suggetsions on this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 21 Sep 2011 18:21:57 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-09-21T18:21:57Z</dc:date>
    <item>
      <title>EXIT statement not working in program in Background Processing</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/exit-statement-not-working-in-program-in-background-processing/m-p/8277580#M1633476</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have an requirement where job is scheduled every 3minutes and it calls program ZTEST. But, ZTEST might take more than 3 minutes to complete execution. My requirement is that I want o run the jobs sequentially. I mean 2nd job should start only when 1st job ends. I tried using 'After job' in SM37 but it doesnot work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So,as an alternative, I used funstion module 'TH_GET_WPINFO' to get the if more than one instances of the same program are running or not. Below is the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CALL FUNCTION 'TH_GET_WPINFO'&lt;/P&gt;&lt;P&gt;    TABLES&lt;/P&gt;&lt;P&gt;      wplist     = lit_wpinfo&lt;/P&gt;&lt;P&gt;    EXCEPTIONS&lt;/P&gt;&lt;P&gt;      send_error = 1&lt;/P&gt;&lt;P&gt;      OTHERS     = 2.&lt;/P&gt;&lt;P&gt;  IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;    MOVE sy-repid TO lw_report.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    DELETE lit_wpinfo WHERE wp_report &amp;lt;&amp;gt; lw_report.          "lw_report has REPORTNAME in it.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    DESCRIBE TABLE lit_wpinfo LINES lw_count.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    IF lw_count &amp;gt; 1. " Here I check if 2nd job is executing the same program or not.&lt;/P&gt;&lt;P&gt;      EXIT.    "Here I want to exit from the program.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But, the problem that I am facing is that, the EXIT is not working in background if I write it inside IF statement. I tried using STOP and CHECK statements as well. But, none are working if I write it inside IF statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But,if I write EXIT. outside IF statement, it works. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please let me know,if any one has suggetsions on this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Sep 2011 18:21:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/exit-statement-not-working-in-program-in-background-processing/m-p/8277580#M1633476</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-21T18:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: EXIT statement not working in program in Background Processing</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/exit-statement-not-working-in-program-in-background-processing/m-p/8277581#M1633477</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;bad idea srry &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Manu D'Haeyer on Sep 21, 2011 11:16 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Sep 2011 18:52:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/exit-statement-not-working-in-program-in-background-processing/m-p/8277581#M1633477</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-21T18:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: EXIT statement not working in program in Background Processing</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/exit-statement-not-working-in-program-in-background-processing/m-p/8277582#M1633478</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To answer your question, it means lwa_count does not have value more than 1...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Back to your problem to run a job depending on another...&lt;/P&gt;&lt;P&gt;You can use events (transaction SM62) to control Job execution..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Create an event and schedule a job with an event and program &lt;/P&gt;&lt;P&gt;2. Use BP_EVENT_RAISE to raise that event which will trigger the job..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Sep 2011 20:55:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/exit-statement-not-working-in-program-in-background-processing/m-p/8277582#M1633478</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-21T20:55:42Z</dc:date>
    </item>
  </channel>
</rss>

