<?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: performance issue - processing over a million records in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-processing-over-a-million-records/m-p/7423824#M1549662</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;&amp;gt; will COMMIT WORK AND WAIT serves the purpose.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have done everything fine. In general a commit should be done when a business transaction  is completed.&lt;/P&gt;&lt;P&gt;That is when all your records are processed, exactly like you did it. The system administrators have to try their best&lt;/P&gt;&lt;P&gt;to provide a setup that can handle frequently used business transactions (is your case a frequently used one?)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once we decide to commit in between a business transaction we have to implement a restart logic... that would &lt;/P&gt;&lt;P&gt;then be your task to create a logging for your batches... which ones are commited which ones are not... and in case&lt;/P&gt;&lt;P&gt;of problems... restart and process only those ones that have not been processed so far.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hermann&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 10 Nov 2010 13:25:27 GMT</pubDate>
    <dc:creator>HermannGahm</dc:creator>
    <dc:date>2010-11-10T13:25:27Z</dc:date>
    <item>
      <title>performance issue - processing over a million records</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-processing-over-a-million-records/m-p/7423823#M1549661</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi SDN&lt;/P&gt;&lt;P&gt;there's a file of over million records sitting in the application server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i'm reading the file into an internal table and passing batches of 100,000 records at a time to the standard BAPI BAPI_ACC_GL_POSTING_POST.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;after entire file is processed successfully, and only if no errors exist, i'm doing the COMMIT WORK. &lt;/P&gt;&lt;P&gt;but due to this the roll back area occupies lot of memory and the processing time took is 6hrs. sometime it ends in memory shortage &amp;amp; the job gets cancelled.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basis team asks me to do the COMMIT WORK frequently to avoid more memory consumption of rollback area which inturn increase the performance. &lt;/P&gt;&lt;P&gt;but the problem is in case of an error in the file and  some records are already posted by then with COMMIT WORK. how to roll back those documents.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;will COMMIT WORK AND WAIT serves the purpose.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;awaiting your suggestions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Suman.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Nov 2010 13:19:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-processing-over-a-million-records/m-p/7423823#M1549661</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-11-10T13:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: performance issue - processing over a million records</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-processing-over-a-million-records/m-p/7423824#M1549662</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;&amp;gt; will COMMIT WORK AND WAIT serves the purpose.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have done everything fine. In general a commit should be done when a business transaction  is completed.&lt;/P&gt;&lt;P&gt;That is when all your records are processed, exactly like you did it. The system administrators have to try their best&lt;/P&gt;&lt;P&gt;to provide a setup that can handle frequently used business transactions (is your case a frequently used one?)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once we decide to commit in between a business transaction we have to implement a restart logic... that would &lt;/P&gt;&lt;P&gt;then be your task to create a logging for your batches... which ones are commited which ones are not... and in case&lt;/P&gt;&lt;P&gt;of problems... restart and process only those ones that have not been processed so far.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hermann&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Nov 2010 13:25:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-processing-over-a-million-records/m-p/7423824#M1549662</guid>
      <dc:creator>HermannGahm</dc:creator>
      <dc:date>2010-11-10T13:25:27Z</dc:date>
    </item>
    <item>
      <title>Re: performance issue - processing over a million records</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-processing-over-a-million-records/m-p/7423825#M1549663</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would go for Hermann's second suggestion, implement a restart functionality. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This logic works fine for me in a similar setting:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;say 100,000 items to be posted:&lt;/P&gt;&lt;P&gt;- store all in a Z-table,&lt;/P&gt;&lt;P&gt;- commit work&lt;/P&gt;&lt;P&gt;loop:&lt;/P&gt;&lt;P&gt;  - bundle 100 into a document and post with BAPI&lt;/P&gt;&lt;P&gt;  - update these 100 items in Z table with status and or document number&lt;/P&gt;&lt;P&gt;  - commit work (or rollback)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If anything bombs along the way, you can restart for those items in the Z-table that don't have correct status or missing document number. The Z-table can be reorganized regularly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Addition: the nice thing about the loop part above is that these blocks can be started in parallel using aRFC technique&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Nov 2010 14:22:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-processing-over-a-million-records/m-p/7423825#M1549663</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2010-11-10T14:22:42Z</dc:date>
    </item>
    <item>
      <title>Re: performance issue - processing over a million records</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-processing-over-a-million-records/m-p/7423826#M1549664</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Thomas.&lt;/P&gt;&lt;P&gt;i've applied frequent commit works for every 990 records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now i'm trying to apply parallel processing on it.&lt;/P&gt;&lt;P&gt;it's creating few documents. thereafter it's falling over with "memory no more paging" dumps.&lt;/P&gt;&lt;P&gt;in the logic i applied the condition to wait until the work processes are free &amp;amp; also the received results &amp;gt;= send tasks.&lt;/P&gt;&lt;P&gt;but still it's falling over.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pls check the below code.&lt;/P&gt;&lt;P&gt;suggest me for any corrections. once all the work processes are fully occupied, i need to wait for the work to be done, then pass the next batch of records for posting.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*-- Posting
    if lv_free_workproc = 0.
      do.
        CALL FUNCTION 'SPBT_GET_CURR_RESOURCE_INFO'
          IMPORTING
            free_pbt_wps                = lv_free_workproc
          EXCEPTIONS
            internal_error              = 1
            pbt_env_not_initialized_yet = 2
            OTHERS                      = 3.
        IF lv_free_workproc &amp;gt; 0.
          EXIT.
        ELSE.
          lv_seconds = '1'.
***          WAIT UNTIL lv_free_workproc &amp;gt; 0 UP TO lv_seconds SECONDS.
              DO.
                lv_seconds = '1'.
                WAIT UNTIL rcv_jobs &amp;gt;= snd_jobs UP TO lv_seconds SECONDS.
                IF rcv_jobs &amp;gt;= snd_jobs OR sy-index = 60.
                  EXIT.
                ENDIF.
              ENDDO.
*          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
*                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
        ENDDO.
      endif.

        CALL FUNCTION 'ZGL_ACCOUNT_POSTING' STARTING NEW TASK lv_taskname
          DESTINATION IN GROUP lv_server_grp
          PERFORMING return_pproc_result ON END OF TASK
          EXPORTING
            is_documentheader     = ls_doc_hdr
          TABLES
            it_accountgl          = lt_gl_account
            it_currencyamount     = lt_currency
            it_extension1         = lt_ext1
          EXCEPTIONS
            system_failure        = 1
            communication_failure = 2
            resource_failure      = 3.
        CASE sy-subrc.
          WHEN 0.
            snd_jobs = snd_jobs + 1.
            lv_free_workproc = lv_free_workproc - 1.
          WHEN 1 OR 2.
            MESSAGE 'Error' TYPE 'I'.
          WHEN 3.
            IF snd_jobs &amp;gt;= 1 AND
               exc_flag = 0.
              exc_flag = 1.
              DO.
                lv_seconds = '1'.
                WAIT UNTIL rcv_jobs &amp;gt;= snd_jobs UP TO lv_seconds SECONDS.
                IF rcv_jobs &amp;gt;= snd_jobs OR sy-index = 60.
                  EXIT.
                ENDIF.
              ENDDO.
              ENDIF.
              IF sy-subrc = 0.
                exc_flag = 0.
              ELSE.
                MESSAGE 'Resource failure' TYPE 'I'.
              ENDIF.
            WHEN OTHERS.
              MESSAGE 'Other error' TYPE 'I'.
          ENDCASE.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;Suman.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Thomas Zloch on Nov 15, 2010 3:40 PM - code tags added&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Nov 2010 14:27:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-processing-over-a-million-records/m-p/7423826#M1549664</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-11-15T14:27:16Z</dc:date>
    </item>
    <item>
      <title>Re: performance issue - processing over a million records</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-processing-over-a-million-records/m-p/7423827#M1549665</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As for the memory problem, make sure that after each call you are clearing all internal tables that you use to collect document data for one posting.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As for your code snippet, hard to judge from the distance, let me briefly outline my flow logic instead:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;call function SPBT_INITIALIZE once to determine proc_max
proc_use = proc_max - n   (n = number of work processes to remain available)
loop at items
  bundle x items into one document, once document complete:
  do
    wait until proc_active &amp;lt; proc_use up to 1 seconds
    call Z-function starting new task ... performing end_of_arfc at end of task.
    if sy-subrc = 0
      add 1 to proc_active
      exit
    elseif sy-subrc = 3
      stay in do-loop
    else
      call z-function the "normal way" (no aRFC)
      exit
    endif
  enddo
  clear document data!
endloop

form end_of_arfc
  receive results ...
  subtract 1 from proc_active
endform&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Nov 2010 15:18:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-processing-over-a-million-records/m-p/7423827#M1549665</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2010-11-15T15:18:45Z</dc:date>
    </item>
  </channel>
</rss>

