While releasing an Accounts Receivable invoice batch, the batch suspends with system message 6909. The ardebug will give the following error message:

Violation of PRIMARY KEY constraint 'HistDocSlsTax0'. Cannot insert duplicate key in object 'HistDocSlsTax'.


There is another invoice in the ardoc table with the same reference number as one of the invoices in this batch. The result is that Solomon is trying to insert a duplicate record in the HistDocSlsTax table.


To work around this problem, follow these steps:

  1. Find the duplicated records. To do this, run the following SQL statement:

    select refnbr, doctype, batnbr, * from ardoc tablea 
    where doctype='IN' and refnbr IN
    (select refnbr from ardoc tableb where doctype='IN' and tablea.refnbr=tableb.refnbr
    and tablea.tstamp<>tableb.tstamp and (tablea.batnbr='<XXXXXX>' OR tableb.batnbr='<XXXXXX>'))
    order by refnbr, batnbr

    Note <XXXXXX> is a placeholder for the suspended batch number.

    This script will return the ardoc record of the two (or more) invoices with the same reference number.

  2. Update the invoice in the suspended batch to something slightly different, such as by adding an "A" to the end. Here is an example of the necessary update statements:

    update ardoc set refnbr='01013A' where refnbr='010130' and batnbr='<XXXXXX>'
    update artran set refnbr='01013A' where refnbr='010130' and batnbr='<XXXXXX>'

More Information

When you select a new reference number, make sure that the new reference number has not been already used. Also try to keep the invoice number the same length as the other reference numbers.

Need more help?

Expand your skills
Explore Training
Get new features first
Join Microsoft Insiders

Was this information helpful?

What affected your experience?

Thank you for your feedback!