Application Development 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: 

multiple entries with key fields same in a ZTABLE

Former Member
0 Kudos

Hi

I do have a ZTABLE, with 3 key fields defined earlier. It consists of around 1 lakh records. Later onwards, two of the non keyfields have been made to key fields.

This table is being populated with records at the time of saving a ztransaction.

But some times, the system is updating the same records, some times twice, sometimes thrice, etc. I got to know that all fields (both key fields and non-key fields) of the record are same. That is, records are being updated in to the database table n number of times may be depending of some false logic in the program.

If I tried to enter the same using SM30, it is showing me an error message stating that the record is already existing.

What can be the reson?

6 REPLIES 6

Former Member
0 Kudos

Hi,

The program might be using INSERT...try with UPDATE it checks the record if exist replace else inserts the new record.

OR

Check the entries for the existence in the Ztable before updating the table.

Former Member
0 Kudos

hi there....

since you have updated the table with new key fields at a later point of time.... thats y this error is coming... i would suggest you to first delete all the entries in the the z table, and also write an exception handling code in it. Also check the ztable if the entry you are inserting already exists or not as when we use the insert command , it does not check the valuse that the table already has... you need to chk it individually by using select single command and issue appropriate messages as per the result....

i hope this helps....

regards

Former Member
0 Kudos

hi ,

u haev created the other two keys afterwards.. may b this is the issue ..

better create the fields once again by deleting the previous one's ..

also u are using insert statement which will simply insert this will cause multiple entries ..

better to use update statement it will check for duplicate entries and replace the existing ..

hope it will helps ..

regards,

prashanti

former_member1245113
Active Contributor
0 Kudos

Hi,

If you think your key field combination is strict enough, then please use MODIFY statement to update your table entries.

this does two things

if record already exists it modifies based on the key field combination

else inserts a new record

Please go through the KEY word documenataion of MODIFY

Please verify the keyfield combination you have working fine or not.

regards

Ramchander Rao.K

agnihotro_sinha2
Active Contributor
0 Kudos

hi,

did you adjust the table after changing the key fields from SE14???

Former Member
0 Kudos

Hi

Once you change the primary key field definition of your custom table, you need to revalidate the data and then reload them again into the table.

Also, while updating you should fully qualify your record by giving values to the key fields.

Regards

Raj