Example of calling a BAPI in tRFC

You cannot call the BAPI BAPI_ACC_DOCUMENT_POST inside the update task because it performs a CALL SCREEN Statement.

You can call the BAPI in tRFC, this should work as follows:

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
        DESTINATION 'NONE'
         EXPORTING
           documentheader    gs_documentheader
         IMPORTING
           obj_key           lv_key
         TABLES
           accountgl         it_accountgl
           accountpayable    it_accountpayable
           accounttax        it_accounttax
           currencyamount    it_currencyamount
           return            it_return  .
  

     IF  sy-subrc = 0.
  
         CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
           DESTINATION 'NONE'
           EXPORTING
             wait 'X'.

         CALL FUNCTION 'RFC_CONNECTION_CLOSE'
           EXPORTING
             destination          'NONE'
           EXCEPTIONS
             destination_not_open 1
             OTHERS               2.

     ENDIF.

Comentários