Skip to Content
author's profile photo Former Member
Former Member

Performance Issue when Using BAPI

Hi All,

We are creating sales order via BAPI. We are expecting around 2000 per file. At the start of the processing, it creates about 20 orders in a minute. However, as the file progresses, the performance is really degrading. It creates about 5-6 orders in a minute. Is there any idea on how to improve the performance? Is it because of the memory allocation used by the BAPI? BAPI_TRANSACTION_COMMIT is used every after SO is created. I have seen that this BAPI is refreshing the buffers used. Will this suffice? How do I free up the memory used by the BAPI each time I create a new order? I am suspecting this has something to do with memory allocation in the BAPI. I have already used the STARTING NEW TASK with the BAPI, on the hope that it will improve the performance.

Any help is appreciated.

Thanks,

Louisse

Edited by: Louisse Heartsdale on Sep 13, 2011 3:17 PM

Add a comment
10|10000 characters needed characters exceeded

Related questions

6 Answers

  • Posted on Sep 13, 2011 at 02:01 PM

    Hello Louisse,

    one possible solution would be to reprogram your sales order creation for parallel processing in separate dialog work processes.

    Please refer to this documentation:

    http://help.sap.com/saphelp_nw04/helpdata/en/fa/096e92543b11d1898e0000e8322d00/frameset.htm

    Kind regards,

    Yuri

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 13, 2011 at 02:03 PM

    Did you doa trace using ST05?

    Sure you dont want to modify the BAPI, but still if you find out what takes him so long (probably some of the selects inside), you could get an idea if providing additional info could speed up those selects.

    Maybe additional data could help you to hit a index for big selects and so speed up the process.

    But until you dont know WHAT exactly is beeing slow, it´s quite hard to generate an idea on how to speed things up.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 13, 2011 at 03:43 PM

    Hello,

    We have had to deal with a requirement to process create 12,000 orders per night, with up to 45,000 on occasions. We used the standard BAPI, BAPI_SALESORDER_CREATE_FROM_DAT2. The process creates about 15 orders a second in batch. Among the techniques we used were:

    Chop the data up into 3 sets and have 3 batch jobs running in parallel on the DB server. We were able to do this as the batch load on the machine is low at the time these jobs run. We call BAPI_TRANSACTION every 100 orders.

    We did extensive run time analysis of the BAPI, BAPI_SALESORDER_CREATE_FROM_DAT2 and found that program exits were doing unnecessary extra reads of tables such as KNA1 when the front end program calling the BAPI was already doing this.

    We found the BAPI spent time calling routines that weren't needed (eg. LIS and Inbound Deliveries). We were unable to see how to switch these off, nor did we want to go 'inside' the BAPI to use the internal FM that SAP would use the create the sales order.

    The sales orders were very simple (no more than 5 lines), but most were rush orders meaning that we were creating a delivery as well.. There was no availability checking.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 13, 2011 at 06:59 PM

    Hi,

    starting fast and getting slower suggests (sorry if some of these sound stupid, I am just brainstorming here):

    - File being read from the beginning each time.

    - intermediate result being selected into internal table in a loop and not cleared for next iteration (table gets bigger each loop)

    - SAP - enqueues not released fast enough causing contention

    Second thing:

    Your calling new tasks with customer function module and call the BAPI as end-of task.

    How do you keep track, that all started childs have finished?

    Shouldn't you call a customer function on end-of-task to count down that alll tasks are finished

    so that your memory is not released too early...

    Like

    ...build packages

    loop at packages

    increase counter

    start new task with package (end-of task -> call customer fm, that does processing and decreases counter)

    endloop

    wait until counter = 0

    Volker

    Add a comment
    10|10000 characters needed characters exceeded

    • answer continued...

      Now coming to my proposal from my last post (first all creates, then all changes), here is more details about it.

      Grouping by BAPI method

      The processing of one particular object from the beginning to the end by calling different BAPIs (BAPI_OBJECT_CREATE, BAPI_OBJECT_CHANGE) often requires that the update of one BAPI is completed before the next BAPI could be called. Below you will find a sample how this would look like in a straightforward implementation

      ...

      LOOP AT objects.
        CALL FUNCTION 'BAPI_OBJECT_CREATE'.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          IMPORTING
            WAIT = 'X'.
        CALL FUNCTION 'BAPI_OBJECT_CHANGE'.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          IMPORTING
            WAIT = ' '.
        ENDIF.
      ENDLOOP.

      Instead of doing all actions object by object it could be better to use grouping by BAPI method. Below you will find a sample how this could look like:

      ...

      LOOP AT objects.
        CALL FUNCTION 'BAPI_OBJECT_CREATE'.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          IMPORTING
            WAIT = ' '.
      ENDLOOP.
      LOOP AT objects.
        IF object not exists.
          APPEND object TO object_work_list
        ELSE.
          CALL FUNCTION 'BAPI_OBJECT_CHANGE'.
          CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
            IMPORTING
              WAIT = ' '.
        ENDIF.
      ENDLOOP.

      Reprocess the objects in object_work_list and wait

      The sample will first use method CREATE to create all objects before the objects are going to be changed. Since the second loop starts with the object which was created first, it is highly probable that this object exists and could be changed. If the object does not exist yet it could be put into a work list and processed at a later point in time.

      Regards,

      Yuri

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2011 at 09:58 AM

    Maybe there are not enough processes for executing update requests?

    Maybe you can try to put the command "SET UPDATE TASK LOCAL" at the beginning of your FM 'Z_V_BAPI_SO_CREATEFROMDAT2_RFC'?

    Edited by: Carsten Grafflage on Sep 19, 2011 12:28 PM

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Carsten,

      Sorry for asking this, but would you know what's gonna be the impact if I have more than a thousand records, and then I am calling the BAPI for 1000 times as well, and I'm setting each call to local task? Will that not disrupt the flow of the program? Sorry, as I haven't used the command before.

      Thanks,

      Louisse

  • author's profile photo Former Member
    Former Member
    Posted on Sep 21, 2011 at 09:00 AM

    Let's say you have only two update processes, but you start four parallel worker processes, then two of them have always to wait for their turn (if you have to use COMMIT WORK AND WAIT). But if you use SET UPDATE TASK LOCAL, each of the parallel processes can perform his own update, without the need of the update processes. This can possibly lead to a higher system load, but may be faster.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.