Skip to Content
0
Former Member
May 11, 2007 at 10:46 AM

Regarding BAPI_ACC_DOCUMENT_POST

631 Views

Hi ,

I am trying to execute the BAPI ' BAPI_ACC_DOCUMENT_POST ' for the transaction FB70.

I tried to execute directly using SE37 as well as through a program.

As some body suggested in one existing thread , i am using the following program :

*-----Making the Header

x_invheader-obj_type = 'BKPFF'. "Reference procedure

x_invheader-obj_key = '$'. "Object key

CONCATENATE sy-sysid 'CLNT' sy-mandt INTO

x_invheader-obj_sys. "Logical system of source document

x_invheader-bus_act = 'RFBU'. "Business Transaction

x_invheader-username = sy-uname. "User name

x_invheader-header_txt = x_header-col7. "Document Header Text

x_invheader-comp_code = x_header-col3. "Company Code

x_invheader-doc_date = v_doc_date. "Document Date in Document

x_invheader-pstng_date = v_pstng_date. "Posting Date in the Document

x_invheader-doc_type = 'DR'. "Reference Document Number

x_invheader-ref_doc_no = x_header-col4. "Reference Document Number

*-----For ACCOUNTRECEIVABLE

LOOP AT it_header INTO x_header.

x_bapiacar09-itemno_acc = '1'. "Accounting Document Line Item Number

*-----Filling zeros before Customer No

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = x_header-col2

IMPORTING

output = v_customer.

x_bapiacar09-customer = v_customer. "Customer Number 1

x_bapiacar09-comp_code = x_header-col3. "Company Code

APPEND x_bapiacar09 TO it_bapiacar09.

ENDLOOP.

*-----For ACCOUNTGL

LOOP AT it_lineitem INTO x_lineitem.

IF it_bapiacgl09 IS INITIAL.

v_itemno = 2.

ELSE.

v_itemno = v_itemno + 1.

ENDIF.

x_bapiacgl09-itemno_acc = v_itemno. "Accounting Document Line Item Number

*-----Filling zeros before G/L Account no

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = x_lineitem-col10

IMPORTING

output = v_gl_account.

x_bapiacgl09-gl_account = v_gl_account. "General Ledger Account

x_bapiacgl09-comp_code = x_lineitem-col11. "Company Code

x_bapiacgl09-profit_ctr = x_lineitem-col14. "Profit Center

x_bapiacgl09-item_text = x_lineitem-col15. "Item Text

APPEND x_bapiacgl09 TO it_bapiacgl09.

ENDLOOP.

*-----Clearing variable

CLEAR : v_itemno.

*-----For CURRENCYAMOUNT

LOOP AT it_header INTO x_header.

x_bapiaccr09-itemno_acc = '0000000001'. "Accounting Document Line Item Number

x_bapiaccr09-curr_type = '00'. "Currency type and valuation view

x_bapiaccr09-amt_doccur = x_header-col8. "Amount in document currency

x_bapiaccr09-currency = x_header-col9. "Currency Key

APPEND x_bapiaccr09 TO it_bapiaccr09.

ENDLOOP.

v_itemno_1 = 1.

LOOP AT it_lineitem INTO x_lineitem.

v_itemno_1 = v_itemno_1 + 1.

x_bapiaccr09_temp-itemno_acc = v_itemno_1. "Accounting Document Line Item Number

x_bapiaccr09_temp-curr_type = '00'. "Currency type and valuation view

CONCATENATE '-' x_lineitem-col12 INTO v_amount.

x_bapiaccr09_temp-amt_doccur = v_amount. "x_lineitem-col12. "Amount in document currency

x_bapiaccr09_temp-currency = x_lineitem-col13. "Currency Key

APPEND x_bapiaccr09_temp TO it_bapiaccr09.

ENDLOOP.

CLEAR : v_itemno_1.

*-----Calling BAPI for creating Customer Invoice

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

EXPORTING

documentheader = x_invheader

IMPORTING

obj_key = v_obj_key

TABLES

accountgl = it_bapiacgl09

accountreceivable = it_bapiacar09

currencyamount = it_bapiaccr09

return = return.

But, I am getting the following error.

Error in document: BKPF $ QPTCLNT200

Incorrect entry in field OBJ_TYPE: BKPF

Could some body please help me out ?

And ,i want to know the significance of BKPF and BKPFF i.e. what they means?

Thanks in advance,

Srini