<?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: BAPI_MATERIAL_SAVEDATA in background task in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-material-savedata-in-background-task/m-p/11911651#M1963223</link>
    <description>&lt;P&gt;You can use the &lt;A href="https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/iabapcall_function_background_unit.htm"&gt;Background RFC&lt;/A&gt; once, during execution of standard transaction to prevent breaking of the LUW.&lt;/P&gt;&lt;P&gt;But during the execution of the FM, use a &lt;A href="https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abapcall_function_starting.htm"&gt;RFC asynchronous call&lt;/A&gt; and handle the number of currently running processes, either use a &lt;A href="https://help.sap.com/viewer/search?q=RFC%20server%20group"&gt;RFC server group &lt;/A&gt;(RZ12)&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;" to use a RZ12 defined group (with limits in its definition)
 CALL FUNCTION 'Z_ASSIGN_PROC' STARTING NEW TASK nbtask
                DESTINATION NONE IN GROUP group
                CALLING minus1 ON END OF TASK.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;EM&gt;NB: Also handle the foillowing exceptions in the call : system_failure, communication_failure and resource_failure.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;or, if you don't (want to) use a group, handle the number of task yourself (+1 after call, -1 in the called method). &lt;/P&gt;&lt;P&gt;&lt;EM&gt;NB: To get max/available number of process use FM SPBT_INITIALIZE at start of loop.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;If you actually want to use batch process, then don't call your FM RFC mode, but rewrite your code in a small report, and use JOP_OPEN/SUBMIT/JOB_CLOSE instead.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 01 Apr 2019 11:47:53 GMT</pubDate>
    <dc:creator>RaymondGiuseppi</dc:creator>
    <dc:date>2019-04-01T11:47:53Z</dc:date>
    <item>
      <title>BAPI_MATERIAL_SAVEDATA in background task</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-material-savedata-in-background-task/m-p/11911649#M1963221</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
  &lt;P&gt;Case: There is a need to extending material with a specific view like plant, warehouse, Sales Organizations, etc. Due to the very large amount of data, it was decided to start the extending process in the background task. &lt;/P&gt;
  &lt;UL&gt; 
   &lt;LI&gt;Created FM: "call function Z_ASSIGN_PROC in background task" &lt;/LI&gt; 
   &lt;LI&gt;Inside of FM: loop by materials, inside of loop: BAPI_MATERIAL_SAVEDATA &lt;/LI&gt; 
  &lt;/UL&gt;
  &lt;P&gt;But, after running fm in background task, i see to many DIA process in SM50. They take up all the free processes, and it is very stressful to the system... &lt;/P&gt;
  &lt;P&gt;Can anybody explain, why this happens? &lt;/P&gt;
  &lt;P&gt;Why are DIA processes created instead of BTS?&lt;/P&gt;
  &lt;P&gt;Is it possible to wrap DIA processes of BAPI_MATERIAL_SAVEDATA to the one BTC process?&lt;/P&gt;
  &lt;P&gt;Main program like:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;  loop at lt_matnr assigning field-symbol(&amp;lt;ls_matnr&amp;gt;).

    if lines( lt_id ) = c_counter.

      do.

        loop at lt_id assigning field-symbol(&amp;lt;ls_id&amp;gt;).

          data(lv_tabix) = sy-tabix.

          call function 'STATUS_OF_BACKGROUNDTASK'
            exporting
              tid           = &amp;lt;ls_id&amp;gt;-tid
            tables
              errortab      = lt_errtab
            exceptions
              communication = 1
              recorded      = 2
              rollback      = 3
              others        = 4.

          if sy-subrc = 0.

            data(lv_exit) = abap_true.
            delete lt_id index lv_tabix.

            exit.

          else.

            lv_exit = abap_false.

          endif.

        endloop.

        if lv_exit = abap_true.

          exit.

        endif.

      enddo.

    endif.

    lv_taskname = &amp;lt;ls_matnr&amp;gt;.

      call function 'Z_ASSIGN_PROC'
        in background task
        exporting
          iv_matnr              = &amp;lt;ls_matnr&amp;gt;
          it_werks              = s_werks[]
          it_lgnum              = s_lgnum[]
        exceptions
          communication_failure = 1
          resource_failure      = 2
          system_failure        = 3
          others                = 4.

      call function 'ID_OF_BACKGROUNDTASK'
        importing
          tid  = ls_tid
          fnum = lv_fnum.

      append value #(
                      tid  = ls_tid
                      fnum = lv_fnum
                    ) to lt_id.

      " Start'Z_ASSIGN_PROC'
      commit work.

endloop.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;FM Z_ASSIGN_PROC like:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;loop at lt_t001w assigning field-symbol(&amp;lt;ls_t001w&amp;gt;).

" fill bapi's structures

  call function 'BAPI_MATERIAL_SAVEDATA'
	...
  if sy-subrc = 0.

        call function 'BAPI_TRANSACTION_COMMIT'
          exporting
            wait = abap_true.
  endif.

  loop at lt_warehouse assigning field-symbol(&amp;lt;ls_wh&amp;gt;) where werks eq &amp;lt;ls_t001w&amp;gt;-werks.

"   fill bapi's structures

    call function 'BAPI_MATERIAL_SAVEDATA'
	...
    if sy-subrc = 0.

          call function 'BAPI_TRANSACTION_COMMIT'
            exporting
              wait = abap_true.
    endif.

  endloop.

endloop.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Mar 2019 16:09:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-material-savedata-in-background-task/m-p/11911649#M1963221</guid>
      <dc:creator>life1</dc:creator>
      <dc:date>2019-03-29T16:09:40Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_MATERIAL_SAVEDATA in background task</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-material-savedata-in-background-task/m-p/11911650#M1963222</link>
      <description>&lt;P&gt;In background task means transactional RFC (tRFC).&lt;/P&gt;&lt;P&gt;All kind of RFC run in DIA workprocesses only.&lt;/P&gt;&lt;P&gt;No, it can't run in BTC workprocesses.&lt;/P&gt;&lt;P&gt;There are some profile parameters to adjust the maximum number of DIA workprocesses which can be assigned to RFC tasks. You should ask your administrator some proposals to less stress the system.&lt;/P&gt;</description>
      <pubDate>Sat, 30 Mar 2019 20:58:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-material-savedata-in-background-task/m-p/11911650#M1963222</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2019-03-30T20:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_MATERIAL_SAVEDATA in background task</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-material-savedata-in-background-task/m-p/11911651#M1963223</link>
      <description>&lt;P&gt;You can use the &lt;A href="https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/iabapcall_function_background_unit.htm"&gt;Background RFC&lt;/A&gt; once, during execution of standard transaction to prevent breaking of the LUW.&lt;/P&gt;&lt;P&gt;But during the execution of the FM, use a &lt;A href="https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abapcall_function_starting.htm"&gt;RFC asynchronous call&lt;/A&gt; and handle the number of currently running processes, either use a &lt;A href="https://help.sap.com/viewer/search?q=RFC%20server%20group"&gt;RFC server group &lt;/A&gt;(RZ12)&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;" to use a RZ12 defined group (with limits in its definition)
 CALL FUNCTION 'Z_ASSIGN_PROC' STARTING NEW TASK nbtask
                DESTINATION NONE IN GROUP group
                CALLING minus1 ON END OF TASK.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;EM&gt;NB: Also handle the foillowing exceptions in the call : system_failure, communication_failure and resource_failure.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;or, if you don't (want to) use a group, handle the number of task yourself (+1 after call, -1 in the called method). &lt;/P&gt;&lt;P&gt;&lt;EM&gt;NB: To get max/available number of process use FM SPBT_INITIALIZE at start of loop.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;If you actually want to use batch process, then don't call your FM RFC mode, but rewrite your code in a small report, and use JOP_OPEN/SUBMIT/JOB_CLOSE instead.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2019 11:47:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-material-savedata-in-background-task/m-p/11911651#M1963223</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2019-04-01T11:47:53Z</dc:date>
    </item>
  </channel>
</rss>

