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: 

general

Former Member
0 Kudos

if we try to modify the record which does not exist in database table then what it happens will new record will be updated ?plz explain me.

1 ACCEPTED SOLUTION

aris_hidalgo
Contributor
0 Kudos

Hi,

The MODIFY statement either changes the current record or inserts a new one. Here is the syntax:


MODIFY target FROM source. 



Effect 
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. 

Note 
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. 


9 REPLIES 9

aris_hidalgo
Contributor
0 Kudos

Hi,

The MODIFY statement either changes the current record or inserts a new one. Here is the syntax:


MODIFY target FROM source. 



Effect 
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. 

Note 
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. 


Former Member
0 Kudos

Hi Manjula

<b>To insert or change a single line in a database table, use the following: </b>

MODIFY <target> FROM <wa> .

The contents of the work area <wa> are written to the database table <dbtab>. The work area <wa> must be a data object with at least the same length and alignment as the line structure of the database table. The data is placed in the database table according to the line structure of the table, and regardless of the structure of the work area. It is a good idea to define the work area with reference to the structure of the database table.

<b>If the database table does not already contain a line with the same primary key as specified in the work area, a new line is inserted. If the database table does already contain a line with the same primary key as specified in the work area, the existing line is overwritten. SY-SUBRC is always set to 0. </b>

A shortened form of the above statement is:

MODIFY <dbtab>.

In this case, the contents of the table work area <dbtab> are inserted into the database table with the same name. You must declare this table work area using the TABLES statement. In this case, it is not possible to specify the name of the database table dynamically. Table work areas with the same name as the database table (necessary before Release 4.0) should no longer be used for the sake of clarity.

<b>

Inserting or Changing Several Lines</b>

To insert or change several lines in a database table, use the following:

MODIFY <target> FROM TABLE <itab> .

Those lines of the internal table <itab> for which there is not already a line in the database table with the same primary key are inserted into the table. Those lines of the internal table <itab> for which there is already a line in the database table with the same primary key overwrite the existing line in the database table. The same rules apply to the line type of <itab> as to the work area <wa> described above.

SY-SUBRC is always set to 0. SY-DBCNT is set to the number of lines in the internal table.

Regards Rk

Message was edited by:

Rk Pasupuleti

Former Member
0 Kudos

Hi

It inserts a NEW RECORD

Reward points if useful

Regards

Anji

Former Member
0 Kudos

Hai,

Modify will modify the existing record in the database if record is there.

If it is not there it will insert a new record in database.

Reward if useful.

Regards,

Umasankar

Former Member
0 Kudos

hi

good

if you want to update ther record which does not exist in the database table than no record ll update,

if the record is already existed ,in that case the same record ll update.

thanks

mrutyun^

Former Member
0 Kudos

Why can't you press your F1 key and see what the help says?!

Former Member
0 Kudos

Hi Manjula....

Modify works for both inserting if the record does not exist and if the record exist then it modifies the record .. or you can say overwrites the same record... please readhep on modify you will be done with the command...

Also please do use transporting and index options always with modify ststement ..it helps in performance tuned programming...

Regards

Jayant

sreeramkumar_madisetty
Active Contributor
0 Kudos

Hi

It creates a NEW RECORD

Regards,

Sreeram

Former Member
0 Kudos

hi

A new record is inserted

regards

shinu