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

what is difference between modify and update i am using

Former Member
0 Likes
5,544

hi

what is difference between mofify and update

my requiremen is to have three condition checkec while mofifying or updating from a internal table

the three fields are

cus no

status

date these all are primary key in the database table

so which sould i use modify or update

there might be entry already existing in database table or new entry to be created if already existin it should check on the primary keys and updatat if not it should add a record

pls suggest whihc to use and how to implement the check on teh threee primary key

like if modify ztable from table it_test

now where condition ? can be used or not with modify? and if yes how

if not should i use update will update create a new entry if no entry is there and please give syntex

regards

Arora

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,277

Hi Nishant Arora,

Modify: It works in performing two actions.

They are: Insert + Update.

For Example If a record that is exited in database, so you are modifying that record, it updates that particular record.

Similarly, If the is not existed in the database, you are modifying it, it inserts a new record.

Update: Update means just it updates the status, I mean it only updates the record. It doesn't inserts any new record if that particular record is not present in the database.

These are the cases you need to write these statements.

Syntaxes: :

Go through this links please.,

http://help.sap.com/saphelp_nw04/helpdata/en/e7/968aa8b2384dd9835f91e7f8470064/content.htm

http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb35eb358411d1829f0000e829fbfe/content.htm

Reward points if useful

Cheers,

Swamy Kunche

Edited by: Swamy Kunche on Jun 11, 2008 2:41 PM

10 REPLIES 10
Read only

Former Member
0 Likes
2,277

Modify is used to modify the existing entry in the internal table if the entry is not found it created the new entry

update is to update the existing entry if the entry is not found statement fails

you can use modify with where

Read only

Former Member
0 Likes
2,278

Hi Nishant Arora,

Modify: It works in performing two actions.

They are: Insert + Update.

For Example If a record that is exited in database, so you are modifying that record, it updates that particular record.

Similarly, If the is not existed in the database, you are modifying it, it inserts a new record.

Update: Update means just it updates the status, I mean it only updates the record. It doesn't inserts any new record if that particular record is not present in the database.

These are the cases you need to write these statements.

Syntaxes: :

Go through this links please.,

http://help.sap.com/saphelp_nw04/helpdata/en/e7/968aa8b2384dd9835f91e7f8470064/content.htm

http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb35eb358411d1829f0000e829fbfe/content.htm

Reward points if useful

Cheers,

Swamy Kunche

Edited by: Swamy Kunche on Jun 11, 2008 2:41 PM

Read only

Former Member
0 Likes
2,277

hi

as given in my problem i want to use the three primary key with modify statment but when i am using with where database field1 = internal_field1

f2 = f2

so one it is not takeing what is syntex to use modify with where clause i dont find any syntex for that

regards

arora

Read only

0 Likes
2,277

Use MODIFY <dbtab> FROM <wa>.

<wa> should be of the same structure as <dbtab>.

The statement itself will take care of the primary key. <wa> will have the same primary key fields and it's values. so this statement checks <dbtab> for the same key fields. If exits, modifies the other field values from <wa>.

If not exist, then creates a new entry with the values from <wa>.

There is no necessity of using a WHERE condition.

Same applies for MODIFY ztable FROM TABLE it_tab also. This is for modifying or inserting more than one record at a time.

Regards,

Lakshmi.

Edited by: Santhanalakshmi V on Jun 12, 2008 11:24 AM

Read only

Former Member
0 Likes
2,277

AS FAR AS DATA BASE TABLE ARE THERE IF YOU USE MODIFY

AND YOU HAVE ENTERED THE DATA IN TABLE CONTROL

SO IT WILL COMBINE WORK OF INSERT AND UPDATE.

UPDATE WORKS ON DATA WHICH IS RESIDES THERE.

Read only

Former Member
0 Likes
2,277

hi

are u sure?

i want to be sure and use where clause with modify statment please suggest the syntex as its not taking the where clasue and condition of three keys with modify

regards

ARora

Read only

Former Member
0 Likes
2,277

Hi Nishant Arora,

I am giving the syntax below. Yes definitely you can use where conditions in MODIFY statement.

For example:

modify itab transporting aenam where ernam = 'LAXMIK' and matnr = 45.

You are saying that you are having three conditions so you can include them and write as below.

MODIFY ITAB TRANSPORTING <FIELDNAME> WHERE COND.,1 AND COND.,2 AND COND.,3.

Reward points if useful.

Cheers,

Swamy Kunche

Read only

Former Member
0 Likes
2,277

hi Swamy

i am mofifying from a internal table so cannot use the transporting all fields

iam using modify

MODIFY ZFIdatabasetable FROM TABLE it_data.

now how to give three conditions in it. ie threee primaty key condition

where key1 = it_key1

key 2 = it_key2

key 3 = it_key3

regards

arora

Read only

Former Member
0 Likes
2,277

Hi Nishanth,

Please go through this thread.

http://www.abapcode.sapbrainsonline.com/2008/03/modify-abap-keyword.html

Cheers,

Swamy Kunche

Read only

Former Member
0 Likes
2,277

solved thanks all