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

Update database

Former Member
0 Likes
582

Hi Abapers,

there are 20 fields in a ztable 'ymassn'. I have 4 fields in my internal table 'itab' from ztable. I have populated the internal table. now i want to update the ztable with one of my internal table field 'A'. How can i achieve this without effecting performance much.

I can do this using below logic. but if there are 100records in my internal table then it will db for 100 times.

loop at itab into wa.

update ymassn

set A = wa-A.

endloop.

please help me.

thanks.

6 REPLIES 6
Read only

Former Member
0 Likes
566

UPDATE dbtab FROM TABLE itab

Try this

awrd points if useful

Bhupal

Read only

0 Likes
566

This will work only if the structure of db table and internal table is same.

Read only

Former Member
0 Likes
566

the best thing is to declare ur internal table as Z table type and then use UPDATE ZTABLE FROM ITAB.

Read only

0 Likes
566

I dont require other fields.. in other cr, i have 100 fields in ztable. then how can i?

Read only

0 Likes
566

Get the data in ITAB1.

Declare an internal table ITAB2 as Z table type.

copy the data from ITAB1 to ITAB2.

UPDATE table from ITAB2.

This will avoid UPDATE inside a LOOP.

Read only

Former Member
0 Likes
566

Hi Prem,

Then u can do one thing.

First Declare 2 itabs as type ur Ztable.

Assign the itab2 with the values selected from ZTable.

In First itab do the changes.

Modify the Second itab using first itab in which u have done changes.

Now update ztable using the second itab which is having the final data.

awrd points if useful

Bhupal