<?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 Running ABAP Program in Background in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/running-abap-program-in-background/m-p/2336377#M514459</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;I need to write a program which could run in background mode based on some condition. For example, I have two radio buttons, Excel and Spool. If I select Excel the program should run normally in foreground mode. If I select spool the program should run in background mode and save the out put in spool.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanking you in advance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Eswar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 15 Jun 2007 09:45:21 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-06-15T09:45:21Z</dc:date>
    <item>
      <title>Running ABAP Program in Background</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/running-abap-program-in-background/m-p/2336377#M514459</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;I need to write a program which could run in background mode based on some condition. For example, I have two radio buttons, Excel and Spool. If I select Excel the program should run normally in foreground mode. If I select spool the program should run in background mode and save the out put in spool.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanking you in advance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Eswar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jun 2007 09:45:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/running-abap-program-in-background/m-p/2336377#M514459</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-15T09:45:21Z</dc:date>
    </item>
    <item>
      <title>Re: Running ABAP Program in Background</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/running-abap-program-in-background/m-p/2336378#M514460</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;&lt;/P&gt;&lt;P&gt;if p_spool is not intial.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call Fm JOB_OPEn&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call FM JOB_SUBMIT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call fm  job_close.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;else.&lt;/P&gt;&lt;P&gt;ur program logic.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Revert back if any issues,&lt;/P&gt;&lt;P&gt;Reward with points if helpful ,&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;Naveen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jun 2007 09:48:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/running-abap-program-in-background/m-p/2336378#M514460</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-15T09:48:20Z</dc:date>
    </item>
    <item>
      <title>Re: Running ABAP Program in Background</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/running-abap-program-in-background/m-p/2336379#M514461</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;Check for SY-BATCH if it is in background.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Vasanth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jun 2007 09:49:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/running-abap-program-in-background/m-p/2336379#M514461</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-15T09:49:28Z</dc:date>
    </item>
    <item>
      <title>Re: Running ABAP Program in Background</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/running-abap-program-in-background/m-p/2336380#M514462</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes when sy-batch = 'X' the program is executed in the background.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jun 2007 09:59:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/running-abap-program-in-background/m-p/2336380#M514462</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-15T09:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: Running ABAP Program in Background</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/running-abap-program-in-background/m-p/2336381#M514463</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;long time ago, I found this coding at &lt;A href="http://www.4ap.de" target="test_blank"&gt;http://www.4ap.de&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;This coding ask in a popup for running in background, when the select-option fields &lt;B&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;s_carrid&lt;/P&gt; and &lt;B&gt;&lt;P&gt;s_connid&lt;/P&gt;&lt;/B&gt; are intitial.&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps you....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stefan &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
TABLES: sflight.

DATA: BEGIN OF i_sflight OCCURS   0,
        carrid LIKE sflight-carrid,
        connid LIKE sflight-connid,
        fldate LIKE sflight-fldate,
        currency LIKE sflight-currency,
        paymentsum LIKE sflight-paymentsum,
        zielbetrag LIKE sflight-paymentsum,
      END OF i_sflight.

DATA: sw_int(1) TYPE p.
DATA  answer.
DATA: job LIKE tbtcjob-jobname.
DATA: num LIKE rsjobinfo-jobnumb.

SELECT-OPTIONS: s_carrid FOR sflight-carrid,
                s_connid FOR sflight-connid.
PARAMETERS:     p_curr LIKE tcurr-tcurr OBLIGATORY DEFAULT 'EUR'.


AT SELECTION-SCREEN.
  CLEAR answer.
  CHECK sy-batch IS INITIAL AND sy-ucomm NE 'JOBS'.
  IF s_carrid[] IS INITIAL AND
     s_connid[] IS INITIAL.
    CALL FUNCTION 'POPUP_TO_DECIDE'
         EXPORTING
              textline1      = 'Sie haben nichts eingeschränkt!'(001)
              textline2      = 'Das Programm wird voraussichtlich'(002)
              textline3      = 'länger laufen.'(003)
              text_option1   = 'Im Hintergrund'(004)
              text_option2   = 'Trotzdem ausführen'(005)
              titel          = 'Achtung, Langläufer!'(006)
         IMPORTING
              answer         = answer
         EXCEPTIONS
              OTHERS         = 1.
    CASE answer.
      WHEN '1'.
        CONCATENATE sy-uname sy-repid INTO job SEPARATED BY '_'.
        CALL FUNCTION 'JOB_OPEN'
             EXPORTING
                  jobname          = job
             IMPORTING
                  jobcount         = num
             EXCEPTIONS
                  cant_create_job  = 1
                  invalid_job_data = 2
                  jobname_missing  = 3
                  OTHERS           = 4.
        SUBMIT (sy-repid)
                TO SAP-SPOOL
                VIA SELECTION-SCREEN
                VIA JOB job NUMBER num
                WITH s_carrid IN s_carrid
                WITH s_connid IN s_connid
                WITH p_curr = p_curr
                AND RETURN.
        CALL FUNCTION 'JOB_CLOSE'
             EXPORTING
                  jobcount                    = num
                  jobname                     = job
                  strtimmed                   = 'X'
             EXCEPTIONS
                  cant_start_immediate        = 1
                  invalid_startdate           = 2
                  jobname_missing             = 3
                  job_close_failed            = 4
                  job_nosteps                 = 5
                  job_notex                   = 6
                  lock_failed                 = 7
                  OTHERS                      = 8.
        IF sy-subrc = 0.
          MESSAGE s311(tg) WITH job num.
*   Der Batch Job &amp;amp; wurde mit der Nummer &amp;amp; eingeplant
        ELSE.
          MESSAGE e102(ss).
*   Fehler bei der Joberzeugung
        ENDIF.
      WHEN '2'.
      WHEN 'A'.
        SET CURSOR FIELD s_carrid-low.
        MESSAGE e055(c/).
*    Die Selektion ist zu umfangreich. Bitte einschränken.
    ENDCASE.
  ENDIF.

START-OF-SELECTION.
  CHECK sy-ucomm NE 'JOBS' AND answer NE '1'.
  SELECT carrid connid fldate currency paymentsum
         INTO TABLE i_sflight
         FROM sflight
         WHERE carrid IN s_carrid.
  LOOP AT i_sflight.
    FORMAT COLOR COL_NORMAL INTENSIFIED = sw_int.
    sw_int = 1 - sw_int.
    CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
         EXPORTING
              date              = sy-datum
              foreign_amount    = i_sflight-paymentsum
              foreign_currency  = i_sflight-currency
              local_currency    = p_curr
         IMPORTING
              local_amount      = i_sflight-zielbetrag
         EXCEPTIONS
              no_rate_found     = 1
              overflow          = 2
              no_factors_found  = 3
              no_spread_found   = 4
              OTHERS            = 5.
    MODIFY i_sflight TRANSPORTING zielbetrag.
    WRITE: / i_sflight-carrid,
             i_sflight-connid,
             i_sflight-fldate,
             i_sflight-paymentsum CURRENCY i_sflight-currency,
             i_sflight-currency,
             i_sflight-zielbetrag CURRENCY p_curr,
             p_curr,
             AT sy-linsz ''.
    AT END OF connid.
      SUM.
      FORMAT COLOR COL_TOTAL INTENSIFIED OFF.
      WRITE: / i_sflight-carrid,
               i_sflight-connid,
            10 'Summe',
               i_sflight-zielbetrag CURRENCY p_curr
                                    UNDER i_sflight-zielbetrag,
               p_curr,
               AT sy-linsz ''.
    ENDAT.
    AT END OF carrid.
      SUM.
      FORMAT COLOR COL_TOTAL INTENSIFIED ON.
      WRITE: / i_sflight-carrid,
            10 'Summe',
               i_sflight-zielbetrag CURRENCY p_curr
                                    UNDER i_sflight-zielbetrag,
               p_curr,
               AT sy-linsz ''.
      NEW-PAGE.
    ENDAT.
    AT LAST.
      SUM.
      FORMAT COLOR COL_TOTAL INTENSIFIED OFF.
      WRITE: /10 'Gesamtsumme:',
               i_sflight-zielbetrag CURRENCY p_curr
                                    UNDER i_sflight-zielbetrag,
               p_curr,
               AT sy-linsz ''.
    ENDAT.
  ENDLOOP.


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jun 2007 10:57:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/running-abap-program-in-background/m-p/2336381#M514463</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-15T10:57:40Z</dc:date>
    </item>
  </channel>
</rss>

