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: 

Rename DB table column name without loosing data

Former Member
0 Kudos

Hi,

Is it possible to rename a custom z-field in a SAP standard table with out loosing the data in that column? We have millions of records in that Standard table.

Thanks

Sanjay

7 REPLIES 7

guillaume-hrc
Active Contributor
0 Kudos

Hi,

Yes, that should be OK! Especially if you are not changing its type.

Don't forget to re-generate the table maintenance function group/module, if any.

If you have to change type, you can adapt data with the SE14 transaction.

http://help.sap.com/saphelp_47x200/helpdata/en/cf/21f1ab446011d189700000e8322d00/frameset.htm

Best regards,

Guillaume

Message was edited by: Guillaume Garcia

0 Kudos

Hi Guillaume,

I am loosing the data if i rename the column in SE11.

Thanks

Sanjay

0 Kudos

If you rename a column in your db, it is like deleting the field and adding a new one. You will loose data. Best way to do this is to add the new field, transport to production. Write a program to copy the value from the old field to the new field, then delete the old field.

REgards,

Rich HEilman

0 Kudos

Thanks Rich.

What will be the best way to write a program to copy data from old column to new column as i have millions of records.

Sanjay

0 Kudos

Hi Sanjay

I also suggest the way to write a program to shift all data of field to be deleted to new field. You can write a simple code.

Select source field value into variable.

Target field value = variable.

Update table set target field.

Commit work.

OR you can write a BDC program if you can have the target field as any screen field.

Bala

0 Kudos

Should be a simple program.



report zrich_0001.

data: iztab type table of ztab with header line.

select * into iztab from ztab.
loop at iztab.
iztab-newf = iztab-oldf.
modify ztab from iztab.
endloop.




Regards,

Rich Heilman

Former Member
0 Kudos

hi sanjay,

yes u can do that.