<?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: Background job which will execute two programs in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/background-job-which-will-execute-two-programs/m-p/449850#M13644</link>
    <description>&lt;P&gt;Pragmatic solution: Write a third program that calls the other two.&lt;/P&gt;</description>
    <pubDate>Tue, 11 Jul 2017 12:08:31 GMT</pubDate>
    <dc:creator>retired_member</dc:creator>
    <dc:date>2017-07-11T12:08:31Z</dc:date>
    <item>
      <title>Background job which will execute two programs</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/background-job-which-will-execute-two-programs/m-p/449849#M13643</link>
      <description>&lt;P&gt;Hi experts,&lt;/P&gt;
  &lt;P&gt;How to set a background job which will execute first program and take the output as input of the second program and execute it.&lt;/P&gt;
  &lt;P&gt;Any reference program will be helpful.&lt;/P&gt;
  &lt;P&gt;Regards&lt;/P&gt;
  &lt;P&gt;Satya&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2017 12:01:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/background-job-which-will-execute-two-programs/m-p/449849#M13643</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2017-07-10T12:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: Background job which will execute two programs</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/background-job-which-will-execute-two-programs/m-p/449850#M13644</link>
      <description>&lt;P&gt;Pragmatic solution: Write a third program that calls the other two.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 12:08:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/background-job-which-will-execute-two-programs/m-p/449850#M13644</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2017-07-11T12:08:31Z</dc:date>
    </item>
    <item>
      <title>Re: Background job which will execute two programs</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/background-job-which-will-execute-two-programs/m-p/449851#M13645</link>
      <description>&lt;P&gt;Hi Horst,&lt;/P&gt;
  &lt;P&gt;then how will the output of first program will be the input of second program??&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 12:59:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/background-job-which-will-execute-two-programs/m-p/449851#M13645</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2017-07-11T12:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: Background job which will execute two programs</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/background-job-which-will-execute-two-programs/m-p/449852#M13646</link>
      <description>&lt;P&gt; &lt;/P&gt;
  &lt;P&gt;What is the output of a program?&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;What is the input of a program?&lt;/P&gt;
  &lt;P&gt;What do you expect at all?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 13:16:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/background-job-which-will-execute-two-programs/m-p/449852#M13646</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2017-07-11T13:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: Background job which will execute two programs</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/background-job-which-will-execute-two-programs/m-p/449853#M13647</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
  &lt;P&gt;You could try something like this :&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;* Background "print" options
  CALL FUNCTION 'GET_PRINT_PARAMETERS'
    EXPORTING
      no_dialog      = 'X'
    IMPORTING
      out_parameters = print_parameters.
  print_parameters-paart = 'X_62_255'.
  print_parameters-linsz = '132'.
  print_parameters-linct = '108'.
  print_parameters-prrel = space. " direct print
  print_parameters-primm = space. " delete after printing
*-----------------
  nom_prog = sy-repid.
  PERFORM get_spool_name USING nom_prog sy-uname
        CHANGING name.
  CALL FUNCTION 'JOB_OPEN'
    EXPORTING
      jobname          = name
    IMPORTING
      jobcount         = number
    EXCEPTIONS
      cant_create_job  = 1
      invalid_job_data = 2
      jobname_missing  = 3
      OTHERS           = 4.
    CHECK sy-subrc IS INITIAL.
*-----------------
SUBMIT prog1 WITH parameter1 = 'MY VALUE'
                      USING SELECTION-SET 'JOB_DEFAULT'
                      TO SAP-SPOOL
                      SPOOL PARAMETERS print_parameters
                      WITHOUT SPOOL DYNPRO
                      VIA JOB name NUMBER number
                      USER sy-uname
                      AND RETURN.
*------------------
CALL FUNCTION 'JOB_CLOSE'
      EXPORTING
        jobcount             = number
        jobname              = name
        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.
    CHECK sy-subrc IS INITIAL.
*-------------------
* Here you can LOOP with a delay on each iteration. Or just wait X secnds. Or create an EVENT in job and catch it. It depends on average process time of the program.
*-------------------
(LOOP. WAIT X seconds. )
      REFRESH t_spoollist.
      CALL FUNCTION 'BP_JOB_READ'
        EXPORTING
          job_read_jobname  = name
          job_read_jobcount = number
          job_read_opcode   = 36 " read all job data
        TABLES
          spool_attributes  = t_spoollist
        EXCEPTIONS
          job_doesnt_exist  = 1
          OTHERS            = 99.

    CHECK NOT t_spoollist[] IS INITIAL.
    READ TABLE t_spoollist INDEX 1.
    mi_rqident = t_spoollist-spoolid.
(ENDLOOP.)
*--------------

CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'
    EXPORTING
      rqident              = mi_rqident
    TABLES
      buffer               = record
    EXCEPTIONS
      no_such_job          = 1
      not_abap_list        = 2
      job_contains_no_data = 3
      no_permission        = 4
      OTHERS               = 8.

* Now you can loop on RECORD which is a CHAR255 table (depending on your print options)
* You can repeat this process several times &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Jul 2017 13:34:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/background-job-which-will-execute-two-programs/m-p/449853#M13647</guid>
      <dc:creator>bertrand_delvallee</dc:creator>
      <dc:date>2017-07-11T13:34:38Z</dc:date>
    </item>
    <item>
      <title>Re: Background job which will execute two programs</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/background-job-which-will-execute-two-programs/m-p/449854#M13648</link>
      <description>&lt;P&gt;"then how will the output of first program will be the input of second program??"&lt;/P&gt;
  &lt;P&gt;If they are your programs - export the results to memory, export the results to a temporary table, exporting list to memory. read the updated database tables for the values your require&lt;/P&gt;
  &lt;P&gt;If they are SAP custom programs, exporting list to memory, or read the updated database tables.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 13:43:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/background-job-which-will-execute-two-programs/m-p/449854#M13648</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2017-07-11T13:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: Background job which will execute two programs</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/background-job-which-will-execute-two-programs/m-p/449855#M13649</link>
      <description>&lt;P&gt;If they're well designed(!) then it's a simple case of writing a third program that gets the data from the model of the first program and passes it to the model of the second program. One line of ABAP should do it.&lt;/P&gt;
  &lt;P&gt;new model2( new model1( )-&amp;gt;get_results( ) )-&amp;gt;do_stuff( ).&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 14:20:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/background-job-which-will-execute-two-programs/m-p/449855#M13649</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2017-07-11T14:20:31Z</dc:date>
    </item>
  </channel>
</rss>

