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,232

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

Now u need to implement the method CHANGE, so back to the BADI and press INTERFACE tab and double click on method CHANGE

Here u need to insert the code to check the duplicate posting

DATA: W_ACCIT  TYPE ACCIT.
  DATA: _REPRF   TYPE LFB1-REPRF.
  DATA: W_ACCCR  TYPE ACCCR.
  DATA: W_RETURN TYPE BAPIRET2.



  LOOP AT C_ACCIT INTO W_ACCIT WHERE KOART = 'K'.
* Check if the vendor has to be available for duplicete posting control
    SELECT SINGLE REPRF FROM LFB1 INTO _REPRF
       WHERE LIFNR = W_ACCIT-LIFNR
         AND BUKRS = W_ACCIT-BUKRS.
    IF SY-SUBRC <> 0.
      CLEAR _REPRF.
    ENDIF.

    READ TABLE C_ACCCR INTO W_ACCCR WITH KEY POSNR = W_ACCIT-POSNR.

    CALL FUNCTION 'FI_DUPLICATE_INVOICE_CHECK'
      EXPORTING
        I_BUKRS       = W_ACCIT-BUKRS
        I_LIFNR       = W_ACCIT-LIFNR
        I_WAERS       = W_ACCCR-WAERS
        I_BLDAT       = W_ACCIT-BLDAT
        I_XBLNR       = W_ACCIT-XBLNR
        I_WRBTR       = W_ACCCR-WRBTR
        I_KOART       = 'K'
        I_REPRF       = _REPRF
        I_SHKZG       = W_ACCIT-SHKZG
        I_XUMSW       = W_ACCIT-XUMSW
        I_BSTAT       = W_ACCIT-BSTAT
        I_BLART       = W_ACCIT-BLART
      EXCEPTIONS
        MISSING_DATA  = 1
        ERROR_MESSAGE = 2
        OTHERS        = 3.

    IF SY-SUBRC <> 0.
      CALL FUNCTION 'BALW_BAPIRETURN_GET2'
        EXPORTING
          TYPE   = SY-MSGTY
          CL     = SY-MSGID
          NUMBER = SY-MSGNO
          PAR1   = SY-MSGV1
          PAR2   = SY-MSGV2
          PAR3   = SY-MSGV3
          PAR4   = SY-MSGV4
        IMPORTING
          RETURN = W_RETURN.
      APPEND W_RETURN TO C_RETURN.
    ENDIF.

  ENDLOOP.

Max

41 REPLIES 41
Read only

0 Likes
4,422

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,422

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