To determine which records in an internal table have to be inserted, updated or deleted you can use the following function module. The tables need to be sorted by the database key before calling the function module.
CALL FUNCTION 'ISU_TABLE_UC_PREP_FOR_UPDATE'
EXPORTING
x_tabname = 'NAME_OF_DDIC_TABLE'
* X_MANDT = 'X'
TABLES
xt_new = it_updated_table
xt_old = it_database_table
yt_insert = it_needs_inserting
yt_update = it_needs_updating
yt_delete = it_needs_deleteing
EXCEPTIONS
key_too_long = 1
key_too_small = 1
OTHERS = 1.
IF sy-subrc <> 0.
* MESSAGE ID sy-msgid TYPE 'X' NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
* RAISING update_error.
ENDIF.