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 a Z table

Former Member
0 Likes
716

Hi,

I need to update a Z table.. ( update is a primary key .. this table has 7 P. keys )

Bcoz of performance reasons, I can not go line by line and use SET command..

IS there any other way i can upadte the records of this table in one shot.. like..

UPDATE <ztable? from <internal table> but I think this can not update the P. key

Modify will not work as it would insert a new entry in the table....

Any ways to handle this issue.. apart from looping it through...

Hi,

I need to update a Z table.. ( update is a primary key .. this table has 7 P. keys )

Bcoz of performance reasons, I can not go line by line and use SET command..

IS there any other way i can upadte the records of this table in one shot.. like..

UPDATE <ztable? from <internal table> but I think this can not update the P. key

Modify will not work as it would insert a new entry in the table....

Any ways to handle this issue.. apart from looping it through...

5 REPLIES 5
Read only

Former Member
0 Likes
691

Hi Dhruv,

FIRST TEST IN SANDBOX or DEV REGION/SERVER.

THIS METHOD IS NOT TESTED BUT MIGHT JUST WORK , TRY ONLY IF NO OTHER SOLUTION AVAILABLE.

TAKE THE BACKUP OF THE TABLE BEFORE DOING ANY CHANGES.

Consider a following example.

ZT00_EMP has employee data and the PK of this constituted by MANDT, EMP_NO and ACC_NO.

Now you want to change the values in say ACC_NO column for all the entries.i.e. you want to update records.

Add a new column (in SE11 ) in the table say - ACC_NO_1

and update the new/changed values in this column in the table. After this , in SE11 change the table defination by removing the ACC_NO from key and adding ACC_NO_1 in the key. So the new key will be MANDT, EMP_NO and ACC_NO_1. You can either delete column ACC_NO and rename column ACC_NO_1 to ACC_NO or leave it as it is but then you will have to change all programs for name from ACC_NO to ACC_NO_1.

You can always do this in INTERNAL TABLE first and then UPDATE ZTABLE from ITAB..... (FOR DATA PART)

Hope this works.

PLEASE TAKE BACKUP FIRST.

Regds,

Gaurav

Edited by: Gaurav P Fadnis on Mar 7, 2008 11:05 AM

Read only

Former Member
0 Likes
691

Helo,

Check this out (a sample code).

DATA:it_spfli TYPE TABLE OF spfli,

wa_sp LIKE LINE OF it_spfli.

SELECT *

FROM spfli

INTO table it_spfli

WHERE carrid = 'UA'.

LOOP AT it_spfli INTO wa_sp.

wa_sp-fltime = '800'.

MODIFY it_spfli FROM wa_sp INDEX sy-tabix TRANSPORTING fltime.

ENDLOOP.

UPDATE spfli FROM TABLE it_spfli.

if sy-subrc = 0.

write :'updated'.

endif.

Hope this solve ur issue.Be sure that u have all the fields with data in the internal table.

Neeraj.

Read only

Former Member
0 Likes
691

hi

try to use

INSERT into <db table name > VALUES <WA name>.

OR

INSERT dbtab FROM TABLE itab.

Read only

Former Member
0 Likes
691

hi,

use the following.

update target source.

This changes the content of one or more lines of the dbtable specified in TARGET .The entries in source determine which columns of which lines are changed, and how they are changed.

The changes are definitively copied to the database with the next database commit. Until that point, they can still be undone using a database rollback .

regards

sandhya

Read only

Former Member
0 Likes
691

I think to update primary key only way is Using SET