12-10-2008 11:45 AM
Hi,
I am using 'BAPI_ACC_GL_POSTING_POST' for posting G/L accounts .
how to do it for Vendor account numbers.
i have the code as
IF IT_HEADER-BLART = 'KR' OR IT_HEADER-BLART = 'KA'.
IT_ACCGL-ACTTYPE = 'K'.
IT_ACCGL-VENDOR_NO = IT_ITEM-NEWKO.
ENDIF.
But the BAPI -
needs a GL account number also. otherwise it is showing error and the document is not posted.
Can any one help me in this. How to pass on values to the BAPI for VENDOR ACCOUNT NUMBERS.
Vikki.
12-10-2008 12:33 PM
Hi,
You should use BAPI_ACC_DOCUMENT_POST' for posting to vendor a/cs. Please note that there is a seperate table ACCOUNTPAYABLE for passing vendor entry.
Here is a dummy source code for posting an entry for customer.
DATA: doc_header LIKE BAPIACHE09,
criteria LIKE BAPIACKEC9 OCCURS 0 WITH HEADER LINE,
doc_item LIKE BAPIACGL09 OCCURS 0 WITH HEADER LINE,
doc_ar LIKE BAPIACAR09 OCCURS 0 WITH HEADER LINE,
doc_values LIKE BAPIACCR09 OCCURS 0 WITH HEADER LINE,
return LIKE bapiret2 OCCURS 0 WITH HEADER LINE,
extension1 like BAPIACEXTC occurs 0 with header line,
obj_type LIKE bapiache08-obj_type,
obj_key LIKE bapiache02-obj_key,
obj_sys LIKE bapiache02-obj_sys,
docnum LIKE bkpf-belnr.
*
Fill Document Header
doc_header-bus_act = 'RFBU'.
doc_header-username = sy-uname.
doc_header-header_txt = 'TEST BOC BAPI POSTING'.
doc_header-comp_code = 'IN01'.
doc_header-doc_date = '20060127'.
doc_header-pstng_date = sy-datlo.
doc_header-doc_type = 'SA'.
Fill Line 1 of Document Item
doc_item-itemno_acc = '1'.
doc_item-gl_account = '0000680106'.
doc_item-COSTCENTER = 'H909'.
doc_item-pstng_date = sy-datum.
doc_item-item_text = 'TEST POSTING DEBIT ITEM'.
APPEND doc_item.
CLEAR doc_item.
Fill Line 2 of Document Item
doc_ar-itemno_acc = '2'.
doc_ar-customer = '0000000001'.
doc_ar-item_text = 'TEST POSTING CREDIT ITEM'.
APPEND doc_ar.
CLEAR doc_ar.
Fill Line 1 of Document Value.
doc_values-itemno_acc = '1'.
doc_values-currency_iso = 'INR'.
doc_values-amt_doccur = '-200.00'.
doc_values-currency = 'INR'.
APPEND doc_values.
CLEAR doc_values.
Fill Line 2 of Document Value
doc_values-itemno_acc = '2'.
doc_values-currency_iso = 'INR'.
doc_values-amt_doccur = 200.
APPEND doc_values.
CLEAR doc_values.
Add tax code in extension1 table.
*extension1-field1 = 'BAPI CALL'.
*APPEND EXTENSION1.
*
All tables filled - now call BAPI.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
EXPORTING
documentheader = doc_header
IMPORTING
OBJ_TYPE = doc_header-obj_type
OBJ_KEY = doc_header-obj_key
OBJ_SYS = doc_header-obj_sys
TABLES
accountgl = doc_item
ACCOUNTRECEIVABLE = doc_ar
currencyamount = doc_values
return = return.
EXTENSION1 = EXTENSION1.
*
LOOP AT return WHERE type = 'E'.
EXIT.
ENDLOOP.
*
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = doc_header
IMPORTING
OBJ_TYPE = doc_header-obj_type
OBJ_KEY = doc_header-obj_key
OBJ_SYS = doc_header-obj_sys
TABLES
accountgl = doc_item
ACCOUNTRECEIVABLE = doc_ar
currencyamount = doc_values
return = return.
LOOP AT return WHERE type = 'E'.
EXIT.
ENDLOOP.
IF sy-subrc EQ 0.
WRITE: / 'BAPI call failed - debug and fix!'.
ELSE.
CLEAR return.
REFRESH return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
IMPORTING
return = return.
WRITE: / 'BAPI call worked!!'.
WRITE: / doc_header-obj_key, ' posted'.
ENDIF.
I hope this helps,
Regards
Raju Chitale
Edited by: Raju Chitale on Dec 10, 2008 1:34 PM
12-10-2008 12:37 PM
HI,
Thanks for the reply.
Can you give me a sample for the values to be passed on to the PARAMETERS.
Vikki.
12-10-2008 12:38 PM