Application Development 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: 

BAPI_ACC_DOCUMENT_POST: Balance in transaction currency

Former Member
0 Kudos

Hi,

I'm having a problem this bapi, my Currency amount table is balanced, but when i post i get an error like "Balance in transaction currency ".

Has anyone experience this before?

I can post GL AP AR but only when i use certain tax codes i get the above errors. Could it be because of the decimals point after the tax amnt calculation?

Please advice.

Vinod.

7 REPLIES 7

Former Member
0 Kudos

Hi

Yes... we have faced similar issues with this BAPI. It seems BAPI is not called properly. Also, it might be due to decimal points left over.

Since i don't have access to your system. It will be difficult to comment further.

Incase you can paste your code here, then i will able to guide you further.

Regards

- Atul

0 Kudos

begin of gw_fields,

gl_acct like bapiacgl09-gl_account,

cust_no like bapiacar09-customer,

vend_no like bapiacap09-vendor_no,

tx_code like bapiacgl09-tax_code,

nt_amnt like bapiaccr09-amt_doccur,

tx_amnt like bapiaccr09-amt_doccur,

cs_cntr like bapiacgl09-costcenter,

patch like bapiackec9-fieldname,

wmis like bapiackec9-fieldname,

cocode like bapiacgl09-comp_code,

condkey like bapiactx09-cond_key,

tx_jur like bapiactx09-taxjurcode,

profit_ctr like bapiacgl09-profit_ctr,

itm_txt like bapiacgl09-item_text,

ref_key type bapiacgl09-ref_key_3,

acc_ass like bapiacgl09-alloc_nmbr,

end of gw_fields.

data: gt_fields like table of gw_fields,

gt_fields1 like table of gw_fields,

gw_fields1 like gw_fields,

p_monat type bkpf-monat.

data: gt_header like table of bapiache09 with header line,

gt_glwotx like table of bapiacgl09 with header line,

gt_glwitx like table of bapiactx09 with header line,

gt_custln like table of bapiacar09 with header line,

gt_vendln like table of bapiacap09 with header line,

gt_amntln like table of bapiaccr09 with header line,

gt_copaln like table of bapiackec9 with header line.

data: gt_header1 like table of z1bpache09,

gt_glwotx1 like table of e1bpacgl09,

gt_glwitx1 like table of e1bpactx09,

gt_custln1 like table of e1bpacar09,

gt_vendln1 like table of e1bpacap09,

gt_amntln1 like table of e1bpaccr09,

gt_copaln1 like table of e1bpackec9.

data: gw_header1 like line of gt_header1,

gw_glwotx1 like line of gt_glwotx1,

gw_glwitx1 like line of gt_glwitx1,

gw_custln1 like line of gt_custln1,

gw_vendln1 like line of gt_vendln1,

gw_amntln1 like line of gt_amntln1,

gw_copaln1 like line of gt_copaln1.

data: it_filetab type filetable,

gw_option type i,

gw_subrc type i,

gw_flag type c,

gw_sumnet type ekpo-netwr,

gw_sumtax type ekpo-netwr,

gw_blance type ekpo-netwr,

gw_number type ska1-saknr,

gw_txjcd type csks-txjcd,

gw_line type i,

gw_pert type i,

global_counter type i,

gw_cond_key type bapiactx09-cond_key.

data : gt_datatab type kcde_cells occurs 0 with header line,

gt_datatab2 type kcde_cells occurs 0 with header line,

gt_t2502 like table of t2502 with header line,

gt_t2503 like table of t2503 with header line,

gt_ska1 like table of ska1 with header line,

gt_kna1 like table of kna1 with header line,

gt_lfa1 like table of lfa1 with header line,

gt_return like table of bapiret2 with header line.

perform fill_internal_table.

perform bapi_check.

--


Header----

move: 'RFBU' to gt_header-bus_act,

sy-uname to gt_header-username,

'' to gt_header-compo_acc,

'555' to gt_header-ref_doc_no,

p_bktxt to gt_header-header_txt,

p_bukrs to gt_header-comp_code,

p_bldat to gt_header-doc_date,

p_budat to gt_header-pstng_date,

p_monat to gt_header-fis_period,

p_blart to gt_header-doc_type.

  • Copy header to header1 for posting later.

move-corresponding: gt_header to gw_header1.

move p_waers to gw_header1-curr_key.

if p_stodt <> '' and p_stgrd <> ''.

move: p_stodt to gw_header1-acc_date,

p_stgrd to gw_header1-reason_rev.

endif.

gt_idoc_data-segnum = 1.

gt_idoc_data-segnam = 'Z1BPACHE09'.

move gw_header1 to gt_idoc_data-sdata.

append gt_idoc_data.

clear gw_header1.

loop at gt_fields into gw_fields.

add 1 to global_counter.

gw_pert = sy-tabix / gw_line * 100.

if gw_fields-gl_acct is not initial.

  • Fill the G/L Lines

if not gw_fields-gl_acct is initial.

  • ADD 1 TO gw_glcounter.

  • gw_witx = gw_glcounter.

if gw_fields-itm_txt+0(3) = '[&]'.

move gw_fields-itm_txt+3(47) to lv_itm_txt.

endif.

move: global_counter to gt_glwotx-itemno_acc,

gw_fields-gl_acct to gt_glwotx-gl_account,

gw_fields-cocode to gt_glwotx-comp_code,

gw_fields-tx_code to gt_glwotx-tax_code,

gw_fields-tx_jur to gt_glwotx-taxjurcode,

lv_itm_txt to gt_glwotx-item_text,

gw_fields-cs_cntr to gt_glwotx-costcenter,

gw_fields-profit_ctr to gt_glwotx-profit_ctr,

gw_fields-ref_key to gt_glwotx-ref_key_3,

gw_fields-acc_ass to gt_glwotx-alloc_nmbr.

append gt_glwotx.

move-corresponding: gt_glwotx to gw_glwotx1.

endif.

  • IF r_gldoc IS INITIAL.

  • With Tax

if gw_fields-tx_amnt is not initial or gw_fields-itm_txt+0(3) = '[&]'.

if gw_fields-itm_txt+0(3) = '[&]'.

move gw_fields-itm_txt+3(47) to gw_fields-itm_txt.

endif.

gw_witx = global_counter.

add 1 to gw_witx.

move: gw_witx to gt_glwitx-itemno_acc,

  • gw_fields-gl_acct to gt_glwitx-GL_ACCOUNT, "Added

gw_fields-condkey to gt_glwitx-cond_key,

gw_fields-tx_code to gt_glwitx-tax_code,

gw_fields-tx_jur to gt_glwitx-taxjurcode.

append gt_glwitx.

move-corresponding: gt_glwitx to gw_glwitx1.

gw_gottx = 'X'.

endif.

  • Copy gllines to gllines1 for posting later.

perform gllines1.

endif.

if gw_fields-cust_no is not initial.

  • Fill the Customer and

perform customer_lines.

  • Copy customer_lines to customer_lines1 for posting later.

perform customer_lines1.

add 1 to gw_custno.

endif.

if gw_fields-vend_no is not initial.

  • Fill the Vendor lines

perform vendor_lines.

  • Copy vendor_lines to vendor_lines1 for posting later.

perform vendor_lines1.

add 1 to gw_vendno.

endif.

*Fill Currency Amont Table

add 1 to gw_glno.

move: global_counter to gt_amntln-itemno_acc,

p_waers to gt_amntln-currency,

gw_fields-nt_amnt to gt_amntln-amt_doccur,

gw_fields-nt_amnt to gt_amntln-amt_base.

append gt_amntln.

check gw_gottx is not initial.

add 1 to global_counter.

  • Move Tax amounts

move: global_counter to gt_amntln-itemno_acc,

p_waers to gt_amntln-currency,

gw_fields-tx_amnt to gt_amntln-amt_doccur,

gw_fields-nt_amnt to gt_amntln-amt_base.

append gt_amntln.

clear gw_gottx.

*Amounts

sort gt_amntln.

loop at gt_amntln.

  • Copy amounts to amounts1 for posting later.

perform amounts1.

endloop.

This is how my Currency amount table looks like

ITEMNO_ACC CURRENCY AMT_DOCCUR AMT_BASE

1 0000000001 |GBP | 117.5000-< 117.5000-< |

2 0000000002 |GBP | 115.9250 < 115.9250 < |

3 0000000003 |GBP | 1.5750 < 115.9250 < |

If i round up the amount to (115.93 and 1.57) than it will post succesfully.

Please advice.

Message was edited by:

Vinodman Nair

0 Kudos

Hi

<u>What data declaration have you done in this case for the internal tables and the local variables used in your program ?</u>

<u>Please paste the same as well.</u>

<u>Seems to be data declaration problem.</u>

I will send you a sample code how to go about it in my next reply.

Regards

- Atul

0 Kudos

Hi Atul,

Sorry, i thought you just wanted the coding, I've edited the previous message with the declaration.

I did not copy other parts of the programs as it would be too long and much more confusing.

I hope you can help me out now.

Thanks in advance.

Vinod

0 Kudos

Hi

I will sent you a sample code in my next reply.

<u>Alternatively, Try declaring the final internal table which is holding the field AMT_DOCCUR ( as Data: AMT_DOCCUR type p decimals 2. )</u>

Hope this will help.

Please reward suitable points, incase it suits your requirements.

Regards

- Atul

0 Kudos

I have a scenario where my tax amounts 1.575 and 3.335. now if i declare a variable like that it behaves differently it truncates on of it to 1.58 and the other is 3.34 when added it would not equal to the same amount as previously.

thus i can't move it to a a 2 decimal place variable. it will give me balance in currency error.

I'm quite sure the 3 decimal point is casuing the error but how come the bapi has set it as 3 decimal points?

Still stuck....

0 Kudos

Hi

Please send me your detailed code and the detailed requirements on my email id.

atul.kant@gmail.com

I will then reply back with the required changes in the code to made.

Regards

- Atul