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

Primary key change

Former Member
0 Likes
1,973

Hi Everybody,

I have created a ztable"EMP1" having three keys empno,empname,address.Empno and empname are the primary keys.I had put 10 records in table.Now my req changes and i want one more field in a table i.e.ciry.and empno and city should be primary keys.Can I do this without deleting the original data from the table .

Hi Everybody,

I have created a ztable"EMP1" having three keys empno,empname,address.Empno and empname are the primary keys.I had put 10 records in table.Now my req changes and i want one more field in a table i.e.ciry.and empno and city should be primary keys.Can I do this without deleting the original data from the table .

4 REPLIES 4
Read only

Former Member
0 Likes
932

hi,

you can do that ... after modifying do this .... utilities->data base utilities-> press button save and adjust database..... if you have created table maintainece generator ... then press change button---> press expert mode button and then select check box 'Refresh overview screen' and press enter ...

Regards,

Santosh

Read only

Former Member
0 Likes
932

hi,

The database table can be adjusted to the changed definition in the ABAP Dictionary in three different

ways:

By deleting the database table and creating it again. The table on the database is deleted, the inactive

table is activated in the ABAP Dictionary, and the table is created again on the database. Data

existing in the table is lost.

By changing the database catalog (ALTER TABLE). The definition of the table on the database is

simply changed. Existing data is retained. However, indexes on the table might have to be built again.

By converting the table. This is the most time-consuming way to adjust a structure.

If the table does not contain any data, it is deleted in the database and created again with its new

structure. If data exists in the table, there is an attempt to adjust the structure with ALTER TABLE. If the

database system used is not able to do so, the structure is adjusted by converting the table.

Hope this helps, Do reward.

Read only

Former Member
0 Likes
932

hi,

just modify the table as u require & save it (SE11 tcode).

now go to SE14 give the table name and press edit button,

then click activate and adjust the data.

Reward if helpful

Regards.

Praveen

Read only

Former Member
0 Likes
932

Hai Vaibhav,

To enable ABAP programs to access database tables correctly, the runtime object of a table must correspond to the structure of the table in the database. If the table is changed in the ABAP Dictionary, you must ensure that the database structure of the table is adjusted to the change in the ABAP Dictionary during activation (when the runtime object is rewritten).

The database structure does not need to be changed for certain changes in the ABAP Dictionary. For example, the database table does not need to be adjusted to a change in the field sequence (except for key fields) in the ABAP Dictionary, since the field sequence in the ABAP Dictionary does not have to correspond to the field sequence in the database. In this case, the changed structure is simply activated in the ABAP Dictionary and the database structure remains unchanged.

The database structure of a table can be adjusted to its changed ABAP Dictionary definition in three ways:

By deleting and recreating the database table The table is deleted in the database. The revised version of the table is then activated in the ABAP Dictionary and created again in the database. Data in the table is lost during this process.

By changing the database catalog (ALTER TABLE) Only the definition of the table is changed in the database. Data in the table is retained. The indexes on the table might have to be rebuilt.

By converting the table (see Conversion Process). The database table is renamed and serves as a temporary buffer for the data. The revised version of the table is activated in the ABAP Dictionary and created in the database. The data is reloaded from the temporary buffer to the new database table (with MOVE-CORRESPONDING) and the indexes on the table are built.

The procedure actually used by the system in a particular case depends on the following:

type of structural change

database system used

whether data already exists in the table

If the table does not contain any data, the existing table is deleted in the database and recreated. If there is data in the table, the system tries to change the structure using ALTER TABLE. If the database system used cannot execute the structural change with ALTER TABLE, the table is converted.

Conversion is usually the most resource-intensive method of adjusting structures. But structural changes involving changes to the database catalog can also result in costly internal data reorganizations in some database systems. For details on the processes occurring in the database for structural changes with ALTER TABLE, refer to the documentation of your database system.

Normally you should not adjust the database structure during production. At least all the applications that access the table should be deactivated during the structural adjustment. Since the table data is not consistent during the structural adjustment (in particular during conversion), programs could behave incorrectly when they access this data.

Regards.

Eshwar.