cancel
Showing results for 
Search instead for 
Did you mean: 

Invoice - Runtime Error : DBSQL_DUPLICATE_KEY_ERROR

silveira
Explorer
0 Kudos
3,405

Hi Experts,

I really hope that somebody can help me.

I have a problem in my IDES SAP. When I create an invoice throgh TA VF01, SAP creates an invoice number, but when I try to open this invoice, SAP says that this document doesn't exist and I have a Dump in ST22. See below:

Short Text

Open SQL array insert produces duplicate records in the database.

What happened?

Error in the ABAP Application Program

The current ABAP program "SAPSIPM01" had to be terminated because it has

come across a statement that unfortunately cannot be executed.

What can you do?

Note down which actions and inputs caused the error.

To process the problem further, contact you SAP system

administrator.

Using Transaction ST22 for ABAP Dump Analysis, you can look

at and manage termination messages, and you can also

keep them for a long time.

--------------------------------------

Error analysis

An exception has occurred which is explained in more detail below. The

exception is assigned to class 'CX_SY_OPEN_SQL_DB' and was not caught in

procedure

"FLAG_THESE_ITEMS_AS_MARKED" "(FORM)", nor was it propagated by a RAISING

clause.

Since the caller of the procedure could not have anticipated this

exception, the current program was terminated.

The reason for the exception is:

When an Open SQL array insert is performed, trying to insert a record

into the database table "IPM_TRANSFER_STA" causes the function to terminate if

a record with the same key already exists.

(When an Open SQL individual record insert is performed, this situation

does not cause the function to terminate. SY-SUBRC is set to 4 instead.)

How to correct the error

The exception must either be prevented, caught in procedure

"FLAG_THESE_ITEMS_AS_MARKED" "(FORM)", or

the possibility of it occurring must be declared in the RAISING clause

in the procedure.

To prevent the exception, note the following:

Open SQL array insert should only be used if it is certain that none of

the records specified already exists on the database. If this cannot be

guaranteed, exception CX_SY_OPEN_SQL_DB should be intercepted, and the

error must be resolved.

Line SourceCde

164

165 ENDIF.

166

167 ENDFORM. "CALL_RIGHTS_ATTR_MAPPER_BADI

168

169 " There is a separate database table that keeps the status of the mapping

170 " This table is IPM_TRANSFER_STA.

171 " When flagging the billing items, this table must be modified.

172 " Marking the billing items corresponds to inserting entries in this table.

173 FORM flag_these_items_as_marked USING iv_billing_doc_no TYPE VBELN_VF

174 it_billing_items TYPE TABLE_OF_BILLING_ITEMS.

175

176 DATA lt_transfer_status TYPE STANDARD TABLE OF IPM_TRANSFER_STA.

177 DATA ls_transfer_status TYPE IPM_TRANSFER_STA.

178 FIELD-SYMBOLS: <ls_billing_item> LIKE LINE OF IT_BILLING_ITEMS.

179

180 " Go through the input items and create the entries to be inserted in the database.

181 LOOP AT it_billing_items ASSIGNING <ls_billing_item>.

182

183 CLEAR ls_transfer_status.

184

185 ls_transfer_status-vbeln = iv_billing_doc_no.

186 ls_transfer_status-posnr = <ls_billing_item>-posnr.

187 ls_transfer_status-marked = 'X'.

188

189 APPEND ls_transfer_status TO lt_transfer_status.

190

191 ENDLOOP.

192

193 " Insert all entries at once.

>>>>> INSERT ipm_transfer_sta FROM TABLE lt_transfer_status.

195

196 ENDFORM. "FLAG_THESE_ITEMS_AS_MARKED

197

I checked the table VBRK and there is no created invoice in 2017!

See attachment: table VBRK and table IPM_TRANSFER_STA

Really thanks for the help!

Accepted Solutions (0)

Answers (1)

Answers (1)

Lakshmipathi
Active Contributor
0 Kudos

Have a look at OSS note 196113

silveira
Explorer
0 Kudos

I still could not fix the Problem. I chech the OSS note, but it didn't work