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

how to modify a data base table ?

Former Member
0 Likes
657

Hi,

i am working on a list output where if user is editing a field and that field need to be updated in the data base. table is a z table .

the table has 5 fields .

mandt key field

matnr key field

werks key field

charg key field

lgpla key field

usnam

edate

in the list output , the user will change the values in the lgpla field and that field need to be changed in the data base table.

i have used the stmt :

modify< table> from <internal table> ,

but a new record is added in the data base instead of overwriting the existing one.

but the record can be seen modified in the internal table.

kinldy let me know the method of updating or modifying the existing value in the data base.

thanks and regards,

vikram.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
605

Hi,

Its not possible to change Primary Key contents in the database.

it mention in documentation of MODIFY Statement,



a line is searched for in the database table that has the same content 
in the primary key as the corresponding beginning part of the work area. 

If such a line is not found, 
a new line is inserted according to the same rules as for the INSERT statement. 

If such a line is found, 
this line is overwritten according to the same rules as for the UPDATE statement


if you want insert the modified line first Delete from database,Then Use Modify Statement

Regards,

Raghava Channooru

5 REPLIES 5
Read only

Former Member
0 Likes
605

Hi

Use the Below syntax and see whether table gets modified instead of added new rows.

MODIFY dbtab FROM TABLE itab.

Read only

Former Member
0 Likes
605

Please hit F1 on MODIFY and UPDATE statements and check the documentation. That should give you a solution

Read only

Former Member
0 Likes
605

Hi,

try using below code-

MODIFY scarr_tab INDEX idx FROM scarr_wa

TRANSPORTING currcode.

or modify db from table itab transporting lgpla.

hope this helps

Read only

Former Member
0 Likes
606

Hi,

Its not possible to change Primary Key contents in the database.

it mention in documentation of MODIFY Statement,



a line is searched for in the database table that has the same content 
in the primary key as the corresponding beginning part of the work area. 

If such a line is not found, 
a new line is inserted according to the same rules as for the INSERT statement. 

If such a line is found, 
this line is overwritten according to the same rules as for the UPDATE statement


if you want insert the modified line first Delete from database,Then Use Modify Statement

Regards,

Raghava Channooru

Read only

0 Likes
605

Hi raghava ,

thanks for the update ..really helpful answer.

regards,

vikram.