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

Insertin record in table

Former Member
0 Likes
837

Hi,

I was inserting record in custom table, values of primary key in

work area where already present in table.

so i got short dump for entring duplicate values.

Is their any way to avoid short dump in this case so that program

should not be terminated.

Rgds,

Fattesingh

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
791

Hi fattesingh,

1. MODIFY

2. Use MODIFY statement (instead of INSERT,UPDATE etc)

3. MODIFY

will AUTOMATICALLY

take care of insert/update

based upon the

primary key combination

FOUND / NOT FOUND

in the database table,

based upon the work area fields.

regards,

amit m.

7 REPLIES 7
Read only

Former Member
0 Likes
792

Hi fattesingh,

1. MODIFY

2. Use MODIFY statement (instead of INSERT,UPDATE etc)

3. MODIFY

will AUTOMATICALLY

take care of insert/update

based upon the

primary key combination

FOUND / NOT FOUND

in the database table,

based upon the work area fields.

regards,

amit m.

Read only

ferry_lianto
Active Contributor
0 Likes
791

Hi Fattesigh,

Please use <b>MODIFY</b> statement instead of INSERT.

It will modify the record with new values if the record already exits otherwise it will insert new record.

Hope this will help.

Regards,

Ferry Lianto

Read only

0 Likes
791

Use MODIFY statement instead of update and insert.

Read only

Former Member
0 Likes
791

Hi,

Use MODIFY Statement which acts like 2 Open Sql queries (Insert and Update), if the records already exists it updates else it inserts the new record) and Regarding your case to avoid short dumps, use user-defined messages.

For Ex:

Insert zemployee.
if sy-subrc <> 0.
MESSAGE 'RECORD ALREADY EXISTS' TYPE 'S'.
ELSE.
MESSAGE 'RECORD SUCCESSFULLY CREATED' TYPE 'S'.
ENDIF.

Read only

Former Member
0 Likes
791

Hi,

Use MODIFY statment instead of INSERT.

MODIFY stmt will insert the record in table only if it is not present in table else it will just update the record with new values in that workarea.

Rgds,

Prakash

Read only

Former Member
0 Likes
791

hi,

I want to know how to do exception handling to avoid short dump.

coz i had checked sy-subrc after the insert

but still short dump was gifted to me.

I know modify command.

Rgds,

Fattesingh

Read only

0 Likes
791

Hi,

use 'ACCEPTING DUPLICATE KEYS' with insert statement.

whenever any duplicate primary key record comes , system will modify existing records.

Ex: INSERT ztable FROM TABLE i_tab ACCEPTING DUPLICATE KEYS.

Regards

Appana