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

simultaneous insert in a z table

Former Member
0 Likes
1,959

hi everyone

in a program, im doing an INSERT into a ztable from an internal table

Now this program is getting executed by several users at the same time and the program is getting a short dump

The ABAP/4 Open SQL array insert results in duplicate database records.

anybody can help me how i can handle this?

I tried to replace INSERT by MODIFY but its not working

1 ACCEPTED SOLUTION
Read only

sridhar_meesala
Active Contributor
0 Likes
1,893

Hi,

You cannot insert duplicate values into the table using INSERT statement. MODIFY or UPDATE would work but that would overwrite the date with the same key fields.

If this table is used to maintain some log, then you have to use INSERT and to help further please post the key fields in the table ?

Thanks,

Sri.

16 REPLIES 16
Read only

sridhar_meesala
Active Contributor
0 Likes
1,894

Hi,

You cannot insert duplicate values into the table using INSERT statement. MODIFY or UPDATE would work but that would overwrite the date with the same key fields.

If this table is used to maintain some log, then you have to use INSERT and to help further please post the key fields in the table ?

Thanks,

Sri.

Read only

0 Likes
1,893

the key field is an ID of 6 characters

Read only

0 Likes
1,893

Hi,

As you said earlier, that different users may insert records at the same time and if the table contains some time field then that would give a dump for having duplicate values. So you better make the time field along with the ID as a key field in the table.

Thanks,

Sri.

Read only

0 Likes
1,893

Define your own number range object for your key field.

Look at transaction SNRO

As you said earlier, that different users may insert records at the same time and if the table contains some time field then that would give a dump for having duplicate values. So you better make the time field along with the ID as a key field in the table.

There is still a change to have duplicates.

Read only

0 Likes
1,893

its a good idea

i'll try to do that

thanks

Read only

0 Likes
1,893

hi sri

another question

when doing the INSERT, its not necessary to specify the field time

i just have to define this field, UZEIT TYPE SY-UZEIT and during the INSERT, this field will be populated automatically, right?

Read only

0 Likes
1,893

>

> hi sri

> another question

> when doing the INSERT, its not necessary to specify the field time

>

> i just have to define this field, UZEIT TYPE SY-UZEIT and during the INSERT, this field will be populated automatically, right?

Nope.

But again: i bet you still will have some duplicates. So just go for your own number range object for your key field. Than you'll know the value will be unique.

To clarify: you said at the same time'. What time will be in that UZEIT field if you get the time for several users at the same time ?

It's the value of your key field that must be unique,

Read only

0 Likes
1,893

hi maen

with the field uzeit, hows its possible to have the dump?there will always be a difference of 1 second, isnt it?

Read only

0 Likes
1,893

i think i must make user as well a key field

the users dont want to go for the option of object range

is making the id, time and user the key fields a plausible solution?

Read only

0 Likes
1,893

with the field uzeit, hows its possible to have the dump?there will always be a difference of 1 second, isnt it?

Nope. Not always.

Why not a number range?

Read only

0 Likes
1,893

>

> is making the id, time and user the key fields a plausible solution?

Sure it's plausible. You may add date as well. And their date of birth... and their zipcode. And the date of birth of their firstborn child... the name of their secret lover...

Why complicate things if you can solve it easily with just a simple number range?

Read only

0 Likes
1,893

Hi Prema,

Why don't you make use of lock objects on the table?

Regards,

Jaya krishna.K

Read only

0 Likes
1,893

Sorry if it sounds a bit out of context, but wouldnt this be a perfect scenario for a enqueue/dequeue process?

Read only

0 Likes
1,893

>

> Sorry if it sounds a bit out of context, but wouldnt this be a perfect scenario for a enqueue/dequeue process?

Would that be a viable option when only inserting new records?

Truth be told: i have no clue what the purpose of his Z-table is and whether he only inserts new records or also need to update existing ones.

Read only

0 Likes
1,893

hi Maen

Ive done the number range

needs to test it

thanks

Read only

Former Member
0 Likes
1,893

Hi,

Before inserting the data into internal table we need to check whether that data is already available in database or not.

if the data is already in database no need to insert the data.Then if parallel users are using no problem.

STEP1:Select the data from table.

STEP2:LOOP The data and check the data whether data is already there or not.

STEP3:Other wise insert the data into table.

regards,

muralii.