‎2007 Feb 22 8:17 AM
Hi frnds,
Frankly speaking i hav gone thru SDN. but not getting exactly wht is the
concept behind
Insert
update
modify
frnds i m not getting wht is the difference between update and modify..
plzz help me...
with regards,
rajesh
‎2007 Feb 22 8:21 AM
<b>Insert</b>
Inserts new record
<b>Modify:</b>
If the value of key fields in the internal table matches with the key fields values in database table,modify will update the existing entry.Otherwise,it will insert new entry.
<b>Update:</b>
To update db table,it is mandatory that the value of key fields in internal table should match with database table.
go through this link...
‎2007 Feb 22 8:32 AM
Hi santosh thnks,
in case of modify didnt get this statement plzz explain.
"modify will update the existing entry.Otherwise,it will insert new entry.".
regards,
rajesh
‎2007 Feb 22 8:45 AM
hi Rajesh,
It means if the database already has any entry it will update the entry with the new data else will insert the record ..
i.e, for example condsider there is a record already with the following fields .
doc_no field_no well_no
001 002 003
now if you use modify data with the same document number but with different well number
now the record gets modified this way ..
doc_no field_no well_no
001 002 004
Hope this is clear for you now
Regards,
Santosh
‎2007 Feb 22 8:52 AM
Hi santosh thnk u very much.
can u plzz give same type of examples to get understand "update" and insert plzzz
thnking u.
regards,
rajesh
‎2007 Feb 22 8:56 AM
<b>Update</b>
Increase the number of occupied seats on Lufthansa flight 0400
on 28.02.1995 by 3 in client 2:
TABLES SFLIGHT.
UPDATE SFLIGHT CLIENT SPECIFIED
SET SEATSOCC = SEATSOCC + 3
WHERE MANDT = '002' AND
WHERE CARRID = 'LH' AND
CONNID = '0400' AND
FLDATE = '19950228'.
<b>
Insert</b>
TABLES SCUSTOM.
SCUSTOM-ID = '12400177'.
SCUSTOM-NAME = 'Robinson'.
SCUSTOM-POSTCODE = '69542'.
SCUSTOM-CITY = 'Heidelberg'.
SCUSTOM-CUSTTYPE = 'P'.
SCUSTOM-DISCOUNT = '003'.
SCUSTOM-TELEPHONE = '01234/56789'.
INSERT INTO SCUSTOM VALUES SCUSTOM.
‎2007 Feb 22 8:57 AM
hi Rajesh,
Insert is for inserting a new record
if you use this statement new record with document number 002 which is not already present in the database gets inseted to database ...
i.e,
doc_no field_no well_no
002 002 003
where as update will update the existing record of database .. if that is not there it does nothing ..
on using update statement for this
i.e
doc_no field_no well_no
002 002 004
your well number gets updated from 003 to 004 ... for suppose it that document is not there it does nothing ..
hope you are clear now
regards,
Santosh
‎2007 Feb 22 9:01 AM
Hi,
Consider that ZXX table u have firlds like
NAME, AGE, QUALIFICATION.
U are going to insert a new record to teh table.
<b>INSERT.</b>
i_zxx-name = 'Judith'.
i_zxx-age = '25'.
i_zxx-qualification = 'BE'.
INSERT INTO ZXX VALUES i_zxx.Now the new record get inserted. U can check sy-subrc if it is 0 then success else it will be non-zero.
Now <b>MODIFY:</b>
I would liek to Modify the record or UPDATE.
SELECT * FROM ZXX
INTO i_zxx
WHERE name = 'Judith'
AND age = '25'.
if sy-subrc = 0.
i_zxx-name = 'Judith'.
i_zxx-age = '25'.
i_zxx-qualification = 'BE(EC)'.
UPDATE zxx FROM i_zxx.
endif.Now the record will get updated.
Hope u r clear. <b>When u r updating or modifying it will check whether all teh values in the key fields are same then it will do so, else it will insert as a new row in update.</b>
Reward if this helps.
‎2007 Feb 22 9:17 AM
‎2007 Feb 22 9:30 AM
‎2007 Feb 22 8:21 AM
Insert: it will insert the record into table.
Upate: it is useful to update the existing record.
Modify: It is like insert/update. It check the whether the records is exist, it if exist then it will update the record otherwise it will insert the record.
‎2007 Feb 22 8:39 AM
INSERT :
It allows you to insert one or more lines into the database table <target>. You can only insert lines into an ABAP Dictionary view if it only contains fields from one table, and its maintenance status is defined as Read and change. You may specify the database table <target> either statically or dynamically.
UPDATE :
It allows you to change one or more lines in the database table <target>. You can only change lines in an ABAP Dictionary view if it only contains fields from one table, and its maintenance status is defined as Read and change. You may specify the database table <target> either statically or dynamically.
MODIFY :
If the database table contains no line with the same primary key as the line to be inserted, MODIFY works like INSERT, that is, the line is added.
If the database already contains a line with the same primary key as the line to be inserted, MODIFY works like UPDATE, that is, the line is changed.
For performance reasons, you should use MODIFY only if you cannot distinguish between these two options in your ABAP program.
You can add or change one or more lines <lines> in a database table <target>. You can only insert or change lines in an ABAP Dictionary view if it only contains fields from one table, and its maintenance status is defined as Read and change. You may specify the database table <target> either statically or dynamically
Pls. Mark if useful
‎2007 Feb 22 8:45 AM
Hi,
<b>INSERT:</b>Inserts a new line in the internal table itab using an explicit
or implicit index specification. You can only use this variant
with index tables (standard or sorted tables).
<b>UPDATE:</b> Updates values in a database table (see Relational Databases).
You can specify the name of the database table either directly
in the form dbtab or at runtime as contents of the field
dbtabname. In both cases, the table must be known to the ABAP
Dictionary. Normally, lines are updated only in the current
client. Data can only be updated using a view if the view
refers to a single table and was created in the ABAP Dictionary
with the maintenance status "No restriction".
<b>MODIFY:</b>Changes a single entry in the internal table itab, specifying
the key explicitly or implicitly. You can only use this variant
with index table (standard or sorted tables).
Hope this helps.
Reward if helpful.
Regards,
Sipra
‎2007 Feb 22 9:39 AM
<b>INSERT</b> : allows to insert one or more lines into database table.
<b>UPDATE</b> : allows you to change one or more lines in the database table.
<b>MODIFY</b> : If database table contains no record with same primary key as the record to be inserted, MODIFY works like INSERT, ie record is inserted into database table.
If the database already contains a record with the same primary key as record to be inserted, MODIFY works like UPDATE, ie record gets changed.
For performance reasons, you should use MODIFY only if you cannot distinguish between these two options in your ABAP program.
‎2007 Feb 22 10:06 AM
Then Frnds there is no difference btween update and modify...
they are nearly same only the diff is that in case of modify if at all key are not same then also it will go for update but in case of update its not possible.
plzz clarify.
Frnds really thanking u all.......
regards,
rajesh
‎2007 Feb 22 10:11 AM
you are confused.
the diff is that in case of modify if at all key are not same then it will go for Insert but in case of update its not possible.
‎2007 Feb 22 10:14 AM
aye, i think you got it.
with "update" you can only change existing records on your database.
if the record you wish to update doesnt exist, you get a sy-subrc <> 0.
with "modify" you can change existing records as well as with update.
if the record you wish to mdoify doesnt exist, the record will be inserted.
so the modify statement seems more powerful than the update statement.
BUT be aware that not everytime you are trying to update a non existing record , it´s your desire to have the record created then.
another important HINT is:
MODIFY is a ABNAP-open-sql statement, and probably will not work in any datacase system. so dont get used to it too much.