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). This process is clearly explained in the figure below.
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. 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, but the runtime object must be rewritten.
The database structure of a table can be adjusted to its changed ABAP Dictionary definition in three ways:
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.
You lose the data in the table during this process.
Only the definition of the table is changed in the database. Sometimes when you use ALTER TABLE, there are additional actions possible. For example, if you change a column from null to not null, you get time-intensive actions like:
WHERE 'F01' IS NULL
When you use ALTER TABLE, the data in the table is retained (for some databases, when you add a not null column, the system writes the default value into each line).
The indexes on the table have to be rebuilt.
The system renames the database table and it 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:
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 the most resource-intensive method of adjusting structures. However, structural changes involving changes to the database catalog can also result in costly internal data reorganizations in some database systems. For information about the processes occurring in the database for structural changes with ALTER TABLE, see your database system documentation.
You must not adjust the database structure during production. At least all the applications that access the table must be deactivated during the structural adjustment. Since the table data is not consistent during the structural adjustment (in particular during conversion), programs may behave incorrectly when they access this data.