Problem: you save documents with use of CRM_ORDER_SAVE function module and you get short dump: SAPSQL_ARRAY_INSERT_DUPREC.
Solution: what you need to do is to check before running CRM_ORDER_SAVE if values in parameter IT_OBJECTS_TO_SAVE are unique. If the values are not unique you will get mentioned short dump because CRM_ORDER_SAVE will try to save the same document multiple times.
Easiest way to get rid of duplicated GUIDs of documents to save will be to use DELETE ADJACENT DUPLICATES command.
None can doubt the veracity of this artcile.