Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

error in BAPI_ACC_DOCUMENT_CHECK

Former Member
0 Likes
455

Hi!

I would like to call function "BAPI_ACC_DOCUMENT_CHECK" and I encounter the error: <i>Type conflict when calling a function module (field length).</i>

First, I upload an excel file. Then, I fill in my document header and line items as below:


* _______________________________________________________ 
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
      FILENAME                = p_file
      I_BEGIN_COL             = '1'
      I_BEGIN_ROW             = '7'
      I_END_COL               = '21'
      I_END_ROW               = '999'
    TABLES
      INTERN                  = intern
    EXCEPTIONS
      INCONSISTENT_PARAMETERS = 1
      UPLOAD_OLE              = 2
      OTHERS                  = 3.

 SORT intern by row col.

* I loop at the intern and append to an internal table 'xcel'.
* then I fill in the document header 'bapiache09'.

      bapiache09-doc_type   = 'PC'. 
      bapiache09-doc_date   = sy-datum.
      bapiache09-pstng_date = p_budat.         "p_budat is declared as 
                                              "bapiache09-pstng_date on selection screen
      bapiache09-comp_code  = 'B000'. 
      bapiache09-header_txt = 'SCTA (AB28)-P11/06'.
      bapiache09-ref_doc_no = 'Test'. 
      bapiache09-username = sy-uname.
      bapiache09-bus_act = 'RFBU'.

* now i fill in the line items
  LOOP AT xcel INTO wa_xcel.

    ADD 1 to item_no.

* internal table of gl account, type bapiacap09
    IF wa_xcel-post_key EQ '40' OR wa_xcel-post_key EQ '50'.
      wa_gl_account-itemno_acc = item_no.
      wa_gl_account-doc_type   = wa_xcel-fld2.
      wa_gl_account-gl_account  = wa_xcel-fld3.
      wa_gl_account-costcenter = wa_xcel-fld7.
      wa_gl_account-alloc_nmbr = wa_xcel-fld11.
      wa_gl_account-item_text  = wa_xcel-fld12.
      wa_gl_account-cs_trans_t = wa_xcel-fld18.
      wa_gl_account-tax_code   = wa_xcel-fld20.
      APPEND wa_gl_account TO gl_account.
      CLEAR wa_gl_account.
* internal table of payable account, type bapiacap09
    ELSEIF wa_xcel-post_key EQ '21' OR wa_xcel-post_key EQ '31'.
      wa_py_account-itemno_acc = item_no.
      wa_py_account-vendor_no  = wa_xcel-fld3.
      wa_py_account-bline_date = wa_xcel-fld5.
      wa_py_account-alloc_nmbr = wa_xcel-fld11.
      wa_py_account-item_text  = wa_xcel-fld12.
      wa_py_account-sp_gl_ind  = wa_xcel-fld14.
      wa_py_account-tax_code   = wa_xcel-fld20.
      APPEND wa_py_account TO py_account.
      CLEAR wa_py_account.
    ENDIF.

* internal table of currency amount, type bapiaccr09.
    wa_curr_amt-itemno_acc = item_no.
    wa_curr_amt-currency = wa_xcel-fld6.
    wa_curr_amt-amt_doccur = wa_xcel-fld15.
    APPEND wa_curr_amt TO curr_amt.
    CLEAR wa_curr_amt.
  ENDLOOP.

  PERFORM bapi_check.
 ENDFORM.                    " fill_line_item

*_______________________________________________
FORM bapi_check .
  DATA: wa_ret_tab    LIKE LINE OF ret_tab.

  CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
    EXPORTING
      DOCUMENTHEADER    = bapiache09
    TABLES
      ACCOUNTGL         = gl_account
      ACCOUNTRECEIVABLE = py_account
      CURRENCYAMOUNT    = curr_amt
      RETURN            = ret_tab.
ENDFORM.

Does anyone know what is the exact problem as I declared all the internal tables according to the type in FM 'BAPI_ACC_DOCUMENT_CHECK'. Why I get the error of type conflict?

thanks in advance!

ying ying..

1 REPLY 1
Read only

Former Member
0 Likes
342

Hi, I have figured out what is the problem, I passed the py_account to ACCOUNTRECEIVABLE. It should be ACCOUNTPAYABLE.


FORM bapi_check . 
  CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
    EXPORTING
      DOCUMENTHEADER    = bapiache09
    TABLES
      ACCOUNTGL         = gl_account
*      ACCOUNTRECEIVABLE = py_account
      

<b>ACCOUNTPAYABLE </b>= py_account

"should be payable account, not receivable account

      CURRENCYAMOUNT    = curr_amt
      RETURN            = ret_tab.
ENDFORM.                    " bapi_check

cheers,

ying