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: 

MODIFY AND UPDATE

Former Member
0 Kudos
141

CAN MODIFY AND UPDATE OPERATIONS CAN BE DONE ON PRIMARY-KEY

OR NON-PRIMARY KEY.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
103

YOU CAN WRITE UPDATE AND MODIFY ON PRIMARY AND NON-PRIMARY KEYS

<u>UPDATE</u>

The statement UPDATE changes the content of one or more lines of the database table specified in target. The entries in source determine which columns of which lines are changed, and how they are changed.

System fields

The statement UPDATE sets the values of the system fields sy-subrc and sy-dbcnt.

sy-subrc Meaning

0 At least one line has been changed.

4 At least one line was not able to be changed, either because no appropriate line was found, or because the change would generate a line that leads to double entries in the primary key or a unique secondary index in the database table.

The statement UPDATE sets sy-dbcnt to the number of changed lines.

The changes are definitively copied to the database with the next database commit. Until that point, they can still be undone using a database rollback.

<u>MODIFY</u>

The MODIFY statement inserts one or several lines specified in source in the database table specified in target, or overwrites existing lines.

System fields

The MODIFY statement sets the values of the sy-subrc and sy-dbcnt system fields.

sy-subrc Meaning

0 At least one line is inserted or changed.

4 At least one line could not be processed since there is already a line with the same unique name secondary index in the database table.

The MODIFY statement sets sy-dbcnt to the number of processed lines.

The changes are transferred finally to the database table with the next database commit. Up to that point, they can be reversed using a database rollback.

7 REPLIES 7

Former Member
0 Kudos
103

non primary key

Former Member
0 Kudos
104

YOU CAN WRITE UPDATE AND MODIFY ON PRIMARY AND NON-PRIMARY KEYS

<u>UPDATE</u>

The statement UPDATE changes the content of one or more lines of the database table specified in target. The entries in source determine which columns of which lines are changed, and how they are changed.

System fields

The statement UPDATE sets the values of the system fields sy-subrc and sy-dbcnt.

sy-subrc Meaning

0 At least one line has been changed.

4 At least one line was not able to be changed, either because no appropriate line was found, or because the change would generate a line that leads to double entries in the primary key or a unique secondary index in the database table.

The statement UPDATE sets sy-dbcnt to the number of changed lines.

The changes are definitively copied to the database with the next database commit. Until that point, they can still be undone using a database rollback.

<u>MODIFY</u>

The MODIFY statement inserts one or several lines specified in source in the database table specified in target, or overwrites existing lines.

System fields

The MODIFY statement sets the values of the sy-subrc and sy-dbcnt system fields.

sy-subrc Meaning

0 At least one line is inserted or changed.

4 At least one line could not be processed since there is already a line with the same unique name secondary index in the database table.

The MODIFY statement sets sy-dbcnt to the number of processed lines.

The changes are transferred finally to the database table with the next database commit. Up to that point, they can be reversed using a database rollback.

0 Kudos
103

CAN U EXPLAIN

THESE OPERATIONS WILL BE DONE ON PRIMARY KEY

OR

NON-PRIMARY KEY

Former Member
0 Kudos
103

IT WILL BE DONE ON PRIMARY KEY'S OR NON PRIMARY KEY'S.

0 Kudos
103

IT CAN BE ON ANY KEYS

IF USE ON PRIMARY KEYS IT WILL BE VERY FAST

IF U DO THIS FOR NON-PRIMARY IT WILL BE SOME WHAT SLOW

former_member198270
Active Contributor
0 Kudos
103

Hi Ashok ,

That operation can be done only on non primary key .

for example you have a header table with key field X .

now you want to print detail(item) of that header item X .

you will use for all entries in table header .and print the same but if you want to delete field X from detail(item) table you can't do . due to data base constraints .

Reward points if helpful .

Regards ,

Amber S

0 Kudos
103

THANKS AMBER

FOR YOUR ANSWER

SOME ARE TELLING THAT IT CAN BE DONE ON PRIMARY KEY ALSO

THATS THE REASON I GOT CONFUSED