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: 

Duplicate Invoices while saving document through MIR7

Former Member
0 Kudos

Hello,

I have to Post the invoice document through MIR7. This can be done through MIRO as well but the end user is using MIR7 for this purpose by parking and then posting the document.

Problem here is that once user has posted the invoice document, he is able to post the same document again by just changing the reference document number field in MIR7, which leads duplicate invoices.

Here we need to control this by manually putting some conditions. I tried to find the exit and BADI but was able to get only one useful thing that is BADI "INVOICE_UPDATE".

I am not sure about this BADI but in case if this BADI can be used then I want to know how?

Also if not then what are the possible solutions to resolve the issue.

I am open for any further inputs.

Thanks,

Harjeet

1 ACCEPTED SOLUTION

former_member182371
Active Contributor
0 Kudos

Hi,

just searching in the forums you could find something like this:

http://www.sdn.sap.com/irj/scn/advancedsearch?query=miroduplicateinvoice#

SAP-HELP:

http://help.sap.com/saphelp_47x200/helpdata/en/ce/4f3e39ea3aee02e10000000a114084/frameset.htm

Thread:

SPRO:

Materials Management -> Logistics Invoice Verification -> Incoming Invoice -> Set Check Duplication Invoices

OSS Notes:

( Note 305201 - Description: Check for duplicate invoices )

https://service.sap.com/sap/support/notes/305201

(Note 305277 - Check for double credit memos):

https://service.sap.com/sap/support/notes/305277

transactions:

XK02 (tick the check double invoice field)

OMRM and make message M8 108 or M8 462 as Error.

...etc

it´s not that bad to use the search button (there´s plenty of information available).

Best regards.

Edited by: Pablo Casamayor on Jul 27, 2011 11:21 PM

22 REPLIES 22

former_member182371
Active Contributor
0 Kudos

Hi,

just searching in the forums you could find something like this:

http://www.sdn.sap.com/irj/scn/advancedsearch?query=miroduplicateinvoice#

SAP-HELP:

http://help.sap.com/saphelp_47x200/helpdata/en/ce/4f3e39ea3aee02e10000000a114084/frameset.htm

Thread:

SPRO:

Materials Management -> Logistics Invoice Verification -> Incoming Invoice -> Set Check Duplication Invoices

OSS Notes:

( Note 305201 - Description: Check for duplicate invoices )

https://service.sap.com/sap/support/notes/305201

(Note 305277 - Check for double credit memos):

https://service.sap.com/sap/support/notes/305277

transactions:

XK02 (tick the check double invoice field)

OMRM and make message M8 108 or M8 462 as Error.

...etc

it´s not that bad to use the search button (there´s plenty of information available).

Best regards.

Edited by: Pablo Casamayor on Jul 27, 2011 11:21 PM

0 Kudos

Dear Pablo,

I must appreciate your reply with so many inputs. But just want to mention that I have already searched the SDN and was unable to get the exact answer. In case I am dealing with MIRO , I have ample options available, but I am dealing with MIR7 now.

I have maintained the messages in transaction OMRM and they are working for MIRO again not for MIR7.

I want to know any validation for MIR7 when I change my reference field and other criteria remains same.

Just want to mention, I am a technical resource (ABAP) and have less idea about the functional customization. So I would appreciate if you elaborate the customization or configuration if required to solve this.

Thanks,

Harjeey

0 Kudos

Hi,

in SPRO-> Materials management -> Logistics invoice verification -> Incoming Invoice -> Set check for duplicate invoices:

this is what help says about "check reference" field

Indicator: Check reference number

Specifies whether the system is to check the reference number during the duplicate invoice check.

Use

Select the field Check reference number, if you want the system to check if the reference number occurs twice.

Deselect the field Check reference number, if you do not want the system to check if the reference number occurs twice.

have a look at fm´s MRM_DUPLICATE_INVOICE_CHECK and FI_DUPLICATE_INVOICE_CHECK in order to understand how the standard works.

check this wiki too:

http://wiki.sdn.sap.com/wiki/display/ERPFI/DuplicateInvoiceCheck

Once you´ve done that,

there are several options available:

1.- a Validation (transaction GGB0)

e.g. financial accounting -> complete document

2.- a BTE (transaction FIBF):

http://wiki.sdn.sap.com/wiki/display/Snippets/BusinessTransactionevents%28BTE%29

3.- A Badi:

( Note 1156325 - BAdIs in the Logistics Invoice Verification environment)

https://service.sap.com/sap/support/notes/1156325

e.g. INVOICE_UPDATE or MRM_HEADER_CHECK

All this information is available in SDN.

Best regards.

Edited by: Pablo Casamayor on Jul 28, 2011 9:33 AM

0 Kudos

Hello Pablo,

I managed with MIR7 with the BADI INVOICE_UPDATE, but the problem I am facing is that the document can be posted through MIRO or from MIR7.

When I post it through MIR7, BADI works fine, but say I have parked the document through MIR7 and posted it. Now if I am trying to post the same document through MIRO it allows me to post it again. Moreover in the BADI data which is flowing doesn't contain BELNR values and with out which I cannot proceed the validation through RBKP table.

Please suggest how to get the value of BELNR and how to implement it.

Thanks,

Harjeet

0 Kudos

Hi,

can you show the code you´re using?

Best regards.

0 Kudos

Hello Pablo,

In the BADI I am using table TI_RSEG_NEW, there I am getting values same as listed below for MIR7 but instead I am getting the values of BELNR as well. Here the second column is BELNR which is blank for MIRO.

1 110 | |2011 |000001|0411000942|00010|00 |000000000009000029 |

2 110 | |2011 |000002|0411000942|00020|00 |000000000003000013 |

______ ___________________________________________________________________________

______ ___________________________________________________________________________

Code for the same is:

if sy-ucomm eq 'COMP'.
        select ebeln
               ebelp
               zekkn
               gjahr
               buzei
               bewtp
          from ekbe into table i_ekbe
          for all entries in ti_rseg_new
          where ebeln = ti_rseg_new-ebeln
            and ebelp = ti_rseg_new-ebelp
            and zekkn = ti_rseg_new-zekkn
            and gjahr = ti_rseg_new-gjahr
            and buzei = ti_rseg_new-buzei+2(4).
      endif.

      if sy-ucomm = 'BU'.
        select ebeln
               ebelp
               zekkn
               gjahr
               belnr
               buzei
               bewtp
          from ekbe into table i_ekbe_belnr
          for all entries in ti_rseg_new
          where ebeln = ti_rseg_new-ebeln
            and ebelp = ti_rseg_new-ebelp
            and zekkn = ti_rseg_new-zekkn
            and gjahr = ti_rseg_new-gjahr
            and belnr = ti_rseg_new-belnr
            and buzei = ti_rseg_new-buzei+2(4).
        if sy-subrc eq 0.
          select belnr
                 gjahr
                 vgart
            from rbkp into table i_rbkp
            for all entries in i_ekbe_belnr
            where belnr = i_ekbe_belnr-belnr
              and gjahr = i_ekbe_belnr-gjahr.
        endif.
      endif.

      loop at ti_rseg_new into wa_rseg_new.
        if sy-ucomm = 'COMP'.
          clear v_message.
          read table i_ekbe into wa_ekbe with key
                                         ebeln = wa_rseg_new-ebeln
                                         ebelp = wa_rseg_new-ebelp
                                         zekkn = wa_rseg_new-zekkn
                                         gjahr = wa_rseg_new-gjahr
                                         buzei = wa_rseg_new-buzei
                                         bewtp = 'T'.
          if sy-subrc eq 0.
            concatenate 'Purchasing Document Number' wa_ekbe-ebeln 'is already parked.' into v_message separated by space.
            message v_message type 'E'.
          else.
            clear v_message.
            read table i_ekbe into wa_ekbe with key
                                           ebeln = wa_rseg_new-ebeln
                                           ebelp = wa_rseg_new-ebelp
                                           zekkn = wa_rseg_new-zekkn
                                           gjahr = wa_rseg_new-gjahr
                                           buzei = wa_rseg_new-buzei
                                           bewtp = 'Q'.
            if sy-subrc eq 0.
              concatenate 'Purchasing Document Number' wa_ekbe-ebeln 'is already Posted.' into v_message separated by space.
              message v_message type 'E'.
            endif.
          endif.

        elseif sy-ucomm = 'BU'.
          clear v_message.
          read table i_ekbe_belnr into wa_ekbe_belnr with key
                                         ebeln = wa_rseg_new-ebeln
                                         ebelp = wa_rseg_new-ebelp
                                         zekkn = wa_rseg_new-zekkn
                                         gjahr = wa_rseg_new-gjahr
                                         belnr = wa_rseg_new-belnr
                                         buzei = wa_rseg_new-buzei
                                         bewtp = 'Q'.
          if sy-subrc eq 0.
**          READ TABLE s_rbkp_new WITH KEY belnr = wa_ekbe_belnr-belnr
**                                         gjahr = wa_ekbe_belnr-gjahr.
**          IF sy-subrc EQ 0.
            read table i_rbkp into wa_rbkp with key belnr = s_rbkp_new-belnr
                                                    gjahr = s_rbkp_new-gjahr
                                                    vgart = s_rbkp_new-vgart.
            if sy-subrc eq 0.
              concatenate 'Purchasing Document Number' wa_ekbe_belnr-ebeln 'is already posted.' into v_message separated by space.
              message v_message type 'E'.
            endif.
*          ENDIF.
          endif.
        endif.
      endloop.

0 Kudos

Hi,

regarding field BELNR try something like:


TYPE-POOLS: MRM.
CONSTANTS: c_rbkpv(15) TYPE c VALUE '(SAPLMRMP)RBKPV'.
 
FIELD-SYMBOLS: <fs_rbkpv> TYPE mrm_rbkpv. 
ASSIGN (c_rbkpv) TO <fs_rbkpv>.

IF <fs_rbkpv> IS ASSIGNED.
* Here you have <fs_rbkpv>-belnr and <fs_rbkpv>-gjahr available
ENDIF.

IN MIR7 if you Hold/Park/save as complete the document the tables to check are VBKPF and VBSEGK.

If you post the document the tables to check are BKPF and BSEG.

http://wiki.sdn.sap.com/wiki/display/ERPFI/Parkingtablesoverview

And I insist again: do have a look at fm´s MRM_DUPLICATE_INVOICE_CHECK and FI_DUPLICATE_INVOICE_CHECK in order to understand how the standard works.

why do you select values of EKBE table? what will happen if you have an invoice not making reference to a PO?

BSIP table is the key here.

And finally check this thread too:

Best regards.

Edited by: Pablo Casamayor on Aug 10, 2011 4:31 PM

0 Kudos

Hi,

Again same issue, No BELNR.. The code you had given also provides the same deep structure which I have but BELNR is blank.

I tried other exits as well but everywhere BELNR is coming blank when posting is done through MIRO. It displays values when POST is pressed from MIR7.

Thanks,

Harjeet

0 Kudos

Hi,

I tried other exits as well but everywhere BELNR is coming blank

even badi MRM_HEADER_CHECK?

if you are so interested in getting BELNR field then put a break-point in fm NUMBER_GET_NEXT and you´ll see where the invoice number is generated.

I insist again check fm´s MRM_DUPLICATE_INVOICE_CHECK and FI_DUPLICATE_INVOICE_CHECK.

Table BSIP is the key here.

why do you select values of EKBE table ?

what will happen if you have an invoice not making reference to a PO ?

Best regards.

Edited by: Pablo Casamayor on Aug 10, 2011 5:46 PM

0 Kudos

Hello,

I agree with you and I can anytime change the table instead of EKBE. But that won't resolve my problem. I need to check table RBKP as well to find out that if its an Invoice or credit memo or something else. And for that I require BELNR . Moreover when I applied the messages in OMRM transaction it checks for duplicate invoices for these conditions:

Vendor

Currency

Company code

Gross invoice amount

Reference document number

Invoice document date

But I have a condition where user edits Reference Document Number XBLNR and then post the document. There this validation fails.

Please suggest as the scenario is pretty clear to you now.

Thanks

Harjeet

0 Kudos

Hello ,

Yes I tried that BADI as well and BELNR is not there too.

Also I checked table BSIP, here the key fields have XBLNR and BELNR as well. Now in my situation XBLNR gets changed every time and BELNR I don't have it.

In this situation how would I get the exact conclusion that particular document is posted or not.

Thanks,

0 Kudos

Hi,

I need to check table RBKP as well to find out that if its an Invoice or credit memo or something else. And for that I require BELNR.

You´re wrong.

In order to find out if the document is an Invoice or Credit memo or something else you do not need field BELNR.

Check this thread:

Best regards.

Edited by: Pablo Casamayor on Aug 10, 2011 7:32 PM

0 Kudos

I think we are missing something.

Here you mean that in BADI "INVOICE_UPDATE" I have S_RBKP_NEW flowing which contains field XRECH. Now when this field is blank or X will indicate that the document is invoice or credit memo. Fine if that is the case then this problem is resolved for RBKP.

But other issue is still pending where I cannot use table BSIP because of the reasons I mentioned above and while using EKBE I don't have BELNR again and without which I am again helpless.

Please suggest something for this as well.

0 Kudos

Hi,

In this situation how would I get the exact conclusion that particular document is posted or not.

In order to know if a particular document is posted or not there is field RBKP-RBSTAT.

if you double click on data element RBSTAT ,

and then double click again on domain RBSTAT, then if you go to "Value Range" tab

you´ll see the values available:

1 Defined for background verification

2 Deleted

3 With Errors

4 Correct (posted, not completed)

5 Posted

A Parked

B Parked and completed

C Parked and held

D Entered and held

E Parked and released

Again i insist please read this:

http://wiki.sdn.sap.com/wiki/display/ERPFI/DuplicateInvoiceCheck

http://wiki.sdn.sap.com/wiki/display/Snippets/BusinessTransactionevents%28BTE%29

and check MRM_DUPLICATE_INVOICE_CHECK and FI_DUPLICATE_INVOICE_CHECK

Regards.

Edited by: Pablo Casamayor on Aug 10, 2011 7:57 PM

0 Kudos

This seems helpful.

If this is the case then would you prefer that RBSTAT itself fills the purpose since S_RBKP_NEW is flowing with this field as well. And it that field is 5 then I must display the error that this document is already been posted.

Will this much validation be sufficient or there may be any other scenario functionally, since I am a technical guy not functional so may not know any other possible scenario for this RBSTAT.

Thanks a lot for the helpful replies.

0 Kudos

Hi,

If this is the case then would you prefer that RBSTAT itself fills the purpose since S_RBKP_NEW is flowing with this field as well. And it that field is 5 then I must display the error that this document is already been posted.

No, if i was you i would raise the message before posting (e.g. when holding or parking the document).

Will this much validation be sufficient or there may be any other scenario functionally, since I am a technical guy not functional so may not know any other possible scenario for this RBSTAT.

I think this must be answered by a functional unless you´re the one defining the request.

The best advice i can give you is to read carefully all the information of this thread and reconsider again what you´re trying to do.

Regards.

Edited by: Pablo Casamayor on Aug 10, 2011 8:10 PM

0 Kudos

Hello,

I wish I can reward more points.

I will get back in case the problem still there.

Thanks a lot for the helpful points and answers provided.

0 Kudos

Hello,

Problem still persists.

Value for S_RBKP_NEW-XRECH works fine but S_RBKP_NEW-RBSTAT is always 5 i.e. posted.

I have taken a PO which is posted for Invoice but credit memo is not done. It is working fine for Invoice but as credit memo is not yet done RBSTAT should not be equal to 5, but it is still 5.

Please help.

0 Kudos

Hi,

again read this OSS Note:

Note 305277 - Check for double credit memos

https://service.sap.com/sap/support/notes/305277

Best regards.

0 Kudos

Dear Pablo,

I have already checked this SNOTE and its not useful to me.

I would appreciate if you please suggest me as per my scenario since I have already done all the searching and found nothing useful.

Thanks,

Harjeet

0 Kudos

Hi,

I have already checked this SNOTE and its not useful to me.

Why is it not useful to you?

Regards.

Former Member
0 Kudos

Hello,

Problem still persists.

Value for S_RBKP_NEW-XRECH works fine but S_RBKP_NEW-RBSTAT is always 5 i.e. posted.

I have taken a PO which is posted for Invoice but credit memo is not done. It is working fine for Invoice but as credit memo is not yet done RBSTAT should not be equal to 5, but it is still 5.

Please help.