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

BAPI_ACC_DOCUMENT_POST Tax code must be entered

Former Member
0 Likes
3,893

Hi all,

I am using bapi BAPI_ACC_DOCUMENT_POST to post in FB01 but i am getting a error "Tax code must be entered". The amounts are equals in S/H but I don´t know what happen. Anybody have a suggestion?

Thanks in advance.

Mireya

1 ACCEPTED SOLUTION
Read only

Harsh_Bansal
Contributor
0 Likes
1,503

Hi,

While posting document, Tax Code is mandatory field. So, because of that it is giving error.

Regards,

Harsh Bansal

4 REPLIES 4
Read only

Former Member
0 Likes
1,503

hi,

Please check wat you are filling in ACCOUNTTAX parameter

inside ACCOUNTTAX check

TAX_CODE = TAX CODE

please check this thread for filling ACCOUNTTAX

Ben

Read only

Former Member
0 Likes
1,503

Hi, Here is a sample code how to use this one.


DATA: it_acc_gl LIKE bapiacgl09 OCCURS 0 WITH HEADER LINE,
it_acc_ap LIKE bapiacap09 OCCURS 0 WITH HEADER LINE,
it_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE,
it_curr_amt LIKE bapiaccr09 OCCURS 0 WITH HEADER LINE,
it_doc_header LIKE bapiache09 OCCURS 0 WITH HEADER LINE,
it_acc_tax LIKE bapiactx09 OCCURS 0 WITH HEADER LINE,
obj_type LIKE bapiache09-obj_type,
obj_key LIKE bapiache09-obj_key,
obj_sys LIKE bapiache09-obj_sys,
pstng_date LIKE it_doc_header-pstng_date,
doc_date LIKE it_doc_header-doc_date,
loop_cnt TYPE i VALUE 0,
gv_vendor(10) TYPE c,
gv_gl_acc(10) TYPE c.
 
LOOP AT bdc_source.
* First line of table is heading so don't do anything
IF bdc_layout IS INITIAL.
MOVE bdc_source TO bdc_layout.
TRANSLATE bdc_layout TO UPPER CASE.
CONTINUE.
ENDIF.
bdc_out = bdc_source.
CLEAR: obj_type, obj_sys, obj_key, pstng_date, doc_date, gv_vendor, gv_gl_acc.
* Setup the dates in correct format
CONCATENATE bdc_source-col_c+6(4) bdc_source-col_c(2) bdc_source-col_c+3(2) INTO pstng_date.
CONCATENATE bdc_source-col_b+6(4) bdc_source-col_b(2) bdc_source-col_b+3(2) INTO doc_date.
* Padding zeros, very important otherwise bunch of stuff is missing
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = bdc_source-col_e
IMPORTING
output = gv_vendor.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = bdc_source-col_j
IMPORTING
output = gv_gl_acc.
* Header
REFRESH it_doc_header.
it_doc_header-bus_act = 'RFBU'.
it_doc_header-username = sy-uname.
it_doc_header-header_txt = bdc_source-col_h. " Invoice Text
it_doc_header-comp_code = bdc_source-col_a. " Company Code
it_doc_header-doc_date = doc_date. " Invoice Date
it_doc_header-pstng_date = pstng_date. " Posting Date
it_doc_header-doc_type = 'KR'. " Return Order...?
it_doc_header-ref_doc_no = bdc_source-col_d. " Invoice Number
APPEND it_doc_header.
* GL Account
REFRESH it_acc_gl.
it_acc_gl-itemno_acc = '1'.
it_acc_gl-gl_account = gv_gl_acc. " GL Account
it_acc_gl-item_text = bdc_source-col_o. " Line Item Text
it_acc_gl-doc_type = 'KR'. " Return Order...?
it_acc_gl-comp_code = bdc_source-col_a. " Company Code
it_acc_gl-pstng_date = pstng_date. " Posting Date
it_acc_gl-vendor_no = gv_vendor. " Vendor Number
it_acc_gl-costcenter = bdc_source-col_k. " Cost Center
it_acc_gl-wbs_element = bdc_source-col_q. " WBS Element
"it_acc_gl-tax_code = bdc_source-col_m. " Tax Code
it_acc_gl-network = bdc_source-col_p. " Internal Order
conv_s_amt = bdc_source-col_f. " Invoice Amount
REPLACE ALL OCCURRENCES OF ',' IN conv_s_amt WITH ''.
IF conv_s_amt < 0.
it_acc_gl-de_cre_ind = 'H'. " H-Credit
conv_s_amt = - conv_s_amt.
ELSE.
it_acc_gl-de_cre_ind = 'S'. " S-Debit
ENDIF.
CONDENSE conv_s_amt.
APPEND it_acc_gl.
* AP Account
REFRESH it_acc_ap.
it_acc_ap-itemno_acc = '2'. " Invoice Number
it_acc_ap-vendor_no = gv_vendor. " Vendor Number
it_acc_ap-comp_code = bdc_source-col_a. " Company Code
it_acc_ap-item_text = bdc_source-col_o. " Line Item Text
APPEND it_acc_ap.
* Currancy
REFRESH it_curr_amt.
it_curr_amt-itemno_acc = '1'. " Invoice Number
it_curr_amt-curr_type = '00'.
it_curr_amt-currency = bdc_source-col_g. " Currancy
it_curr_amt-amt_doccur = conv_s_amt. " Line Item Amount
APPEND it_curr_amt.
it_curr_amt-itemno_acc = '2'. " Invoice Number
it_curr_amt-curr_type = '00'.
it_curr_amt-currency = bdc_source-col_g. " Currancy
it_curr_amt-amt_doccur = conv_s_amt * -1. " Line Item Amount
APPEND it_curr_amt.
REFRESH it_return.
* Do the post to GL Account and AP
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = it_doc_header
IMPORTING
obj_type = obj_type
obj_key = obj_key
obj_sys = obj_sys
TABLES
accountgl = it_acc_gl
currencyamount = it_curr_amt
accountpayable = it_acc_ap
return = it_return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
* Check for any errors
loop_cnt = 0.
LOOP AT it_return.
IF it_return-type = 'E'.
bdc_out-code = 'E'.
error_count = error_count + 1.
ELSE.
bdc_out-code = 'S'.
ENDIF.
loop_cnt = loop_cnt + 1.
IF loop_cnt = 1.
bdc_out-mesg1 = it_return-message.
ELSE.
IF loop_cnt = 2.
bdc_out-mesg2 = it_return-message.
ENDIF.
ENDIF.
ENDLOOP.
APPEND bdc_out.
cur_line = cur_line + 1.
ENDLOOP.  

Read only

Harsh_Bansal
Contributor
0 Likes
1,504

Hi,

While posting document, Tax Code is mandatory field. So, because of that it is giving error.

Regards,

Harsh Bansal

Read only

Former Member
0 Likes
1,503

hi all.

Thanks for yuor helpful answers The problem was tax code in some accounts.

Regards.

Mireya