SAP Knowledge Base Article - Public

3614558 - SQL Error dbsql_duplicate_key_error while creating billing document in SAP S/4HANA Cloud Public Edition

Symptom

Error : SQL DBSQL_DUPLICATE_KEY_ERROR for flexible billing document number range when trying to generate billing document where flexible billing number range is configured.

Environment

SAP S/4HANA Cloud Public Edition

Reproducing the Issue

  1. Go to VF01
  2. Use OBD as reference to create billing document
  3. On Save, dump is coming - SQL Error dbsql_duplicate_key_error

Cause

The current issue is because of the Flexible Billing Document Number range that has been configured has the To Number , set to 00000099 as per the flexible number range rule with prefix as configured. Since system has already created  billing document till number 99 so its restarting the flow to create billing document with 01,02,03... and since already a document exists in the database with the same number , the issue of duplicate key is occurring and the corresponding error is coming.

Resolution

To resolve the issue , the To Number range needs to be extended to a higher value.

Steps to extend the To number range:

  1. Go to Implementation Activities
  2. Go To Billing and Invoicing
  3. Expand - Custom Adaptations for Billing
  4. Execute Define Number Ranges for Billing Documents
  5. Give Number Range Prefix as maintained
  6. Change the To Number from 00000099 to a larger number, e.g., 09999999
  7. Change the number range status to 99 in place of whatever system is showing as system tried generating multiple times already so new document number should be 100 so we need to keep last number as per database.
  8. Save and lock in the TR and proceed forward.

See Also

3253020 - How to set up flexible billing document numbering

Keywords

sql dbsql_duplicate_key_error, flexible billing document number range, vf01, sap s/4hana cloud public edition, billing document, duplicate key error, implementation activities, billing and invoicing, custom adaptations for billing, define number ranges for billing documents, number range prefix, number range status , KBA , SD-BIL-IV , Processing Billing Documents , Problem

Product

SAP S/4HANA Cloud Public Edition all versions