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: 

Mass Update with Update Tables

sinan_keklik
Associate
Associate
0 Kudos
1,192

Hi,

is it possible to make an mass update without updating all Fields of the internal table?

The following Code does update all Fields.

UPDATE dbtab FROM TABLE itab.

But I want to update only some Fields. But different Fields in every record. So an

UPDATE dbtab SET f1 ... fn.

is not what I want. This does update indeed only a couple of Fields, but for each record the same value.

I want to avoid looping about the internal table and do single updates.

Sinan

6 REPLIES 6

Former Member
0 Kudos
425

Hi,

Try creating a projection view in SE11 for the corresponding table...

Create the projection view with the fields that you want to update along with the key fields..

Then try using

DATA: itab_view TYPE STANDARD TABLE OF z_viewname.

UPDATE z_viewname FROM TABLE itab_view.

Thanks,

Naren

0 Kudos
425

Hi,

I have no experience with Projection Views. How does your hint work?

Can I make a View do my update and delete the View afterwards.

Sinan

0 Kudos
425

Projection view is nothing but selection of few columns of existing table.

You must be aware that view is not a physical entity, it is just a window over the database table.

Suppose the table has 10 fields and you want to update only 2 fields of the table and also include the key fields to identify records uniquely, then create a projection view for only those 2 fields.

Follow this link for help in creating projection view:

http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ed06446011d189700000e8322d00/frameset.htm

After creating view, define table with structure of view.

DATA: itab TYPE STANDARD TABLE OF <view>.

And update table using the internal table.

UPDATE <view> FROM TABLE itab.

View is an ABAP dictionary object. You should not delete it. Because if you run the program after deleting it, it will give an syntax error 'View does not exist'.

0 Kudos
425

But if I want to update all fields. Maybe for the first record only the first 3 Fields. For the second the next 3 and so on.

Does this work, too.

Sinan

0 Kudos
425

Hi Sinan!

Easiest way: read first all fields into an internal table, change the desired fields and update the database from your internal table.

Technically all fields can be changed, but by reading the current values, you will only do a few changes and the rest will stay the same.

Don't forget to enqueue the table before doing the select - otherwise some changes might be done before your update is done.

Regards,

Christian

Former Member
0 Kudos
425

Hi,

if u want to update some fields then use:

Update dbtab from table itab.

and if u want to update different fields in every reord then u hv no other way but to use loop.

so use:

update dbtab from wa_itab.

Jogdand M B