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

Errors with BAPI_ACC_DOCUMENT_CHECK

former_member367551
Participant
0 Likes
8,124

Dear Experts,

I've been having errors with my codes for executing BAPI_ACC_DOCUMENT_CHECK.

Eventually, I will also need to run the same codes for BAPI_ACC_DOCUMENT_POST too.

Here is how I have populated the input parameters for the BAPI_ACC_DOCUMENT_CHECK:-

1) Input parameter, DOCUMENTHEADER:-

USERNAME = 'SY-UNAME'

HEADER_TXT = 700/003350

COMP_CODE = 8000

DOC_DATE = 05.03.2015

PSTNG_DATE = 19.01.2015

(Other fields are left blank here.)

2) Input parameter, ACCOUNTGL:-

ITEMNO_ACC = 1

ACCT_TYPE = D

FIS_PERIOD = 01

FIS_YEAR = 2015

CUSTOMER = 10005

(Other fields are left blank here.

Only 1 data record is populated for this internal table.)


Executing the BAPI with just these two input parameters above will not return any error messages at all.

3) Input parameter, CURRENCYAMOUNT:-

ITEMNO_ACC = 1

CURR_TYPE = 00

CURRENCY = GBP

AMT_DOCCUR = 40.2500

(Other fields are left blank here.

Only 1 data record is populated for this internal table.)

But, when I add the third input parameter as shown above, these error messages will be returned:-


RW 609: Error in document: BKPFF

RW 022: FI/CO interface: Balance in transaction currency

If I change the data value for CURRENCYAMOUNT-CURR_TYPE to 10, these error messages will be returned:-

RW 609: Error in document: BKPFF

RW 021: FI/CO line item without transaction currency information

P/S:

I have also tried adding another data record to the input parameter, CURRENCYAMOUNT as follows, but the same errors still persist:-

ITEMNO_ACC = 2

CURR_TYPE = 00

CURRENCY = GBP

AMT_DOCCUR = 40.2500-

How may I pass this BAPI execution successfully, with currency amounts?

Please do advise. Appreciate any inputs at all.

Thanks in advance.

Deborah

3 REPLIES 3
Read only

VenkatRamesh_V
Active Contributor
0 Likes
3,895

Hi,

Try.

FORM POST.

   DATA: w_header     type          BAPIACHE09,

         t_item_gl    type table of BAPIACGL09,

         w_item_gl    type          BAPIACGL09,

         t_item_curr  type table of BAPIACCR09,

         w_item_curr  type          BAPIACCR09,

         it_rtn       type table of BAPIRET2,

         wa_rtn       type          BAPIRET2,

         it_rtn1      type table of BAPIRET2,

         cnt          type          i,

         g_obj_type   type          BAPIACHE09-OBJ_TYPE,

         g_obj_key    type          BAPIACHE09-OBJ_KEY,

         g_obj_sys    type          BAPIACHE09-OBJ_SYS,

         lv_dr(13)    type          p decimals 2,

         lv_cr(13)    type          p decimals 2,

         lv_doc       type          string.

FIELD-SYMBOLS: <error>       type  BAPIRET2.

   w_header-COMP_CODE   = bkpf-bukrs.

   w_header-DOC_DATE    = bkpf-bldat.

   w_header-PSTNG_DATE  = bkpf-budat.

   w_header-REF_DOC_NO  = bkpf-xblnr.

   w_header-HEADER_TXT  = bkpf-bktxt.

   w_header-DOC_TYPE    = bkpf-BLART.

   w_header-USERNAME    = sy-uname.

   loop at it_final into wa_final.

     cnt = cnt + 1.

**Fill Credit line item data

     if wa_final-shkzg = 'H'.

*  IF w_postings-pkey = 50.

       w_item_gl-itemno_acc      =  cnt.

       w_item_gl-comp_code       = w_header-COMP_CODE.

       w_item_gl-gl_account      = wa_final-hkont.

       if w_item_gl-gl_account IS NOT INITIAL.

         PERFORM Conversion using w_item_gl-gl_account.

       endif.

       w_item_gl-pstng_date      = w_header-PSTNG_DATE.

       w_item_gl-item_text       = wa_final-txt20.

       w_item_gl-value_date      = w_header-PSTNG_DATE.

       APPEND w_item_gl TO t_item_gl.

       w_item_curr-itemno_acc  = cnt.

*w_item_curr-curr_type   = 'INR'.      "Document Currency

       w_item_curr-currency    = 'INR'.

       w_item_curr-amt_doccur  = wa_final-wrbtr * ( -1 ).

       APPEND w_item_curr TO t_item_curr.

       CLEAR w_item_curr.

       lv_cr   = lv_cr + wa_final-wrbtr.

     elseif  wa_final-shkzg = 'S'.

       w_item_gl-itemno_acc      =  cnt.

       w_item_gl-comp_code       = w_header-COMP_CODE.

       w_item_gl-gl_account      = wa_final-hkont.

       if w_item_gl-gl_account IS NOT INITIAL.

         PERFORM Conversion using w_item_gl-gl_account.

       endif.

       w_item_gl-pstng_date      = w_header-PSTNG_DATE.

       w_item_gl-item_text       = wa_final-txt20.

       w_item_gl-value_date      = w_header-PSTNG_DATE.

       APPEND w_item_gl TO t_item_gl.

       w_item_curr-itemno_acc  = cnt.

*w_item_curr-curr_type   = 'INR'.      "Document Currency

       w_item_curr-currency    = 'INR'.

       w_item_curr-amt_doccur  = wa_final-wrbtr.

       APPEND w_item_curr TO t_item_curr.

       CLEAR w_item_curr.

       lv_dr   = lv_dr + wa_final-wrbtr.

     endif.

* ELSEIF w_postings-pkey =  40.

*

* ENDIF.

*

   endloop.

move: lv_dr to   ACGL_HEAD-SUMSOLL,

       lv_cr to   ACGL_HEAD-SUMHABEN.

*

*

*IF g_credit_total <> 0 AND g_debit_total <> 0.

   CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'

     EXPORTING

       documentheader = w_header

     TABLES

       accountgl      = t_item_gl

       currencyamount = t_item_curr

       return         = it_rtn.

if  lv_dr   NE lv_cr.

loop at it_rtn into wa_rtn.

wa_rtn-type = 'E'.

wa_rtn-MESSAGE   = text-010.

append wa_rtn to it_rtn.

clear  wa_rtn.

exit.

endloop.

endif.

IF it_rtn IS NOT INITIAL.

LOOP AT  it_rtn assigning <error>.

CHECK <error>-TYPE = 'E'.

PERFORM message tables it_rtn.

EXIT.

ENDLOOP.

ENDIF.

*If t_return is not initial.

*   IF it_rtn IS INITIAL.

** Posting journal entries

   CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

     EXPORTING

       documentheader = w_header

     IMPORTING

       obj_type       = g_obj_type

       obj_key        = g_obj_key

       obj_sys        = g_obj_sys

     TABLES

       accountgl      = t_item_gl

       currencyamount = t_item_curr

       return         = it_rtn1.

   IF sy-subrc =  0.

     CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

       EXPORTING

         wait = abap_true.

  CONCATENATE 'Document posted' g_obj_key into lv_doc separated by space.

MESSAGE lv_doc type 'S'.

  ELSE.

PERFORM message tables it_rtn1.

   ENDIF.

*  ENDIF.

*

ENDFORM.

Hope it helpful,

Regards,

Venkat.V

Read only

0 Likes
3,895

Dear Venkat,

The same error still persists for me

But thanks a lot anyway, for your sample work.. Appreciate it..

Does anyone still have any other inputs perhaps?

Deborah

Read only

0 Likes
3,895

Hi Deborah,

This error means that the sum of the amounts you are passing for that particular document is not zero. I checked your code and you are passing only 1 amount (40.2500). It is not possible to post a financial doc without the sum of debit and credit being zero. So no matter you send positive or negative value, it will never be zero so you will need to introduce another line item for the amount table (example 40.2500 and -40.2500).

You an talk to your functional about how you need to pass the other amount (GL account etc) but the total must be zero. A good way to find out if the data you are sending is correct or not is to go to FB50 and try to create a document manually with the exact same data. If it let's you create a doc, then the same data has to work for BAPI. If it does not, then amendments have to be introduced.

Thanks,

Soumyajit