cancel
Showing results for 
Search instead for 
Did you mean: 

Duplicate vendor Invoice check in FB60

Former Member
0 Kudos

Hi Experts,

I want to put the duplicate invoice check while posting the vendor invoice through FB60. I want the system to check the duplicate invoices in combination of the Vendor code and vendor invoice number ( we put the vendor invoice no. in the reference field of FB60 ). How to make this possible. I do not want to make the FI validation for the same. Can you please suggest how to go ahead with this.

Thanks,

BABA

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

Suggest you activate the validation of the reference number field where you are storing the invoice number via transaction OB28. When you specify the pre-requsite condition, you can limit the doc type or transaction to effect this validation check.

pls award points if this helps.

Thanks.

Former Member
0 Kudos

Hi,

Goto ur vendor master ... and u can select the Payment transactions in company code segment and press enter then select check double invoice indicator.

all the best

Prasad

Former Member
0 Kudos

Hi Hui Siang,

Since I have not yet got the other solution but to develop a validation which I was not thinking off due to system performances as it lowers the same but there is no other option. Thus can you please suggest me how to create this validation. The requirement is the system should check the reference field ( vendor invoice no. ) in combination with vendor code for previous invoice documents either created through MIRO or FB60 for a particular vendor. For example if you have posted a FB60 / MIRO document no. 51000011 for a vendor code 10000 which has the invoice no. HS151 in the reference field BKPF - XBLNR and you post another document for the same vendor 10000 with the same invoice no HS151, system should give an error saying that 'please check the document no. 51000011 posted with the same invoice'.

I am awaiting for your helpful feedback.

Rgds,

Shailesh

former_member581986
Active Participant
0 Kudos

Hi there,

pls check out the thread below

Especially my post:

Posted: Jul 21, 2007 3:58 PM

You can see there that the document date is part of the comparison procdure, so if the very same invoice was entered twice but for different doc.dates, the 2nd entry is just considered as a different invoice and no message is issued.

In this case, you indeed have no other option than a validation on item level.

It is obvious, that you cannot put a proper validation for this purpose without having an exit. This is because you have to check OTHER documents in the system and the validation w/o an exit allows you only to access the current document.

In the exit, you should simply take the same (or ALMOST the same) selection from the standard function FI_DUPLICATE_INVOICE_CHECK. I would recommend to copy this function to a Z function first and modify the coding like this:

1. In all (!!) selects on table bsip, remove the selectin criterion bldat. This is your main interest, so previous invoices will be compared without considering the document date.

2. Instead of issuing the customized message(s), you just should set the validation to fail (b_result = b_false or similar) and issue the message from the validation. Do not issue any message from the function, or from the validation exit.

If you have further questions on how to set up this validation, pls. feel free to ask.

Hope that helps, points welcome

Csaba

Former Member
0 Kudos

Hi Cisaba,

Really it is very helpful answer from you. Now I have very little query as below, carification to which will make me to start the work:

1. You mean we have to put both Validation and Userexit in place to cater this requirement. Validation will be meant for issuing the message only and user exit for checking the invoice document created previously with the current one in combination of vendor and invoice no not with the invoice date. The validation will be at header level.

2. How to make the validation? Can you please tell me exactly the same steps and information to be inputed in T_code OB28 to make the validation.

3.Ok I will copy the Function Module FI_DUPLICATE_INVOICE_CHECK to Z one and then have to remove all BLDAT where ever it is written in combination with BSIP. If you can please tell me what exactly to be done in this function module.

4. If I copy the above function module to Z one then where I have to attach this Z Function Module to work for.

Eagerly waiting for your reply.

BABA

former_member581986
Active Participant
0 Kudos

Hi Shailesh,

phuu, ok, let's start from the beginning then.

Some theory first:

you need the validation because the standard check takes the doc.date ito consideration and this is not wanted. And you need the exit from the validation (! not a separate exit! not the original), locate the IF-statements where there is an ELSE option ending with function CUSTOMIZED_MESSAGE. It is up to you what to do here. In the original functoin module, the messages are issued here immediately. It can be an error or a warning, depending on the setting in table T100C. If my understanding is correct, you always want to see an error message, bt this should be done in the validation, not in the function module. So you should skip the customized_message function call and just issue the messages here as info message regardless of T100C settings. In this case, remove the function call customized_message (as many times as it occurs) and issue the message included directly as an information. Right after the message was issued, set E_RC to 4, infoming the validation that the check has failed. (Note that the customized_message function is only called if the check has failed, so no worry that you always get the message.

4. Define the exit for the validation

=========================

Go to your form pool Z_RGGBR000 (defined in V_T80D) and locate the statement APPEND EXITS. It should appear few times, locate the last occurence.

Right after that, enter the following:

exits-name = 'U901' .

exits-param = c_exit_param_none.

exits-title = text-901.

append exits.

This will define a new exit namd U901 for the validation routines. If in V_T80D, you already had a Z (or Y) report, check if the string U901 is used in that code already (check for the main program). If this is the case, instead of U901, use another name, it should begin with U followed by 3 digits. Also, you make sure the text symbol text-901 (or the 3 digits you are using) is existing, doubleclick it and enter a description like "Duplicate invoice check validation" or similar.

Well, the exit is published, we have to write the main code now.

go to the very end of your Z_RGGBR000 report and add a new form U901 like follows:

  • Duplicate invoice check validation

FORM U901 USING B_RESULT.

  • Vendor master flag

data: l_reprf like lfb1-reprf.

  • Result of function module

data: l_rc like sy-subrc.

  • Check vendor master first

select single reprf into l_reprf from lfb1 where bukrs = bkpf-bukrs and lifnr = bseg-lifnr.

  • Do not continue if flag is not set.

if L_REPRF is initial.

b_result = b_true.

endif.

check not L_reprf is initial.

  • Call modified function module

CALL FUNCTION 'Z.....your function'

EXPORTING

i_bukrs = bkpf-bukrs

i_lifnr = bseg-lifnr

i_waers = bkpf-waers

i_bldat = bkpf-bldat

i_xblnr = bkpf-xblnr

i_wrbtr = bseg-wrbtr

i_koart = bseg-koart

i_reprf = L_reprf

i_shkzg = bseg-shkzg

i_xumsw = bseg-xumsw

i_bstat = bkpf-bstat

i_belnr = bseg-belnr

i_gjahr = bkpf-gjahr

i_blart = bkpf-blart

EXPORTING

e_rc = L_RC.

  • Decide if validation message must be issued or not

if L_RC = 4.

b_result = b_false.

else.

b_result = b_true.

endif.

endform.

After this, activate the source code. Make sure you have defined the text-symbol 901 before!

5. Define the validation

=================

Go to OB28 now, and enter your company code(s) and the call-up point 002 (line item). If there is a validation defined already, you have to add a new step only, if not, you have to create the validation anew.

I assume there is no validation defined yet, so enter a name for the validation like FI_2 or similar. It should NOT be named DUPLIC or similar, i.e., you should not include the purpose in the validation name. This is because the validation is defined on company code / call-up point level and it may contain many steps for different purposes later. A generic name FI-2 or probably your company code followed by 2 (2 is the call-up point) is the best choice.

Before presing enter go to the last column Validatin active and enter 1 here.

Then press enter and you will get an error that the validation does not exist. No problem, go to menu path Environment --> Validation and let's create a new validation.

First, enter a description for your new validation in the right hand panel. Again, this should be a generic description, tell nothing about duplicate invoice checks here.

You may be asked here to assign a message class to the boolean class 009. You should enter here a Z message class where the validation message should be issued from. If no appropriate message class exits, open a new session go to SE91, enter a new message class Z... press create, enter a description. Then go to the Messages tab there, and create a new message with number 001 (NOT 000) and enter the message text there. E.g. Duplicate entry not allowed.

Coming back to the validation, if the message class was already assigned (this is the case if there was a validation defined earlier), you can create a new step. In case of a new validation, it will become the first step. But if there was already a validation in OB28 for your company code and call-up point 2, then it will be the last step. In the left hand panel, make sure the new (or existing) validation is selected and press the Create Step button (Ctrl-Shift-F5).

In the right hand panel, enter a description for your step. This is the point where you can enter Double invoice check or similar.

We have three parts here, a Prerequisite and a Check part, finally a message.

In the left hand panel, select the Prerequiste. This will activate that screen block in the right side. We have to make sure that our validation is called only for the relevant vendor line items, so press Ctrl-F3 to hange to expert mode ) and enter the following in the Prerequiste window in the right hand panel:

BSEG-LIFNR <> '' AND BSEG-XUMSW = 'X' AND BSEG-KOART = 'K' AND

BKPF-BSTAT = ''

Beware '' is a ' followed by another ' and not a single " !!

Then switch back to normal mode using Ctrl-F1 and check the small lamp below that should be green now. Also, you can see the field descriptions now. If the lamp is red, press Ctrl-F3 again, delete all and copy the above again. Do not bother with line breaks. Switch to Ctrl-F1 again until the lamp is green. OK, what we have told here was please call the validation only if we have a vendor number and if this is a sales relevant item (invoice or credit memo, but not a payment or similar, this is the standard logic as well), and the account type is vendor (K) and this is a normal document.

WHen you are done here and the lamp is green, then go to the left side again and select the Check part. Now you should be able to edit the Check screen lock in the right hand side again. Switch to expert mode and enter simply U901

This is the name of the form in your Z_RGGBR000 report. NO brackets, no spaces, only U901 here. Switch back to Ctrl-F1 and instead of U901, you should see the text of your form (text symbol 901 in report Z_RGGBR000).

Finally, click the Message part in the left side to be able to maintain the message in the right side. If you issued an error from the function module already, you can give here an information, or you can give it as an error if you like. The message number is one of the messages from your Z message class, you have to define the text in SE91 (see above).

When done, save the validation and you can test it immediately.

Here a brief summary what is happening:

OB28 setting defines that in your company code a validation like FI-2 or similar is active on line item level. Whenever a line item is abut to be created, the validation will be called.

However, the prerequisite of the validation is quite strict: only a limited number or vendor items will allow to continue, other line items (G/L, customer, not sales relevant vndor, etc.) will just skip the whole validation.

If the prerequsite was met, the Check part is carried out. Here we have the exit U901.

In the exit, first we check if the vendor is flagged for double invoie checks. If not, we quit and processing can be continued. B_TRUE means it is OK. If the vendor is flagged, we call the new Z function which is almost the same as the original one.

The Z function will check table BSIP, but it will skip the document date comparison. If the current invoice seems to be entered earlier (regardless of the doc.date), instead of the standard customized message (which can be E or W for instance), the very same standard message will be issued as an information. So the user will be informed about the previous document number but the processing won't be stopped. In addition, a return code will be set to 4, meaning check has failed.

Jumping back to the exit, if the return code is 4, we have to tell the validatin that the check has failed (B_RESULT = B_FALSE), otehrwise we can tell the validation that the check was OK (B_RESULT = B_TRUE).

Now we are back in the validation, and, depending on B_RESULT, we just continue processing (B_TRUE), or issue an error message from a Z message class (B_FALSE). As the main standard message was isued already from the Z function, the user should know at this stage what the matter is. Your Z message can be a bit generic one, no need to include the vendor number or the previously issued invoice, etc.

Hope that helps, points welcome

Csaba

Former Member
0 Kudos

Hi Csaba,

My ABAPer has copied the same thing as you have mentioned in your reply and I have also create the validation for check the way you have told but it is not working. In TN FB60 the system is not checking the vendor and reference field if the same has ben posted earlier. ABAPer debugged the program and found that the system is picking the program SAPLFIS0 for the purpose and not the coding which we have done for the purpose. Can you please suggest what to do now.

Rgds,

BABA

former_member581986
Active Participant
0 Kudos

Hi,

if the validation is not executed (put a break point into the code to verify), it will for sure not work. Program SAPLFIS0 is a function pool, having (among others) the oriiginal unction module FI_DUPLICATE_INVOICE_CHECK. I have explained earlier why this does not help: because of the different document dates the standard does not see this as a duplicate entry.

So if your ABAPer was not able to call the Z* function yet, you probably need to change your ABAPer ) I hardly believe that I could describe it more detailed than I did in my previous post. Go to all the steps again and make sure you do not miss anything.

Hope that helps, points welcome

Csaba

Former Member
0 Kudos

Hi Csaba,

You are very right. I have just 3-4 more points which require your expertise. These are as follows:

1. For duplicate invoice check, in vendor master data we put the tick for duplicate invoice check which in background activates the FI_DUPLICATE_INVOICE_CHECK. In addition to this std function module we have created another one Z_FI_DUPLICATE_INVOICE_CHECK as suggested by you. Now my point is how the function module Z_FI_DUPLICATE_INVOICE_CHECK will be performed. In configuration we no where assign the Function module to any thing. This is just get performed by putting the tick in duplicate invoice check field in vendor master data. I checked the both function module in SE37 where-used list adn found that the std Function Module FI_DUPLICATE_INVOICE_CHECK is being used in all the below programs

LF040F00

LF040I00

LFDCBFD0

LFSKBI01

MF05AI00_BETRAG_PRUEFEN

MF05AI10_XBLNR_PRUEFEN

MF05LI00

MFCX1I00

While the Z Function Module Z_ FI_DUPLICATE_INVOICE_CHECK in program ZGGBR000 only.

IS THIS THE REASON THAT Z_ FI_DUPLICATE_INVOICE_CHECK IS NOT BEING PERFORMED WHILE DOING THE DUPLICATE INVOICE ENTRY.

If the Z Function module has to be assigned to all the programs to which the std one is assigned then what to do?

2. the below is the validation which I have made at line item level:

Step 001 - Duplicate Invoice Check

Prerequisite :

Vendor <> '' AND Sales-related = 'X' AND

Account type = 'K' AND

Doc.status = '' (only this line appears in green colour and rest all in black )

Check :

Duplicate Invoice check ( This line appears in green colour )

Message:

E117.

IS THE ABOVE VALIDATION IS CORRECT:

Your help is sincerely appreciated. Please reply asap so that I can get rid of this issue.

Rgds,

BABA

Former Member
0 Kudos

Hi Csaba,

Thanks a lot, It has worked now. Once agian thank you.

Rgds,

BABA

former_member581986
Active Participant
0 Kudos

Hi,

sorry, I was not available in the last days.

Well, it seems the validation was defined correctly, the point is if the Check part in the validation (where you have the exit) was maintained properly.

If the prerequisite is met, then the exit is called. In the exit, you invoke your new function module (Z*) which will deliver a boolean value, i.e, YES or NO. Depending on that, you issue the validation message or not.

As you may have realized, you do not need to touch the original SAP source codes to call your Z function. That's why this solution is not a modification, so it is reliable in case of an upgrade. Should you get some syntax error or similar after an upgrade in the future, then this is an indicator that the original function module (or some includes it is using) have been changed by SAP for the new support package / release. No worry, you only have to compare your Z function with the new (upgraded) SAP function and make the necessary changes. Those will NEVER influence the logic you have implemented here, so you are still on the safe side.

I am happy that you have managed to get this work finally.:)

Hope that helps, points welcome

Csaba

Former Member
0 Kudos

Hi Csaba,

Thanks a ton for the further information. I have already awarded you the maximum point as you have given a very very good solution. Hope that we will be meeting and would helping each other.

Rgds,

BABA

former_member581986
Active Participant
0 Kudos

Hi Baba,

thanks for the points The "hope that helps..." sentence is my default "regards" here, that's why I always use it, even if if the question was answered already and points were assigned.

I think the main goal of this forum is to get some solutions that are working from others, so I am happy being able to help you in this matter.

Hope that helps, points welcome

Csaba

Answers (1)

Answers (1)

Former Member
0 Kudos

Hai Shailesh,

You can check double invoicing by following the following procedure:

In vendor master, under payment data tab, you can find a field "Chk double inv", just check that box.

This would ensure that double invoicing is not made. the system actually compares vendor, currency, amount of invoice, reference document number and invoice date. Only if all the above elements are the same, the system issues a message/ warning. As you would be stipulating vendor invoice number in reference field, on comparison it would not allow another invoice to be created with the same reference and amount.

Hope this would solve your problem.

Assign points if useful..

Smruti

Former Member
0 Kudos

Hi Smruti,

What you have mentioned or other friends are the standard settings. Infact my requriement is different and only specific to the FB60 and not the MIRO. First I do not want to create any validations in OB28. Second the standard settings ie check tick for double invoice in vendor master data I am not removing that tick. Even you can check this also.......for example say an invoice has been posted with doc date 17.07.2007 and Invoice no. 1111 ( Reference field ) for vendor 10000. You can post the same amount for same vendor with different doc date. I know this can be said user's mistake as they should not put the different doc date for the same invoice but by mistake it happens. This happened with my client. Now they have decided to put the check for vendor code and reference field. How to make this possible, I want to know. See if you can provide the solution or any sapients.

Thanks,

BABA