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 replace the update staement with a modify statement

Former Member
0 Likes
1,056

how to convert this update stat to a modify stat?

Message was edited by:

Ashwin A

5 REPLIES 5
Read only

Former Member
0 Likes
811

HI Ashwin,

Do it this way,

LOOP AT I_YIBRK_EARNINGS.

MODIFY YIBRK_EARNINGS FROM I_YIBRK_EARNINGS.

CLEAR I_YIBRK_EARNINGS.

ENDLOOP.

Regards,

Jayant

Read only

Former Member
0 Likes
811

Hi..

tables:

ZSRMTST .

data:

itab like standard table of ZSRMTST with header line.

select * from ZSRMTST

into table itab.

loop at itab.

itab-unam = sy-uname.

itab-uzeit = sy-uzeit.

modify itab.

endloop.

modify ZSRMTST from itab.

Read only

Former Member
0 Likes
811

Hi

MODIFY <DB TABLE> FROM <INTERNAL TABLE>

To insert or change a single line in a database table, use the following:

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.

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.

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.

Reward points if useful

Regards

Anji

Read only

Former Member
0 Likes
811

hi ashwin,

update->it is used for only internal tables

modify->used fro both internal and database tables.

generally modify = update + insert which means if no record exists then modify will create a record and places

Read only

Former Member
0 Likes
811

Hi Ashwin,

Refer this code :

loop at itab.

itab-matnr = '00000000000001'.

itab-mtart = 'FERT'.

modify itab.

clear itab.

endloop.

Reward points if helpful.

Regards,

Hemant