Skip to Content
0
Former Member
Jan 04, 2012 at 04:54 PM

BAPI_ACC_DOCUMENT_POST

331 Views

Hi, I am using the below code to create a vendor invoice, but I keep getting the error "FI/CO interface: Balance in transaction currency". Now the vendor and the compnay code are both setup as GBP, and the 2 lines I am posting are simply fro £10, so it all balances correctly. And if I enter the data manually in FB60 then everything works fine. I have searched the forums and the code seems to match everythign that I am seeing, so I am stuck as to what is causing the issue. Any help appreciated..

* fill the header
  s_documentheader-comp_code  = i_company_code.
  s_documentheader-doc_date   = i_invoice_date.
  s_documentheader-pstng_date = i_invoice_date.
  s_documentheader-ref_doc_no = i_invoice_ref.
  s_documentheader-header_txt = i_text.
  s_documentheader-username   = sy-uname.
* added these columns
  s_documentheader-doc_type   = 'KR'.
  s_documentheader-bus_act    = 'RFBU'.
  s_documentheader-obj_type   = 'BKPFF'.
  s_documentheader-obj_key    = '$'.
  s_documentheader-obj_sys    = sy-mandt.

* retrieve GL account no
  select single gl_account from zfi_post_accnts
     into l_account
    where post_type = 'RTI' and posting_key = '40'.

  call function 'CONVERSION_EXIT_ALPHA_INPUT'
    exporting
      input  = l_account
    importing
      output = l_account.

* format the vendor number
  call function 'CONVERSION_EXIT_ALPHA_INPUT'
    exporting
      input         = me->number
   IMPORTING
     OUTPUT        = s_accountpayable-vendor_no.

* get the currency
  select single waers from t001 into lv_currency
         where bukrs = i_company_code.


**(1) Fill Venodor Line item
  clear: s_accountreceivable, s_currencyamount.
  s_accountpayable-itemno_acc = 1.
  s_accountpayable-vendor_no     = lv_vendor.
  s_accountpayable-item_text     = i_text.
  s_accountpayable-comp_code     = i_company_code.
*  s_ACCOUNTPAYABLE-GL_ACCOUNT    = l_account.
*  s_accountpayable-PYMT_CUR      = 'GBP'.
*  s_accountpayable-PYMT_CUR_ISO  = 'GBP'.
*  s_accountpayable-PYMT_AMT      = i_invoiced_amount.
  append s_accountpayable to it_accountpayable.
*
  s_currencyamount-itemno_acc = 1.
  s_currencyamount-curr_type  = '00'.
  s_currencyamount-amt_doccur = i_invoiced_amount.
  s_currencyamount-currency   = lv_currency.
  s_currencyamount-currency_iso = lv_currency.
  append s_currencyamount to it_currencyamount.

**(2) Fill GL Account Line item.
  s_accountgl-itemno_acc = 2.
  s_accountgl-gl_account = l_account.
  s_accountgl-item_text  = i_text.
  s_accountgl-comp_code  = i_company_code.
*  s_accountgl-profit_ctr =
  append s_accountgl to it_accountgl.
*
  s_currencyamount-itemno_acc = 2.
  s_currencyamount-curr_type  = '00'.
  s_currencyamount-amt_doccur = i_invoiced_amount.
  s_currencyamount-currency   = lv_currency.
  s_currencyamount-currency_iso = lv_currency.
  append s_currencyamount to it_currencyamount.


  call function 'BAPI_ACC_DOCUMENT_POST'
    exporting
      documentheader    = s_documentheader
    importing
      obj_type          = l_type
      obj_key           = l_key
      obj_sys           = l_sys
    tables
      accountgl         = it_accountgl
*      accountreceivable = it_accountreceivable
      accountpayable    = it_accountpayable
      accounttax        = it_accounttax
      currencyamount    = it_currencyamount
      return            = it_return
       exceptions
      others            = 1.