<?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 Re: Schedule a pgm in background using function modules from same program in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/schedule-a-pgm-in-background-using-function-modules-from-same-program/m-p/3995323#M954523</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes definatly it will create infinite loop unless you set some variables ... and check them when you submit the program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
PARAMETERS: P_RUN AS CHECKBOX.  " when it is on, it will create a job

start-of-selection.
IF P_RUN = 'X'.

* call funcation JOB_OPEN

  SUBMIT &amp;lt;PROG&amp;gt;  "WITHOUT P_RUN = 'X'
   with jobname jobcount

* call function JOB_CLOSE

ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naimesh Patel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 11 Jun 2008 18:15:27 GMT</pubDate>
    <dc:creator>naimesh_patel</dc:creator>
    <dc:date>2008-06-11T18:15:27Z</dc:date>
    <item>
      <title>Schedule a pgm in background using function modules from same program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/schedule-a-pgm-in-background-using-function-modules-from-same-program/m-p/3995322#M954522</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to schedule a program in background(using function modules) from same program itself.&lt;/P&gt;&lt;P&gt;When click 'execute' button in report, it should schedule same program in background.&lt;/P&gt;&lt;P&gt;As per my knowledge, this will create an infinite loop if we schedule it normally from same program. How we can restrict the program to schedule it only once.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope you guys have already faced the same..&lt;/P&gt;&lt;P&gt;Pls help...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Saj&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jun 2008 18:05:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/schedule-a-pgm-in-background-using-function-modules-from-same-program/m-p/3995322#M954522</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-11T18:05:07Z</dc:date>
    </item>
    <item>
      <title>Re: Schedule a pgm in background using function modules from same program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/schedule-a-pgm-in-background-using-function-modules-from-same-program/m-p/3995323#M954523</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes definatly it will create infinite loop unless you set some variables ... and check them when you submit the program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
PARAMETERS: P_RUN AS CHECKBOX.  " when it is on, it will create a job

start-of-selection.
IF P_RUN = 'X'.

* call funcation JOB_OPEN

  SUBMIT &amp;lt;PROG&amp;gt;  "WITHOUT P_RUN = 'X'
   with jobname jobcount

* call function JOB_CLOSE

ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naimesh Patel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jun 2008 18:15:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/schedule-a-pgm-in-background-using-function-modules-from-same-program/m-p/3995323#M954523</guid>
      <dc:creator>naimesh_patel</dc:creator>
      <dc:date>2008-06-11T18:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: Schedule a pgm in background using function modules from same program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/schedule-a-pgm-in-background-using-function-modules-from-same-program/m-p/3995324#M954524</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi this is the example for this program..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: number           TYPE tbtcjob-jobcount, &lt;/P&gt;&lt;P&gt;      name             TYPE tbtcjob-jobname VALUE 'JOB_TEST', &lt;/P&gt;&lt;P&gt;      print_parameters TYPE pri_params. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'JOB_OPEN' &lt;/P&gt;&lt;P&gt;  EXPORTING &lt;/P&gt;&lt;P&gt;    jobname          = name &lt;/P&gt;&lt;P&gt;  IMPORTING &lt;/P&gt;&lt;P&gt;    jobcount         = number &lt;/P&gt;&lt;P&gt;  EXCEPTIONS &lt;/P&gt;&lt;P&gt;    cant_create_job  = 1 &lt;/P&gt;&lt;P&gt;    invalid_job_data = 2 &lt;/P&gt;&lt;P&gt;    jobname_missing  = 3 &lt;/P&gt;&lt;P&gt;    OTHERS           = 4. &lt;/P&gt;&lt;P&gt;IF sy-subrc = 0. &lt;/P&gt;&lt;P&gt;  SUBMIT submitable TO SAP-SPOOL &lt;/P&gt;&lt;P&gt;                    SPOOL PARAMETERS print_parameters &lt;/P&gt;&lt;P&gt;                    WITHOUT SPOOL DYNPRO &lt;/P&gt;&lt;P&gt;                    VIA JOB name NUMBER number &lt;/P&gt;&lt;P&gt;                    AND RETURN. &lt;/P&gt;&lt;P&gt;  IF sy-subrc = 0. &lt;/P&gt;&lt;P&gt;    CALL FUNCTION 'JOB_CLOSE' &lt;/P&gt;&lt;P&gt;      EXPORTING &lt;/P&gt;&lt;P&gt;        jobcount             = number &lt;/P&gt;&lt;P&gt;        jobname              = name &lt;/P&gt;&lt;P&gt;        strtimmed            = 'X' &lt;/P&gt;&lt;P&gt;      EXCEPTIONS &lt;/P&gt;&lt;P&gt;        cant_start_immediate = 1 &lt;/P&gt;&lt;P&gt;        invalid_startdate    = 2 &lt;/P&gt;&lt;P&gt;        jobname_missing      = 3 &lt;/P&gt;&lt;P&gt;        job_close_failed     = 4 &lt;/P&gt;&lt;P&gt;        job_nosteps          = 5 &lt;/P&gt;&lt;P&gt;        job_notex            = 6 &lt;/P&gt;&lt;P&gt;        lock_failed          = 7 &lt;/P&gt;&lt;P&gt;        OTHERS               = 8. &lt;/P&gt;&lt;P&gt;    IF sy-subrc &amp;lt;&amp;gt; 0. &lt;/P&gt;&lt;P&gt;      ... &lt;/P&gt;&lt;P&gt;    ENDIF. &lt;/P&gt;&lt;P&gt;  ENDIF. &lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jun 2008 18:30:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/schedule-a-pgm-in-background-using-function-modules-from-same-program/m-p/3995324#M954524</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-11T18:30:28Z</dc:date>
    </item>
    <item>
      <title>Re: Schedule a pgm in background using function modules from same program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/schedule-a-pgm-in-background-using-function-modules-from-same-program/m-p/3995325#M954525</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use SY-BATCH to differentiate between your First Call and the Rest of the Calls.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since you will call the Program in Foreground for the First time SY-BATCH will be initial and the Report will be scheduled in Background. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now the Scheduled Report (Background) , will inturn check for the field SY-BATCH. Since SY-BATCH will be filled this time, your code of Submit Via Job will be skipped. So there will be no Recurrsion in the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Aj&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jun 2008 18:53:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/schedule-a-pgm-in-background-using-function-modules-from-same-program/m-p/3995325#M954525</guid>
      <dc:creator>former_member195698</dc:creator>
      <dc:date>2008-06-11T18:53:46Z</dc:date>
    </item>
  </channel>
</rss>

