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: 

Insertion + modification in a database table

Former Member
0 Kudos

Hi all,

I want to insert and as well as update a database table with values in an internal table.

The new records should be inserted from the internal table and the existing records should be modified from the internal table.

is there any keyword to do both insertion and updation. or else, please suggest me a logic to do this.

Thanks in advance,

rajan

Use SAP Documentation or Press F1

Edited by: Vijay Babu Dudla on Dec 15, 2008 11:24 PM

1 ACCEPTED SOLUTION

former_member1245113
Active Contributor
0 Kudos

Hi,

use key word MODIFY , this will do your purpose.

if record is not there it INSERTS else it UPDATES the record in the database

Take F1 help for more info

Regards

Ramchander Rao.K

Edited by: ramchander krishnamraju on Dec 15, 2008 7:50 AM

9 REPLIES 9

Former Member
0 Kudos

<<removed_by_moderator>>

Edited by: Vijay Babu Dudla on Dec 15, 2008 11:24 PM

Edited by: Vijay Babu Dudla on Dec 15, 2008 11:27 PM

Former Member
0 Kudos

Hi,

Firsr fill the internal table with the values which u want to insert into database table

Then Use INSERT,UPDATE ....

For more details how to use INSERT ,UPDATE for database table Press F1 on that ....

Former Member
0 Kudos

Hi,

use the keywords like INSERT & UPDATE.

Regards,

Sudhir K.

former_member1245113
Active Contributor
0 Kudos

Hi,

use key word MODIFY , this will do your purpose.

if record is not there it INSERTS else it UPDATES the record in the database

Take F1 help for more info

Regards

Ramchander Rao.K

Edited by: ramchander krishnamraju on Dec 15, 2008 7:50 AM

Former Member
0 Kudos

Hi,

Use MODIFY statement to update the database table.

This will check the primary key, if it is already present then it updates the database otherwise inserts a new record.

Press F1 help on Modify statement for the syntax and hope this solves your problem.

Regards,

Lavanya.

shadow
Participant
0 Kudos

Hi usman,

key words are INSERT and UPDATE chek this example.

CASE SY-UCOMM.

WHEN 'INSERT'.

MOVE LFA1 TO ITAB.

APPEND ITAB.

INSERT INTO LFA1 VALUES ITAB.

IF SY-SUBRC = 0.

MESSAGE I000(0) WITH 'RECORD INSERTED'.

WHEN 'UPDATE'.

MOVE LFA1 TO ITAB.

APPEND ITAB.

UPDATE LFA1 FROM TABLE ITAB.

IF SY-SUBRC = 0.

MESSAGE I000(0) WITH 'RECORD UPDATED'.

ELSE.

MESSAGE E000(0) WITH 'RECORD NOT UPDATED'.

ENDIF.

Edited by: SHAIK JAILABDIN on Dec 17, 2008 4:25 AM

Former Member
0 Kudos

MODIFY dbtab FROM TABLE itab.or

MODIFY (dbtabname) FROM TABLE itab.

Effect

Mass modify: Inserts new lines or updates existing lines of a database table. The primary keys for identifying the lines to be inserted or updated and the relevant values are taken from the internal table itab. The lines of the internal table itab must satisfy the same conditions as the work area wa in addition 1 to variant 1.

Former Member
0 Kudos

Hi,

use key word MODIFY , this will do your purpose.

if record is not there it INSERTS else it UPDATES the record in the database

Take F1 help for more information.

Regards

Amit.

Former Member
0 Kudos

Hi,

INSERT statement only inserts record into database table from internal table. But MODIFY statement to update the database table and also it checks primary key.if the record already present then it updates the database otherwise inserts a new record.

Regards

Md.MahaboobKhan