Skip to Content
0
Sep 28, 2019 at 06:13 PM

Performance issue with BAPI_ACC_DOCUMENT_POST

1065 Views Last edit Sep 28, 2019 at 06:29 PM 3 rev

Hello All,

Does anyone know or have experienced any performance issue with BAPI_ACC_DOCUMENT_POST?

I'm using this bapi ABAP code but is very slow, each document posting takes almost up to 1,4 minutes.

Each document contain 998 line items (debit and credit).

This program run a batch job. I'm posting 38 documents on an average takes up to 55 minutes.

After the posting, the program checking the processing message returned by the BAPI.

Would something have to be done in this situation or would it be necessary to parallelize this part of the code?

So how to implement multiple BAPI calls (parallelism). Have you any idea? May be another approach?

Thanks in advance,

 CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
      EXPORTING
        documentheader = wa_document-documentheader
      IMPORTING
        obj_key        = lv_obj_key
      TABLES
        accountgl      = wa_document-accountgl_t
        currencyamount = wa_document-currencyamount_t
        criteria       = lt_criteria
        extension1     = lt_extension1
        return         = lt_return.


    DELETE lt_return WHERE type   EQ c_msg_type_e
                       AND id     EQ c_id_rw
                       AND number EQ c_msgnumb_609.


    READ TABLE lt_return
      WITH KEY type = c_msg_type_e
      INTO wa_return.
    IF sy-subrc EQ 0.


      PERFORM f_store_message
        USING wa_document
              wa_return
              abap_true
              space.
    ELSE.


      DESCRIBE TABLE lt_return LINES lv_lines.
      READ TABLE lt_return INTO wa_return INDEX lv_lines.
      IF sy-subrc EQ 0.


        IF wa_return-type EQ c_msg_type_s.


          CLEAR wa_return_commit.
          CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
            EXPORTING
              wait   = abap_true
            IMPORTING
              return = wa_return_commit.
          IF NOT wa_return_commit IS INITIAL.


            PERFORM f_store_message
              USING wa_document
                    wa_return_commit
                    abap_true
                    space.
          ELSE.


            PERFORM f_store_message
              USING wa_document
                    wa_return
                    abap_true
                    space.


            PERFORM f_add_item_txt_long
              USING lv_obj_key
                    wa_document-itm_text_t.


          ENDIF.


        ELSE.


          PERFORM f_store_message
            USING wa_document
                  wa_return
                  abap_true
                  space.
        ENDIF.
      ENDIF.
    ENDIF.