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 posting duplicate entries

Former Member
0 Likes
9,190

Hello,

I have been working on BAPI_ACC_DOCUMENT_POST bapi to create a WD application for creating an invoice similar to Tcode FB10. My issue is:-

The BAPI_ACC_DOCUMENT_POST" bapi is allowing the end user to make duplicate invoice payments which is not acceptable. We need the BAPI to return an error message if a duplicate entry exists. For eg:- If we enter a duplicate entry in FB10 it throws an error message telling the user that a duplicate entry exists. But, this is not happening in the case of the BAPI.

Could anyone help me in finding a way to check for duplicate invoice entries and throw an error message. I would greately appreciate your help.

Regards,

Gopal Yarlagadda.

Hi

The BAPI doesn't call the fm FI_DUPLICATE_INVOICE_CHECK in order to check the posting: I was the same problem and I solved it by the BTE RWBAPI01, usually used to transfer the extension data.

If your release is ECC 6 u can also use the BADI acc_document (method change).

If you use the BTE u need to use a record dummy for extension in order to trigger the BTE

This is the code (Step 1):

.FUNCTION Z_SDFI_INTERFACE_RWBAPI01.
*"----------------------------------------------------------------------
*"*"Interfaccia locale:
*"  TABLES
*"      IT_ACCIT STRUCTURE  ACCIT
*"      IT_ACCCR STRUCTURE  ACCCR
*"      RETURN STRUCTURE  BAPIRET2
*"      EXTENSION STRUCTURE  BAPIACEXTC
*"      IT_ACCWT STRUCTURE  ACCIT_WT
*"  CHANGING
*"     VALUE(DOCUMENT_HEADER) LIKE  ACCHD STRUCTURE  ACCHD
*"----------------------------------------------------------------------
............................
  LOOP AT IT_ACCIT WHERE KOART = 'K'.

    IT_ACCIT-XUMSW = 'X'.
    MODIFY IT_ACCIT.

    SELECT SINGLE REPRF FROM LFB1 INTO _REPRF
                                           WHERE LIFNR = IT_ACCIT-LIFNR
                                             AND BUKRS = IT_ACCIT-BUKRS.
    IF SY-SUBRC <> 0.
      CLEAR _REPRF.
    ENDIF.

    READ TABLE IT_ACCCR WITH KEY POSNR = IT_ACCIT-POSNR.

.

Max

41 REPLIES 41
Read only

0 Likes
4,382

That's good

You're right: when I post my code I forgot this little line:

IT_ACCIT-XUMSW = 'X'.

But you've found out it by yourself....good work

Max

P.s.: I believe u should keep that flag in IT_ACCIT table too.

Read only

0 Likes
4,382

Hi Max,

I have the similar problem. I am posting invoice using IDOC. is it possible to do the same in 4.6c system also? I don't see 'ACC_DOCUMENT' Badi in 4.6c. If I do implement the same functionality using BTE then the event is not getting triggered because EXTENSION1 table is blank as we are not populating it. Can you please help me here?

Regards

Amit