Symptom
When saving a production order which contains external subcontracting operation, the error message "Open SQL array insert produces duplicate records i" occurs. At the same time, a dump with the runtime error "DBSQL_DUPLICATE_KEY_ERROR" can be found in ABAP Runtime Errors app.
Environment
SAP S/4HANA Cloud Public Edition
Cause
This is a data inconsistency.
The production order contains external subcontracting operation, so the purchase requisition will be generated when saving the order. Checking in configuration activity 105616 - Define Number Ranges for Purchase Requisitions, the current number range status for purchase requisition, which means the last purchase requisition number generated in the system and whose next number will be the new generated purchase requisition number, is smaller than the highest number of the existing purchase requisitions. As a result, when creating a new purchase requisition, the system may use a number that has already existed in the system, which will cause the duplicate key error.
To check the highest number of the existing purchase requisitions, you could go to Manage Purchase Requisitions - Professional app and sort the Purchase Requisition column in descending order.
Resolution
Change the current number range status value to the next number of the highest existing purchase requisition number in the system.
Keywords
duplicate records, number range, purchase requisitions, production order, Define Number Ranges for Purchase Requisitions, EBAN , KBA , PP-SFC-2CL , Production Orders (Public Cloud) , MM-PUR-REQ-2CL , Purchase Requisitions (Public Cloud) , Problem