2007 May 11 11:46 AM
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
it is bcoz the object ID BKPF is not present in the table that u r using. I am just not able to recall the name of the table in which these object id's are maintained but its the same problem ie objet id is missing.
2007 May 11 12:04 PM
Hello Srinivas
You will find the valid object types in table <b>TTYP</b>. Most likely you have to use 'BKPF'.
For details about the use of object types refer to the F1 help.
Regards
Uwe
2007 May 14 8:42 AM
Hello Uwe,
Thanks for your reply.
But i am getting the following error even i am supplying valid object type 'BKPF'.
Error in document: BKPF $ QPTCLNT200
Incorrect entry in field OBJ_TYPE: BKPF
I want to know why this error is comming and how to resolve this?
FYI : My intension is to create the accounting invoice document(FB70).
Thanks,
Srini
2007 May 14 9:12 AM
Hello Srinivas
I am not sure if it is correct to use the '$' for the object key:
[code]x_invheader-obj_key = '$'. "Object key[/code]
The documentation (of parameter DOCUMENTHEADER) says that the object key represents the key of the original document in the sending system.
Thus, give it a try with <b>obj_key = ' ' (space)</b> and see if the error messages change.
Regards
Uwe
2007 May 14 9:11 AM
it is bcoz the object ID BKPF is not present in the table that u r using. I am just not able to recall the name of the table in which these object id's are maintained but its the same problem ie objet id is missing.
2007 Jul 11 5:45 AM
Hi reddy,
Is it resolved?.I am also facing the same issue. Please let me know if you know the solution.
Thanks in Advance.
Regards,
Raja
2007 Jul 12 9:48 AM
Hello Raja,
Yes, it is resolved.
You can try with OBJ_TYPE = 'IDOC'. For your reference following is program source code that is executing properly .
WA_RETURN LIKE BAPIRET2.
DATA:
WA_CURRENCY TYPE BAPIACCR09,
WA_CUSTOMER TYPE bapiacar09,
WA_RETURN2 TYPE BAPIRET2,
WA_RETURN3 TYPE BAPIRET2,
WA_ACCOUNTGL TYPE BAPIACGL09.
START-OF-SELECTION.
WA_DOCUMENTHEADER-OBJ_TYPE = 'IDOC'.
CONCATENATE SY-SYSID 'CLNT' SY-MANDT INTO WA_DOCUMENTHEADER-OBJ_SYS.
WA_DOCUMENTHEADER-OBJ_KEY = '$'.
WA_DOCUMENTHEADER-USERNAME = SY-UNAME.
WA_DOCUMENTHEADER-COMP_CODE = 'GOVP'.
WA_DOCUMENTHEADER-BUS_ACT = 'RFBU'.
WA_DOCUMENTHEADER-HEADER_TXT = 'BAPI TEST'.
WA_DOCUMENTHEADER-FISC_YEAR = '2007'.
WA_DOCUMENTHEADER-DOC_DATE = SY-DATUM.
WA_DOCUMENTHEADER-PSTNG_DATE = SY-DATUM.
WA_DOCUMENTHEADER-FIS_PERIOD = ' '.
WA_DOCUMENTHEADER-DOC_TYPE = 'DR'.
WA_DOCUMENTHEADER-ref_doc_no = '1234512345'.
*--One time customer data
Data : wa_onetimecust type BAPIACPA09.
wa_onetimecust-NAME = 'Mr'.
wa_onetimecust-NAME_2 = 'OneTimeCustomer'.
wa_onetimecust-CITY = 'Bangalore'.
wa_onetimecust-COUNTRY = 'India'.
*---end:One time customer data
WA_CUSTOMER-itemno_acc = '1'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = '100000'
IMPORTING
output = WA_CUSTOMER-CUSTOMER.
WA_CUSTOMER-comp_code = 'GOVP'.
APPEND WA_CUSTOMER TO it_bapiacar09.
CLEAR: WA_ACCOUNTGL.
WA_ACCOUNTGL-ITEMNO_ACC = 2.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = '6100.2600'
IMPORTING
output = WA_ACCOUNTGL-gl_account.
WA_ACCOUNTGL-COMP_CODE = 'GOVP'.
WA_ACCOUNTGL-ITEM_TEXT = 'TO CUSTOMER' .
WA_ACCOUNTGL-COSTCENTER = 'DUMMY'.
APPEND WA_ACCOUNTGL TO IT_ACCOUNTGL.
CLEAR: WA_ACCOUNTGL.
CLEAR: WA_CURRENCY.
CLEAR: WA_CURRENCY.
WA_CURRENCY-ITEMNO_ACC = 1.
WA_CURRENCY-CURR_TYPE = '00'.
WA_CURRENCY-CURRENCY = 'USD'.
WA_CURRENCY-AMT_DOCCUR = 10.
APPEND WA_CURRENCY TO IT_CURRENCY.
CLEAR: WA_CURRENCY.
WA_CURRENCY-ITEMNO_ACC = 2.
WA_CURRENCY-CURR_TYPE = '00'.
WA_CURRENCY-CURRENCY = 'USD'.
WA_CURRENCY-AMT_DOCCUR = -10.
APPEND WA_CURRENCY TO IT_CURRENCY.
--------------------------------------------------------
Post
--------------------------------------------------------
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
DOCUMENTHEADER = WA_DOCUMENTHEADER
CUSTOMERCPD = wa_onetimecust
IMPORTING
OBJ_TYPE = OBJ_TYPE
OBJ_KEY = OBJ_KEY
OBJ_SYS = OBJ_SYS
TABLES
ACCOUNTGL = IT_ACCOUNTGL
accountreceivable = it_bapiacar09
CURRENCYAMOUNT = IT_CURRENCY
RETURN = IT_RETURN.
LOOP AT IT_RETURN INTO WA_RETURN.
WRITE : /1 WA_RETURN-MESSAGE.
ENDLOOP.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN = WA_RETURN3.
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |