Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Short Dump CX_SY_OPEN_SQL_DB

Former Member
0 Likes
36,759

Hi experts,

While inserting data into a SE11 table, i am getting the following short dump.

Runtime Errors         SAPSQL_ARRAY_INSERT_DUPREC

Except.                CX_SY_OPEN_SQL_DB

Before inserting data, i am sorting my internal table and deleting adjacent duplicates by primary keys and secondary indexes.

Is there any workaround to fix my issue.

Thanks.

Amine

1 ACCEPTED SOLUTION
Read only

Former Member
17,047

Hi,

Inserting Duplicate records from internal table, will give you a dump if you have duplicate entries in the internal table.

Try this addition "ACCEPTING DUPLICATE KEYS" with your INSERT command, that will prompt sy-subrc = 4, instead of throwing a dump.

Definitely you have to be sure of entries in internal table as suggested by Raymond.

Cheers,

Sumit

33 REPLIES 33
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
17,047

Basically a data exists in database with the same key. so better first check if you want to update it if yes then please use Modify statement.

Read only

0 Likes
17,047

Hi Nabheet,

To be more specific, here the syntax that i am using:

Sort internal table.

Delete adjacent duplicates from internal table comparing primary keys and secondary indexes

insert SE11table from table my internale table.

Do you see any thing wrong?

Amine

Read only

0 Likes
17,047

does you table have any entries?

Its likely there is an entry already that matches the attempted insertion.

Read only

former_member201275
Active Contributor
0 Likes
17,047

Is your table empty to start with? Maybe there is already an existing entry in the table and therefore you get this message?

Read only

0 Likes
17,047

Hi Glenn,

My table is empty of course. I delete the data from it in my program before inserting it again.

Amine

Read only

0 Likes
17,047

You are deleting the data from the Database table in your program i believe if that is the case after deleting did you do a Commit?

Read only

0 Likes
17,047

Please can you post your code, and provide a screenshot of your table.

Read only

0 Likes
17,047

I agree with a lot of the other responses in terms of using MODIFY command. This should do the trick. Have you tried this?

Read only

0 Likes
17,047

Yes Nabheet.

Read only

0 Likes
17,047

Here the code Glen:

SORT wt_report2 BY comp_code costcenter chrt_accts gl_account costelmnt /bic/y_tprtnr co_area profit_center y_labbu y_labdiv y_program part_prctr y_labprbu y_ptnrdiv doc_currcy loc_currcy funcarea fiscper version.

DELETE ADJACENT DUPLICATES FROM wt_report2 COMPARING comp_code costcenter chrt_accts gl_account costelmnt /bic/y_tprtnr co_area profit_center y_labbu y_labdiv y_program part_prctr y_labprbu y_ptnrdiv doc_currcy loc_currcy funcarea fiscper version.
*DELETE ADJACENT DUPLICATES FROM wt_report2 COMPARING all fields.
IF NOT wt_report2 IS INITIAL.
INSERT ycnv_report FROM TABLE wt_report2.
ENDIF.

The underlined fields are my secondary indexes. The other ones are my primary keys.

Read only

0 Likes
17,047

Here an extract of my internal table in debug. Actually i have many empty records because i'm on a dev system, that might be the reason:

Read only

0 Likes
17,047

Here the definition of my secondary indexes, tell me please if you see smthg wrong.

Thx

Read only

0 Likes
17,047

You delete records having identical set of primary keys AND secondary keys (indexes), Do not, you must insure uniqueness for every unique index. Here you can keep two records with same primary keys if one secondary key differs.

So sort and delete comparing ONLY primary keys, then do the same for every index with unique key, but only with keys of one index for each deletion of duplicates.

Regards,

Raymond

Read only

0 Likes
17,047

So you can only have a single record for one funcarea/fisper/version set ?

Read only

0 Likes
17,047

Hi Raymond,

You mean i have to do this:

sort internal table by primary keys.

delete adjacent duplicates comparing primary keys.

sort internal table by secondary indexes.

delete adjacent duplcates comparing secondary indexes.

right?

thanks.

Amine

Read only

0 Likes
17,047

thumb up

Read only

sivaganesh_krishnan
Contributor
0 Likes
17,047

HI Amine,

Check the SAP Notes : 196113 - SAPSQL_ARRAY_INSERT_DUPREC,table  BALHDR

Regards,

Sivaganesh

Read only

snipersap
Product and Topic Expert
Product and Topic Expert
0 Likes
17,047

Dear Amine,

Please take the data that you are trying to insert in a excel sheet.

Find the column which are primary key in your table and mark them in the excel sheet.

Copy the data and put them in the respective fields of the table in SE16.

If you find any output, then these are the entries which already exist in your table while you are trying to insert them via your program.

Solution:

Either correct your program or remove the found entries from the table before inserting them again from your program.

--

Regards

Soumyojyoti Pal

Read only

Former Member
0 Likes
17,047

Hi Pal,

The treatment has to be dynamic

Amine

Read only

anupam_anand
Participant
0 Likes
17,047

Hi Amine,

Try using MODIFY instead of INSERT. In case the entries are found, Modify will overwrite them.

Incase all the entries, already exist, you can also use Update.

Thanks,

Anupam

Read only

Former Member
0 Likes
17,047

I tried modify. It worked, i have no more short dump.

But the number of data in my se11 table is now false, i have only one record instead of 7728 ones.

May be i should decrease the number of keys?!

Amine

Read only

0 Likes
17,047

Sort your internal table by only the primary keys. You shouldn't have duplicates there and again try to run your code.

Thanks,

Anupam

Read only

RaymondGiuseppi
Active Contributor
0 Likes
17,047

Correct code for your indexes would be

* Primary index

SORT wt_report2
   BY        comp_code costcenter chrt_accts gl_account costelmnt /bic/y_tprtnr co_area profit_center y_labbu
             y_labdiv y_program part_prctr y_labprbu y_ptnrdiv doc_currcy loc_currcy.
DELETE ADJACENT DUPLICATES FROM wt_report2
   COMPARING comp_code costcenter chrt_accts gl_account costelmnt /bic/y_tprtnr co_area profit_center y_labbu
             y_labdiv y_program part_prctr y_labprbu y_ptnrdiv doc_currcy loc_currcy.
* Secondary unique index
SORT wt_report2
   BY        funcarea fiscper version.
DELETE ADJACENT DUPLICATES FROM wt_report2
   COMPARING funcarea fiscper version.

So not many records are kept I suppose. Check your index definition.

Also I did not see the client MANDT in the index definition. So I suppose you did not add it to table definition, and were not able to define foreign key relations with standard tables for costcenter or gl_account fieds ?

Regards,

Raymond


Read only

0 Likes
17,047

Thanks Raymond,

In fact i get only one record in the final table which is not correct

I don't need the MANDT since it's a custom table in BW and all records are coming from it.

Amine

Read only

anupam_anand
Participant
0 Likes
17,047

Did it work? I think it should work if you try to use Modify with the primary keys.

Thanks,

Anupam

Read only

0 Likes
17,047

Hi Anupam,

Still not, i think that i may have an issue with the definition of my secondary indexes.

Please refer to the screenshot on top.

Thanks.

Amine

Read only

0 Likes
17,047

Hi Amine,

May be weird but delete your secondary indexes and try to upload.

That way we can be sure of where the issue could be. There may be some rework but just trying to figure out the root of this.

Thanks,

Anupam

Read only

0 Likes
17,047

Did you try this???

Thanks,

Anupam

Read only

Former Member
0 Likes
17,047

Hi,

This error is coming because you are trying to insert a record with the same key as of an existing record.

INSERT statement cannot overwrite the record if it already exists, use MODIFY statement.

regards,

Ashish Rawat

Read only

Former Member
17,048

Hi,

Inserting Duplicate records from internal table, will give you a dump if you have duplicate entries in the internal table.

Try this addition "ACCEPTING DUPLICATE KEYS" with your INSERT command, that will prompt sy-subrc = 4, instead of throwing a dump.

Definitely you have to be sure of entries in internal table as suggested by Raymond.

Cheers,

Sumit

Read only

0 Likes
17,047

Hi Sumit,

Intersting, at least my data will be accepted. And the data will be agregated i guess if the same key already exists.

Amine

Read only

0 Likes
17,047

Hi Amine,

Sy-subrc = 4 should again not update your table.

Thanks,

Anupam

Read only

Former Member
0 Likes
17,047

Hi Amine,

If sy-subrc = 4, then data will not be accepted to be updated in the table.

Cheers,

Sumit