*&---------------------------------------------------------------------* *& Report ZODT_COPY_ODTC_ODTD_ER_TABLES *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT ZODT_COPY_ODTC_ODTD_ER_TABLES line-size 300. PARAMETERS: p_tabnam TYPE tabname default 'ODTD_ER*', p_prefix type char1 default 'Z', p_prefi2 type char1 default 'X', p_cpdbtb type abap_bool default 'X' as checkbox, p_devcls like TADIR-devclass obligatory default '$TMP', p_korrno LIKE E070-TRKORR default 'Q16K900615', p_korcus LIKE E070-TRKORR default 'Q16K900619', p_cpdata type abap_bool default 'X' as checkbox, p_overwr type abap_bool as checkbox, p_delete type abap_bool as checkbox, p_packsz like sy-dbcnt obligatory default 15000, p_test type abap_bool default 'X' as checkbox. data lt_odtc_er_adm_map type table of odtc_er_adm_map. data ls_odtc_er_adm_map type odtc_er_adm_map. TYPES: BEGIN OF odtc_er_map_tab, mandt like sy-mandt, old_dbtab_name type tabname, new_dbtab_name type tabNAME, data_copied type abap_bool, END OF odtc_er_map_tab. types odtc_er_map_tab_tab TYPE TABLE OF odtc_er_map_tab. DATA ls_odtc_er_map_tab TYPE odtc_er_map_tab. DATA lt_odtc_er_map_tab_tab TYPE odtc_er_map_tab_tab. DATA lt_ins_odtc_er_map_tab_tab TYPE odtc_er_map_tab_tab. DATA lt_upd_odtc_er_map_tab_tab TYPE odtc_er_map_tab_tab. data lt_dbtab_tab type table of dd02l. data ls_dbtab_tab type dd02l. data lv_map_tabname type tabname. AT SELECTION-SCREEN. IF P_Prefix ne 'Z' and p_prefix ne 'Y'. message E899(5A) with 'Please use Prefix Y or Z'. endif. IF P_cpdbtb eq abap_false and p_cpdata eq abap_false. message E899(5A) with 'Please select one of the two Copy parameters'. endif. START-OF-SELECTION. if p_test eq abap_true. write : / 'Test mode / no updates'. endif. IF p_cpdbtb eq abap_true. perform copy_dbtabs using p_tabnam p_prefix p_prefi2 p_devcls p_korrno p_korcus p_test lv_map_tabname lT_odtc_er_map_tab_tab. endif. IF p_cpdata eq abap_true. perform copy_data using p_tabnam p_prefix p_prefi2 lv_map_tabname p_overwr p_delete p_packsz p_test lT_odtc_er_map_tab_tab. endif. FORM COPY_Dbtabs USING value(cd_tabname) type tabname Value(cd_prefix) type char1 Value(cd_prefix2) type char1 value(cd_tadir_devclass) like TADIR-devclass value(cd_TRKORR) LIKE E070-TRKORR value(cd_TRKORR_Cust) LIKE E070-TRKORR Value(cd_test) type abap_bool cd_map_tabname type tabname cd_odtc_er_map_tab_tab type odtc_er_map_tab_tab. DATA ls_odtc_er_map_tab TYPE odtc_er_map_tab. data: lt_dd02l type table of dd02l. data: ls_dd02l type dd02l. data: lt_dd02l_ext type table of dd02l. data: ls_old_dbtab_name type ddobjname. data: ls_new_dbtab_name type ddobjname. data: ls_subrc like sy-subrc. data: ls_map_tab_exists type abap_bool. skip. if cd_tabname is initial. write : / 'Start copying database tables ODTD_ER* and ODTC_ER* including extension tables in table ODTC_ER_MAP', cd_tabname. else. write : / 'Start copying database table', cd_tabname. endif. perform create_odtc_er_map_tab using cd_prefix cd_tadir_devclass cd_TRKORR cd_trkorr_cust cd_test cd_map_tabname ls_map_tab_exists ls_subrc. if ls_subrc ne 0. write: / 'ERROR creation of mapping table ', cd_map_tabname. exit. endif. if cd_tabname is initial. select * from dd02l into table lt_dd02l where ( tabname like 'ODTD_ER%' OR tabname like 'ODTC_ER_%') and TABCLASS eq 'TRANSP'. * Special logic for extension tables here (ER_ROOT_EXT, ER_ROOT_MILEAGE_EXT, ER_ROOT_REC_BENEFICIARY_EXT, ER_ROOT_REC_EXT) select * from odtc_er_adm_map into table lt_odtc_er_adm_map where node_name = 'ER_ROOT_EXT' OR node_name = 'ER_ROOT_MILEAGE_EXT' OR node_name = 'ER_ROOT_REC_BENEFICIARY_EXT' OR node_name = 'ER_ROOT_REC_EXT'. Loop AT lt_odtc_er_adm_map into ls_odtc_er_adm_map. if not ls_odtc_er_adm_map-db_table_name is initial. clear ls_dd02l. ls_dd02l-tabname = ls_odtc_er_adm_map-db_table_name. append ls_dd02l to lt_dd02l. endif. endloop. else. select * from dd02l into table lt_dd02l where tabname eq cd_tabname and TABCLASS eq 'TRANSP'. if sy-subrc ne 0. write : / 'Table', cd_tabname, 'does not exist and cannot be copied'. exit. endif. endif. LOOP AT lt_dd02l into ls_dd02l. ls_old_dbtab_name = ls_dd02l-tabname. if ls_map_tab_exists = abap_true. * check in Mapping table cd_map_tabname whether table has already been copied select single * from (cd_map_tabname) into ls_odtc_er_map_tab where old_dbtab_name = ls_dd02l-tabname. if sy-subrc = 0. if ls_odtc_er_map_tab-new_dbtab_name NE SPACE. * DB table already copied --> Skip write : / 'Table', ls_dd02l-tabname, 'has already been mapped to table', ls_odtc_er_map_tab-new_dbtab_name, 'in table', cd_map_tabname. write : '-> table will be skipped'. * but add it at least to internal mapping table append ls_odtc_er_map_tab to cd_odtc_er_map_tab_tab. continue. endif. endif. endif. perform build_new_tabname using ls_old_dbtab_name cd_prefix cd_prefix2 ls_new_dbtab_name. perform copy_dbtab using ls_old_dbtab_name ls_new_dbtab_name cd_tadir_devclass cd_TRKORR cd_test ls_subrc. if ls_subrc = 0. * Update internal mapping table, also in test mode clear ls_odtc_er_map_tab. ls_odtc_er_map_tab-old_dbtab_name = ls_old_dbtab_name. ls_odtc_er_map_tab-new_dbtab_name = ls_new_dbtab_name. append ls_odtc_er_map_tab to cd_odtc_er_map_tab_tab. if cd_test eq abap_false. * Update mapping table on DB in uodate mode refresh lt_ins_odtc_er_map_tab_tab. append ls_odtc_er_map_tab to lt_ins_odtc_er_map_tab_tab. insert (cd_map_tabname) from table lt_ins_odtc_er_map_tab_tab accepting duplicate keys. commit work. endif. endif. endloop. if not cd_trkorr_cust is initial and not ls_odtc_er_map_tab is initial and cd_test eq space. * Add table content of mapping table to tranport request if provided perform add_table_cont_to_tr_request using cd_trkorr_cust cd_map_tabname cd_odtc_er_map_tab_tab ls_subrc. endif. endform. form build_new_tabname using value(bnt_old_tabname) type ddobjname Value(bnt_prefix) type char1 Value(bnt_prefix2) type char1 bnt_new_tabname type ddobjname. clear bnt_new_tabname. bnt_new_tabname = bnt_old_tabname. if bnt_old_tabname(1) NE bnt_prefix. bnt_new_tabname(1) = bnt_prefix. ELSE. * special logic for extension tables fpor nodes ER_ROOT_EXT, ER_ROOT_MILEAGE_EXT, ER_ROOT_REC_BENEFICIARY_EXT, ER_ROOT_REC_EXT starting already with desired prefix bnt_new_tabname+1(1) = bnt_prefix2. ENDIF. endform. form create_odtc_er_map_tab using value(coermd_prefix) type char1 value(coermd_tadir_devclass) like TADIR-devclass value(coermd_TRKORR) LIKE E070-TRKORR value(coermd_TRKORR_cust) LIKE E070-TRKORR value(coermd_test) type abap_bool coermd_map_tabname type tabname coermd_map_tab_exists type abap_bool coermd_subrc type sy-subrc. data: lt_DD03P_TAB type tABle of DD03P. data: ls_dd03p type dd03p. data: lt_new_DD03P_TAB type tABle of DD03P. data: ls_new_dd03p type dd03p. data: ls_rc like sy-subrc. data: ls_subrc like sy-subrc. data: lv_tr_subrc like sy-subrc. data: ls_dd02v_wa type dd02v. data: ls_new_dd02v_wa type dd02v. data: ls_dd09l_wa type dd09l. data: ls_new_dd09l_wa type dd09l. data: ls_tabname type tabname. data: ls_new_tabname type ddobjname. data: ls_src_tabname type ddobjname. data: lt_dd02l type table of dd02l. data: lv_with_content type char1. clear coermd_subrc. coermd_map_tab_exists = abap_false. * build table name ls_tabname = 'ZODTC_ER_MAP_DBT'. ls_tabname(1) = CoermD_prefix. ls_new_tabname = ls_tabname. coermd_map_tabname = ls_tabname. select * from dd02l into table lt_dd02l where tabname eq ls_tabname and TABCLASS eq 'TRANSP'. ls_subrc = sy-subrc. if ls_subrc = 0. * Message: Table already exists write : / 'Mapping table', ls_tabname, 'already exists and will not be created'. coermd_map_tab_exists = abap_true. exit. endif. if coermd_test eq abap_false. ls_src_tabname = 'ODTC_ER_ADM_MAP'. * take ODTC_ER_ADM_MAP as sample * read database table CALL FUNCTION 'DDIF_TABL_GET' EXPORTING NAME = ls_src_tabname * STATE = 'A' LANGU = 'E' IMPORTING * GOTSTATE = DD02V_WA = ls_dd02v_wa DD09L_WA = ls_dd09l_wa TABLES DD03P_TAB = lt_DD03P_TAB * DD05M_TAB = * DD08V_TAB = * DD12V_TAB = * DD17V_TAB = * DD35V_TAB = * DD36M_TAB = EXCEPTIONS ILLEGAL_INPUT = 1 OTHERS = 2. IF SY-SUBRC <> 0. * Implement suitable error handling here coermd_subrc = sy-subrc. write: / 'ERROR Reading DDIC info for mapping table ODTC_ER_ADM_MAP'. exit. ENDIF. * Change tabname in DD02V_WA / DD09L_WA to new tabname ls_new_dd02v_wa = ls_dd02v_wa. ls_new_dd02v_wa-tabname = ls_tabname. ls_new_dd02v_wa-As4USER = sy-uname. ls_new_dd02v_wa-As4date = sy-datum. ls_new_dd02v_wa-As4time = sy-uzeit. ls_new_dd02v_wa-ddtext = 'CfTE Offboarding: Mapping old <-> new DB table name'. ls_new_dd09l_wa = ls_dd09l_wa. ls_new_dd09l_wa-tabname = ls_tabname. ls_new_dd09l_wa-As4USER = sy-uname. ls_new_dd09l_wa-As4date = sy-datum. ls_new_dd09l_wa-As4time = sy-uzeit. clear lt_new_dd03p_tab. * Now resolve Data elements and structures * clear dtels with ODTD_ER * delete include structures * maintain attributes of include fields and change to normal fields loop at lt_dd03p_tab into ls_dd03p. clear ls_new_dd03p. ls_new_dd03p = ls_dd03p. * Replace tabneme with new tabname ls_new_dd03p-tabname = ls_tabname. case ls_dd03p-fieldname. WHEN 'MANDT'. append ls_new_dd03p to lt_new_dd03p_tab. WHEN 'NODE_NAME'. ls_new_dd03p-fieldname = 'OLD_DBTAB_NAME'. ls_new_dd03p-rollname = 'TABNAME'. ls_new_dd03p-inttype = 'CHAR'. ls_new_dd03p-intlen = 30. ls_new_dd03p-datatype = 'CHAR'. ls_new_dd03p-mask = 'CHAR'. ls_new_dd03p-leng = 30. ls_new_dd03p-ddtext = 'Name of old database table'. append ls_new_dd03p to lt_new_dd03p_tab. WHEN 'TRANS_NAME'. ls_new_dd03p-fieldname = 'NEW_DBTAB_NAME'. ls_new_dd03p-rollname = 'TABNAME'. ls_new_dd03p-inttype = 'CHAR'. ls_new_dd03p-intlen = 30. ls_new_dd03p-datatype = 'CHAR'. ls_new_dd03p-mask = 'CHAR'. ls_new_dd03p-leng = 30. ls_new_dd03p-ddtext = 'Name of new database table'. append ls_new_dd03p to lt_new_dd03p_tab. WHEN 'TABLE_TYPE_NAME'. ls_new_dd03p-fieldname = 'DATA_COPIED'. ls_new_dd03p-inttype = 'CHAR'. ls_new_dd03p-intlen = 1. ls_new_dd03p-datatype = 'CHAR'. ls_new_dd03p-mask = 'CHAR'. ls_new_dd03p-leng = 1. ls_new_dd03p-ddtext = 'Data copied'. append ls_new_dd03p to lt_new_dd03p_tab. when others. continue. endcase. endloop. check NOT lt_new_dd03p_tab is initial. CALL FUNCTION 'DDIF_TABL_PUT' EXPORTING NAME = ls_new_tabname DD02V_WA = ls_new_dd02v_wa DD09L_WA = ls_new_dd09l_wa TABLES DD03P_TAB = lt_new_dd03p_tab * DD05M_TAB = * DD08V_TAB = * DD35V_TAB = * DD36M_TAB = EXCEPTIONS TABL_NOT_FOUND = 1 NAME_INCONSISTENT = 2 TABL_INCONSISTENT = 3 PUT_FAILURE = 4 PUT_REFUSED = 5 OTHERS = 6. IF SY-SUBRC <> 0. * Implement suitable error handling here coermd_subrc = sy-subrc. write: / 'ERROR creation of mapping table', ls_new_tabname. exit. ENDIF. data: ls_TADIR_PGMID LIKE TADIR-PGMID value 'R3TR'. data: ls_TADIR_OBJECT LIKE TADIR-OBJECT value 'TABL'. data: ls_TADIR_OBJ_NAME LIKE TADIR-OBJ_NAME. data: ls_TADIR_SRCSYSTEM LIKE TADIR-SRCSYSTEM. data: ls_new_tadir type tadir. ls_TADIR_OBJ_NAME = ls_new_tabname. ls_TADIR_SRCSYSTEM = sy-sysid. CALL FUNCTION 'TR_TADIR_INTERFACE' EXPORTING * WI_DELETE_TADIR_ENTRY = ' ' * WI_REMOVE_REPAIR_FLAG = ' ' * WI_SET_REPAIR_FLAG = ' ' WI_TEST_MODUS = ' ' WI_TADIR_PGMID = ls_TADIR_PGMID WI_TADIR_OBJECT = ls_TADIR_OBJECT WI_TADIR_OBJ_NAME = ls_TADIR_OBJ_NAME * WI_TRKORR = coermd_TRKORR WI_TADIR_SRCSYSTEM = ls_TADIR_SRCSYSTEM WI_TADIR_AUTHOR = sy-uname WI_TADIR_DEVCLASS = coermd_tadir_devclass WI_TADIR_MASTERLANG = 'E' WI_TADIR_CPROJECT = 'L' * WI_TADIR_VERSID = ' ' * WI_REMOVE_GENFLAG = ' ' * WI_SET_GENFLAG = 'X' * WI_READ_ONLY = ' ' * IV_SET_EDTFLAG = ' ' * IV_TRANSL_TECH_TEXT = ' ' * IV_DELFLAG = ' ' * IV_NO_PAK_CHECK = ' ' * IV_OBJ_STABILITY = ' ' * WI_TADIR_CHECK_DATE = '' * WI_TADIR_CHECK_CFG = ' ' IMPORTING * NEW_GTADIR_ENTRY = NEW_TADIR_ENTRY = ls_new_tadir EXCEPTIONS TADIR_ENTRY_NOT_EXISTING = 1 TADIR_ENTRY_ILL_TYPE = 2 NO_SYSTEMNAME = 3 NO_SYSTEMTYPE = 4 ORIGINAL_SYSTEM_CONFLICT = 5 OBJECT_RESERVED_FOR_DEVCLASS = 6 OBJECT_EXISTS_GLOBAL = 7 OBJECT_EXISTS_LOCAL = 8 OBJ_SPECIFICATION_NOT_UNIQUE = 10 NO_AUTHORIZATION_TO_DELETE = 11 DEVCLASS_NOT_EXISTING = 12 SIMULTANIOUS_SET_REMOVE_REPAIR = 13 ORDER_MISSING = 14 NO_MODIFICATION_OF_HEAD_SYST = 15 PGMID_OBJECT_NOT_ALLOWED = 16 MASTERLANGUAGE_NOT_SPECIFIED = 17 DEVCLASS_NOT_SPECIFIED = 18 SPECIFY_OWNER_UNIQUE = 19 LOC_PRIV_OBJS_NO_REPAIR = 20 GTADIR_NOT_REACHED = 21 OBJECT_LOCKED_FOR_ORDER = 22 CHANGE_OF_CLASS_NOT_ALLOWED = 23 NO_CHANGE_FROM_SAP_TO_TMP = 24 OTHERS = 25. IF SY-SUBRC <> 0. * Implement suitable error handling here coermd_subrc = sy-subrc. write: / 'ERROR creation of TADIR entry for mapping table', ls_new_tabname. exit. ENDIF. CALL FUNCTION 'DDIF_TABL_ACTIVATE' EXPORTING NAME = ls_new_tabname * AUTH_CHK = 'X' * PRID = -1 * EXCOMMIT = 'X' IMPORTING RC = ls_rc EXCEPTIONS NOT_FOUND = 1 PUT_FAILURE = 2 OTHERS = 3. IF SY-SUBRC <> 0. * Implement suitable error handling here coermd_subrc = sy-subrc. write: / 'ERROR activation of mapping table', ls_new_tabname. exit. ENDIF. coermd_subrc = sy-subrc. if coermd_subrc = 0. if not coermd_TRKORR is initial. * Add table to tranport request if provided perform add_table_to_tr_request using coermd_trkorr ls_new_tabname lv_tr_subrc. endif. write : / 'Mapping table', ls_new_tabname, 'created'. coermd_map_tab_exists = abap_true. endif. else. * Test mode write : / 'Mapping table', ls_new_tabname, 'will be created'. endif. endform. form add_table_to_tr_request using value(atttr_tr_korr) like E070-TRKORR value(atttr_tabname) type ddobjname atttr_subrc like sy-subrc. data: lt_WT_KO200 type table of KO200. data: ls_wt_kO200 type kO200. data: lv_obj_name type TROBJ_NAME. constants: lc_object type TROBJTYPE value 'TABL'. constants: lc_pgmid type pgmid value 'R3TR'. constants: lc_object_content type TROBJTYPE value 'TABU'. check atttr_tr_korr ne space. refresh lt_WT_KO200. clear ls_wt_kO200. ls_wt_kO200-TRKORR = atttr_tr_korr. ls_wt_kO200-as4pos = 1. ls_wt_kO200-PGMID = lc_pgmid. ls_wt_kO200-OBJECT = lc_object. ls_wt_kO200-OBJ_NAME = atttr_tabname. append ls_WT_KO200 to lt_WT_KO200. CALL FUNCTION 'TR_OBJECTS_CHECK' EXPORTING * IV_NO_STANDARD_EDITOR = ' ' IV_NO_SHOW_OPTION = 'X' * IV_EXTERNALPS = ' ' * IV_EXTERNALID = ' ' * IV_NO_PS = ' ' * IT_E071K_STR = * IT_OBJ_ENTRIES = * IMPORTING * WE_ORDER = * WE_TASK = * WE_OBJECTS_APPENDABLE = TABLES WT_KO200 = lt_WT_KO200 * WT_E071K = lt_wt_E071K * TT_TADIR = EXCEPTIONS CANCEL_EDIT_OTHER_ERROR = 1 SHOW_ONLY_OTHER_ERROR = 2 OTHERS = 3 . IF SY-SUBRC <> 0. * Implement suitable error handling here Write: / 'Error Adding table definition R3TR TABL', atttr_tabname, 'to transport request', atttr_tr_korr. atttr_subrc = sy-subrc. exit. ENDIF. CALL FUNCTION 'TR_OBJECTS_INSERT' EXPORTING WI_ORDER = atttr_tr_korr * IV_NO_STANDARD_EDITOR = ' ' * IV_NO_SHOW_OPTION = ' ' * IV_EXTERNALPS = ' ' * IV_EXTERNALID = ' ' * IV_NO_PS = ' ' * IT_E071K_STR = * IT_OBJ_ENTRIES = * IMPORTING * WE_ORDER = * WE_TASK = TABLES WT_KO200 = lt_WT_KO200 * WT_E071K = lt_wt_E071K * TT_TADIR = EXCEPTIONS CANCEL_EDIT_OTHER_ERROR = 1 SHOW_ONLY_OTHER_ERROR = 2 OTHERS = 3 . IF SY-SUBRC <> 0. * Implement suitable error handling here Write: / 'Error Adding table definition R3TR TABL', atttr_tabname, 'to transport request', atttr_tr_korr. else. Write: / 'Table definition R3TR TABL', atttr_tabname, 'successfully added to transport request', atttr_tr_korr. ENDIF. atttr_subrc = sy-subrc. endform. form add_table_cont_to_tr_request using value(atcttr_tr_korr) like E070-TRKORR value(atcttr_tabname) type ddobjname value(atcttr_cd_odtc_er_map_tab_tab) type odtc_er_map_tab_tab atcttr_subrc like sy-subrc. data: lt_WT_KO200 type table of KO200. data: ls_wt_kO200 type kO200. data: lt_WT_e071K type table of e071k. data: ls_wt_e071k type e071k. data: lv_obj_name type TROBJ_NAME. constants: lc_pgmid type pgmid value 'R3TR'. constants: lc_object_tabu type TROBJTYPE value 'TABU'. DATA ls_odtc_er_map_tab TYPE odtc_er_map_tab. check atcttr_tr_korr ne space. refresh lt_WT_KO200. refresh lt_wt_e071K. * fill the header clear ls_wt_kO200. ls_wt_kO200-TRKORR = atcttr_tr_korr. * ls_wt_kO200-as4pos = 1. ls_wt_kO200-PGMID = lc_pgmid. ls_wt_kO200-OBJECT = lc_object_tabu. ls_wt_kO200-OBJfunc = 'K'. ls_wt_kO200-OBJ_NAME = atcttr_tabname. append ls_WT_KO200 to lt_WT_KO200. * now add the table keys clear ls_wt_e071K. ls_wt_e071K-TRKORR = atcttr_tr_korr. ls_wt_e071K-PGMID = lc_pgmid. ls_wt_e071K-OBJECT = lc_object_tabu. ls_wt_e071K-OBJNAME = atcttr_tabname. ls_wt_e071k-mastertype = lc_object_tabu. ls_wt_e071k-mastername = atcttr_tabname. ls_wt_e071k-tabkey(3) = sy-mandt. loop at atcttr_cd_odtc_er_map_tab_tab into ls_odtc_er_map_tab. ls_wt_e071k-tabkey+3(30) = ls_odtc_er_map_tab-old_dbtab_name. * add 1 to ls_wt_e071K-as4pos. append ls_WT_e071K to lt_WT_e071K. endloop. CALL FUNCTION 'TR_OBJECTS_CHECK' EXPORTING * IV_NO_STANDARD_EDITOR = ' ' IV_NO_SHOW_OPTION = 'X' * IV_EXTERNALPS = ' ' * IV_EXTERNALID = ' ' * IV_NO_PS = ' ' * IT_E071K_STR = * IT_OBJ_ENTRIES = * IMPORTING * WE_ORDER = * WE_TASK = * WE_OBJECTS_APPENDABLE = TABLES WT_KO200 = lt_WT_KO200 WT_E071K = lt_wt_E071K * TT_TADIR = EXCEPTIONS CANCEL_EDIT_OTHER_ERROR = 1 SHOW_ONLY_OTHER_ERROR = 2 OTHERS = 3 . IF SY-SUBRC <> 0. * Implement suitable error handling here Write: / 'Error Adding table content R3TR TABU', atcttr_tabname, 'to transport request', atcttr_tr_korr. atcttr_subrc = sy-subrc. exit. ENDIF. CALL FUNCTION 'TR_OBJECTS_INSERT' EXPORTING WI_ORDER = atcttr_tr_korr * IV_NO_STANDARD_EDITOR = ' ' * IV_NO_SHOW_OPTION = ' ' * IV_EXTERNALPS = ' ' * IV_EXTERNALID = ' ' * IV_NO_PS = ' ' * IT_E071K_STR = * IT_OBJ_ENTRIES = * IMPORTING * WE_ORDER = * WE_TASK = TABLES WT_KO200 = lt_WT_KO200 WT_E071K = lt_wt_E071K * TT_TADIR = EXCEPTIONS CANCEL_EDIT_OTHER_ERROR = 1 SHOW_ONLY_OTHER_ERROR = 2 OTHERS = 3 . IF SY-SUBRC <> 0. * Implement suitable error handling here Write: / 'Error Adding table content R3TR TABU', atcttr_tabname, 'to transport request', atcttr_tr_korr. else. Write: / 'Table content R3TR TABU', atcttr_tabname, 'successfully added to transport request', atcttr_tr_korr. ENDIF. atcttr_subrc = sy-subrc. endform. form copy_dbtab using value(cd_old_tabname) type ddobjname value(cd_new_tabname) type ddobjname value(cd_tadir_devclass) like TADIR-devclass value(cd_TRKORR) LIKE E070-TRKORR value(cd_test) type abap_bool cd_subrc type sy-subrc. data: lt_DD03P_TAB type tABle of DD03P. data: ls_dd03p type dd03p. data: lt_new_DD03P_TAB type tABle of DD03P. data: ls_new_dd03p type dd03p. data: ls_rc like sy-subrc. data: lt_dd02v_tab type table of dd02v. data: ls_dd02v_wa type dd02v. data: lt_new_dd02v_tab type table of dd02v. data: ls_new_dd02v_wa type dd02v. data: ls_dd09l_wa type dd09l. data: ls_new_dd09l_wa type dd09l. data: lt_dd02l type table of dd02l. data: lt_dd12v_tab type table of dd12v. data: ls_dd12v_wa type dd12v. data: lt_new_dd12v_tab type table of dd12v. data: ls_new_dd12v_wa type dd12v. data: lt_dd17v_tab type table of dd17v. data: ls_dd17v_wa type dd17v. data: lt_new_dd17v_tab type table of dd17v. data: ls_new_dd17v_wa type dd17v. data: lv_tr_subrc like sy-subrc. clear cd_subrc. * Check first whether new tablename already exists select * from dd02l into table lt_dd02l where tabname eq cd_new_tabname and TABCLASS eq 'TRANSP'. if sy-subrc = 0. * Message: Table already exists write : / 'Table', cd_new_tabname, 'already exists and will not be created'. exit. endif. if cd_test eq abap_false. * read database table CALL FUNCTION 'DDIF_TABL_GET' EXPORTING NAME = cd_old_tabname * STATE = 'A' LANGU = 'E' IMPORTING * GOTSTATE = DD02V_WA = ls_dd02v_wa DD09L_WA = ls_dd09l_wa TABLES DD03P_TAB = lt_DD03P_TAB * DD05M_TAB = * DD08V_TAB = DD12V_TAB = lt_dd12v_tab DD17V_TAB = lt_dd17v_tab * DD35V_TAB = * DD36M_TAB = EXCEPTIONS ILLEGAL_INPUT = 1 OTHERS = 2. IF SY-SUBRC <> 0. * Implement suitable error handling here cd_subrc = sy-subrc. write: / 'ERROR Read DDIC info for table', cd_old_tabname. exit. ENDIF. * Change tabname in DD02V_WA / DD09L_WA to new tabname ls_new_dd02v_wa = ls_dd02v_wa. ls_new_dd02v_wa-tabname = cd_new_tabname. ls_new_dd02v_wa-As4USER = sy-uname. ls_new_dd02v_wa-As4date = sy-datum. ls_new_dd02v_wa-As4time = sy-uzeit. ls_new_dd09l_wa = ls_dd09l_wa. ls_new_dd09l_wa-tabname = cd_new_tabname. ls_new_dd09l_wa-As4USER = sy-uname. ls_new_dd09l_wa-As4date = sy-datum. ls_new_dd09l_wa-As4time = sy-uzeit. clear lt_new_dd03p_tab. * Now resolve Data elements and structures * clear dtels with ODTD_ER * delete include structures * maintain attributes of include fields and change to normal fields loop at lt_dd03p_tab into ls_dd03p. * Check whether there is a Include Structure (FIELDNAME = '.INCLUDE', PRECFIELD IS NOT INITIAL) -> CONTINUE IF ls_dd03p-fieldname = '.INCLUDE' and ls_dd03p-PRECFIELD IS NOT INITIAL. continue. endif. clear ls_new_dd03p. ls_new_dd03p = ls_dd03p. * Replace tabneme with new tabname ls_new_dd03p-tabname = cd_new_tabname. * Check whether it's a field of an Include Structure (ADMINFIELD NE '0') -> set ADMINFIELD to '0' if ls_new_dd03p-ADMINFIELD NE '0'. ls_new_dd03p-ADMINFIELD = '0'. endif. * Check whether there is a DTEL (ROLLNAME IS NOT INITIAL and with name ODT_ER*)-> clear it and read DTEL-text and fill it into description field DDTEXT if not ls_new_dd03p-rollname is initial and ls_new_dd03p-rollname CP 'ODT_ER*'. perform read_dtel_text using ls_new_dd03p-rollname ls_new_dd03p-ddtext. clear ls_new_dd03p-rollname. endif. append ls_new_dd03p to lt_new_dd03p_tab. endloop. check NOT lt_new_dd03p_tab is initial. CALL FUNCTION 'DDIF_TABL_PUT' EXPORTING NAME = cd_new_tabname DD02V_WA = ls_new_dd02v_wa DD09L_WA = ls_new_dd09l_wa TABLES DD03P_TAB = lt_new_dd03p_tab * DD05M_TAB = * DD08V_TAB = * DD35V_TAB = * DD36M_TAB = EXCEPTIONS TABL_NOT_FOUND = 1 NAME_INCONSISTENT = 2 TABL_INCONSISTENT = 3 PUT_FAILURE = 4 PUT_REFUSED = 5 OTHERS = 6. IF SY-SUBRC <> 0. * Implement suitable error handling here cd_subrc = sy-subrc. write : / 'ERROR creation of table', cd_new_tabname. exit. ENDIF. data: ls_TADIR_PGMID LIKE TADIR-PGMID value 'R3TR'. data: ls_TADIR_OBJECT LIKE TADIR-OBJECT value 'TABL'. data: ls_TADIR_OBJ_NAME LIKE TADIR-OBJ_NAME. data: ls_TADIR_SRCSYSTEM LIKE TADIR-SRCSYSTEM. data: ls_new_tadir type tadir. ls_TADIR_OBJ_NAME = cd_new_tabname. ls_TADIR_SRCSYSTEM = sy-sysid. CALL FUNCTION 'TR_TADIR_INTERFACE' EXPORTING * WI_DELETE_TADIR_ENTRY = ' ' * WI_REMOVE_REPAIR_FLAG = ' ' * WI_SET_REPAIR_FLAG = ' ' WI_TEST_MODUS = ' ' WI_TADIR_PGMID = ls_TADIR_PGMID WI_TADIR_OBJECT = ls_TADIR_OBJECT WI_TADIR_OBJ_NAME = ls_TADIR_OBJ_NAME * WI_TRKORR = cd_TRKORR WI_TADIR_SRCSYSTEM = ls_TADIR_SRCSYSTEM WI_TADIR_AUTHOR = sy-uname WI_TADIR_DEVCLASS = cd_tadir_devclass WI_TADIR_MASTERLANG = 'E' WI_TADIR_CPROJECT = 'L' * WI_TADIR_VERSID = ' ' * WI_REMOVE_GENFLAG = ' ' * WI_SET_GENFLAG = 'X' * WI_READ_ONLY = ' ' * IV_SET_EDTFLAG = ' ' * IV_TRANSL_TECH_TEXT = ' ' * IV_DELFLAG = ' ' * IV_NO_PAK_CHECK = ' ' * IV_OBJ_STABILITY = ' ' * WI_TADIR_CHECK_DATE = '' * WI_TADIR_CHECK_CFG = ' ' IMPORTING * NEW_GTADIR_ENTRY = NEW_TADIR_ENTRY = ls_new_tadir EXCEPTIONS TADIR_ENTRY_NOT_EXISTING = 1 TADIR_ENTRY_ILL_TYPE = 2 NO_SYSTEMNAME = 3 NO_SYSTEMTYPE = 4 ORIGINAL_SYSTEM_CONFLICT = 5 OBJECT_RESERVED_FOR_DEVCLASS = 6 OBJECT_EXISTS_GLOBAL = 7 OBJECT_EXISTS_LOCAL = 8 OBJ_SPECIFICATION_NOT_UNIQUE = 10 NO_AUTHORIZATION_TO_DELETE = 11 DEVCLASS_NOT_EXISTING = 12 SIMULTANIOUS_SET_REMOVE_REPAIR = 13 ORDER_MISSING = 14 NO_MODIFICATION_OF_HEAD_SYST = 15 PGMID_OBJECT_NOT_ALLOWED = 16 MASTERLANGUAGE_NOT_SPECIFIED = 17 DEVCLASS_NOT_SPECIFIED = 18 SPECIFY_OWNER_UNIQUE = 19 LOC_PRIV_OBJS_NO_REPAIR = 20 GTADIR_NOT_REACHED = 21 OBJECT_LOCKED_FOR_ORDER = 22 CHANGE_OF_CLASS_NOT_ALLOWED = 23 NO_CHANGE_FROM_SAP_TO_TMP = 24 OTHERS = 25. IF SY-SUBRC <> 0. * Implement suitable error handling here cd_subrc = sy-subrc. write : / 'ERROR creation of TADIR entry for table', cd_new_tabname. exit. ENDIF. CALL FUNCTION 'DDIF_TABL_ACTIVATE' EXPORTING NAME = cd_new_tabname * AUTH_CHK = 'X' * PRID = -1 * EXCOMMIT = 'X' IMPORTING RC = ls_rc EXCEPTIONS NOT_FOUND = 1 PUT_FAILURE = 2 OTHERS = 3. IF SY-SUBRC <> 0. * Implement suitable error handling here cd_subrc = sy-subrc. write : / 'ERROR activation of table', cd_new_tabname. exit. ENDIF. cd_subrc = sy-subrc. * Now copy and activate the indices clear ls_new_dd12v_wa. loop at lt_dd12v_tab into ls_dd12v_wa. ls_new_dd12v_wa = ls_dd12v_wa. ls_new_dd12v_wa-sqltab = cd_new_tabname. ls_new_dd12v_wa-As4USER = sy-uname. ls_new_dd12v_wa-As4date = sy-datum. ls_new_dd12v_wa-As4time = sy-uzeit. replace cd_old_tabname in ls_new_dd12v_wa-dbindex with cd_new_tabname. refresh lt_new_dd17v_tab. loop at lt_dd17v_tab into ls_dd17v_wa where indexname = ls_new_dd12v_wa-indexname. ls_new_dd17v_wa = ls_dd17v_wa. ls_new_dd17v_wa-sqltab = cd_new_tabname. append ls_new_dd17v_wa to lt_new_dd17v_tab. endloop. CALL FUNCTION 'DDIF_INDX_PUT' EXPORTING NAME = cd_new_tabname ID = ls_new_dd12v_wa-indexname DD12V_WA = ls_new_dd12v_wa TABLES DD17V_TAB = lt_new_dd17v_tab EXCEPTIONS INDX_NOT_FOUND = 1 NAME_INCONSISTENT = 2 INDX_INCONSISTENT = 3 PUT_FAILURE = 4 PUT_REFUSED = 5. IF SY-SUBRC <> 0. * Implement suitable error handling here cd_subrc = sy-subrc. write : / 'ERROR creation of index', ls_new_dd12v_wa-indexname, 'for table', cd_new_tabname. exit. ENDIF. CALL FUNCTION 'DDIF_INDX_ACTIVATE' EXPORTING NAME = cd_new_tabname ID = ls_new_dd12v_wa-indexname * AUTH_CHK = 'X' * PRID = -1 IMPORTING RC = ls_rc EXCEPTIONS NOT_FOUND = 1 PUT_FAILURE = 2 OTHERS = 3. IF SY-SUBRC <> 0. * Implement suitable error handling here cd_subrc = sy-subrc. write : / 'ERROR activation of index', ls_new_dd12v_wa-indexname, 'for table', cd_new_tabname. exit. ENDIF. cd_subrc = sy-subrc. endloop. if cd_subrc = 0. if not cd_TRKORR is initial. perform add_table_to_tr_request using cd_trkorr cd_new_tabname lv_tr_subrc. endif. write : / 'Table', cd_old_tabname, 'copied to table', cd_new_tabname. endif. else. " test Mode write : / 'Table', cd_old_tabname, 'will be copied to table', cd_new_tabname. endif. endform. FORM COPY_Data USING value(cd_tabname) type tabname Value(cd_prefix) type char1 Value(cd_prefix2) type char1 value(cd_map_tabname) type tabname value(cd_overwr) type abap_bool value(cd_delete) type abap_bool value(cd_packsz) like sy-dbcnt value(cd_test) type abap_bool cd_odtc_er_map_tab_tab type odtc_er_map_tab_tab. data: ls_new_tabname type ddobjname. data: ls_map_tabname type ddobjname. data: ls_rc like sy-subrc. data: lt_odtc_er_map_tab_tab type odtc_er_map_tab_tab. data: db_odtc_er_map_tab_tab type odtc_er_map_tab_tab. data: lt_copy_odtc_er_map_tab_tab type odtc_er_map_tab_tab. data: lt_copy_odtc_er_map_tab_cnt like sy-dbcnt. data: lt_dd02l type table of dd02l. data: ls_dd02l type dd02l. data: ls_map_tab_exists type abap_bool. data: ls_subrc like sy-subrc. skip. if cd_tabname is initial. write : / 'Start copying data of all mapped and copied database tables ODTD_ER* and ODTC_ER* including extension tables in table ODTC_ER_MAP'. else. write : / 'Start copying data of database table', cd_tabname. endif. IF cd_overwr eq abap_true. write : ' with overwrite data'. endif. IF cd_delete eq abap_true. write : / 'Already existing data in new database table(s) will be deleted first.'. endif. * check whether name of mapping table is filled if cd_map_tabname is initial. * build table name ls_map_tabname = 'ZODTC_ER_MAP_DBT'. ls_map_tabname(1) = Cd_prefix. else. ls_map_tabname = cd_map_tabname. endif. * Check whether mapping table exists select * from dd02l into table lt_dd02l where tabname eq ls_map_tabname and TABCLASS eq 'TRANSP'. ls_subrc = sy-subrc. if ls_subrc = 0. ls_map_tab_exists = abap_true. else. ls_map_tab_exists = abap_false. if cd_test eq abap_false. * Existance of mapping atbel is mandatory in update mode * Error: Message: mapping table does not yet exist write : / 'ERROR: mapping table', ls_map_tabname, 'does not exist -> Start with Copy Database Tables first'. exit. endif. endif. refresh lt_odtc_er_map_tab_tab. if ls_map_tab_exists = abap_true. * Select entries from mapping table select * from (ls_map_tabname) into table db_odtc_er_map_tab_tab. if cd_test eq abap_false. * in prod mode take always the entries from DB mapping table lt_odtc_er_map_tab_tab = db_odtc_er_map_tab_tab. else. * in test mode take the mapping table filled and handed over by COPY_DBTABS (i.e parameter COPY_DBTABS was set and executed first in test mode) * -> criteria for this is that both cd_map_tabname and cd_odtc_er_map_tab_tab are filled if cd_map_tabname ne space and not cd_odtc_er_map_tab_tab is initial. lt_odtc_er_map_tab_tab = cd_odtc_er_map_tab_tab. else. * in all other cases (i.e parameter COPY_DBTABS was not set and not executed first in test mode) take the DB table lt_odtc_er_map_tab_tab = db_odtc_er_map_tab_tab. endif. endif. else. "No mapping table on DB IF cd_test eq abap_true. * in test mode take the mapping table filled and handed over by COPY_DBTABS lt_odtc_er_map_tab_tab = cd_odtc_er_map_tab_tab. endif. endif. if not cd_tabname is initial. select * from dd02l into table lt_dd02l where tabname eq cd_tabname and TABCLASS eq 'TRANSP'. if sy-subrc ne 0. write : / 'Table', cd_tabname, 'does not exist -> Data cannot be copied'. exit. endif. * if table name is specfied the process only entries for this table refresh lt_copy_odtc_er_map_tab_tab. loop at lt_odtc_er_map_tab_tab into ls_odtc_er_map_tab where old_dbtab_name = cd_tabname. append ls_odtc_er_map_tab to lt_copy_odtc_er_map_tab_tab. endloop. else. lt_copy_odtc_er_map_tab_tab = lt_odtc_er_map_tab_tab. endif. describe table lt_copy_odtc_er_map_tab_tab lines lt_copy_odtc_er_map_tab_cnt. if lt_copy_odtc_er_map_tab_cnt = 0. * Required entries in mapping tab don't exist * no message for test eq abap_true and cd_odtc_er_map_tab_tab not is initial * if cd_test eq abap_false or cd_odtc_er_map_tab_tab is initial. write : / 'ERROR: Required mappings in mapping table', ls_map_tabname, 'do not exist -> Start with Parameter: Copy Database Tables first'. exit. * endif. endif. loop at lt_copy_odtc_er_map_tab_tab into ls_odtc_er_map_tab. if ls_odtc_er_map_tab-new_dbtab_name is initial. * Error: Write DB table not yet copied write : / 'ERROR: Table', ls_odtc_er_map_tab-old_dbtab_name, 'has not been copied yet -> Start with Parameter: Copy Database Tables first'. continue. endif. if ls_odtc_er_map_tab-data_copied ne space and cd_overwr eq space. write : / 'Data of table', ls_odtc_er_map_tab-old_dbtab_name, 'has already been copied to table', ls_odtc_er_map_tab-new_dbtab_name. write : '-> Start again with Parameter: Overwrite Data if you want to overwrite the copied data'. * Info: Data for this DB table already copied and overwrite flag not set continue. endif. * Now copy the data perform copy_data_dbtab using ls_odtc_er_map_tab-old_dbtab_name ls_odtc_er_map_tab-new_dbtab_name cd_delete cd_packsz cd_test ls_rc. if ls_rc = 0 and cd_test eq abap_false. * Update mapping table ls_odtc_er_map_tab-data_copied = abap_true. modify lt_copy_odtc_er_map_tab_tab from ls_odtc_er_map_tab. refresh lt_upd_odtc_er_map_tab_tab. append ls_odtc_er_map_tab to lt_upd_odtc_er_map_tab_tab. update (ls_map_tabname) from table lt_upd_odtc_er_map_tab_tab. commit work. endif. endloop. cd_odtc_er_map_tab_tab = lt_copy_odtc_er_map_tab_tab. endform. form copy_data_dbtab using value(cdd_old_tabname) type ddobjname value(cdd_new_tabname) type ddobjname value(cdd_delete) type abap_bool value(cdd_packsz) like sy-dbcnt value(cdd_test) type abap_bool cdd_subrc type sy-subrc. DATA: dbnnnn_tab TYPE REF TO data. data: lt_dd02l type table of dd02l. data: ls_dd02l type dd02l. data: ls_old_tabname_cnt like sy-dbcnt. data: ls_new_tabname_cnt like sy-dbcnt. data: ls_new_tabname_cnt_after_del like sy-dbcnt. data: ls_diff_cnt like sy-dbcnt. data: lv_ins_subrc like sy-subrc. data: lv_del_subrc like sy-subrc. datA: lv_text type text100. data: lv_percent type perct. data: lv_percent_numc type numc3. data: lV_package_ctr like sy-dbcnt. data: lV_ratio type perct. FIELD-SYMBOLS: TYPE STANDARD TABLE. * Check whether old and new dbtab exists select * from dd02l into table lt_dd02l where tabname eq cdd_old_tabname and TABCLASS eq 'TRANSP'. if sy-subrc ne 0. * Error: Message: old database table does not exist write : / 'ERROR: Source table', cdd_old_tabname, 'does not exist. Data cannot be copied'. cdd_subrc = 4. exit. endif. select * from dd02l into table lt_dd02l where tabname eq cdd_new_tabname and TABCLASS eq 'TRANSP'. if sy-subrc ne 0 and cdd_test eq abap_false. * Error: Message: new database table does not exist write : / 'ERROR: New target table', cdd_new_tabname, 'does not exist. Data cannot be copied from source table', cdd_old_tabname. cdd_subrc = 4. if cdd_test eq abap_false. exit. endif. endif. CREATE DATA dbnnnn_tab TYPE STANDARD TABLE OF (cdd_old_tabname). ASSIGN dbnnnn_tab->* TO . REFRESH . select count(*) from (cdd_new_tabname) into ls_new_tabname_cnt. if ls_new_tabname_cnt > 0. write : / 'New target table', cdd_new_tabname, 'has already', ls_new_tabname_cnt , 'records before copying'. endif. if cdd_delete eq abap_true. * Delete entries in new_dbtab first if ls_new_tabname_cnt = 0. write : / 'No data to be deleted from', cdd_new_tabname. else. if cdd_test eq abap_true. write : / ls_new_tabname_cnt, 'records will be deleted from', cdd_new_tabname, 'first'. else. clear lv_package_ctr. select * from (cdd_new_tabname) INTO table package size cdd_packsz. lv_package_ctr = sy-dbcnt. delete (cdd_new_tabname) FROM TABLE . lv_del_subrc = sy-subrc. refresh . lv_ratio = lV_package_ctr / ls_new_tabname_cnt. lv_percent = ( lV_package_ctr / ls_new_tabname_cnt ) * 100. lv_percent_numc = lv_percent. write lv_percent_numc to lv_text(3). write: '% of data deleted from ' to lv_text+3(22). write: cdd_old_tabname to lv_text+25(16). CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR' EXPORTING PERCENTAGE = lv_percent TEXT = lv_text. endselect. IF LV_DEL_SUBRC = 0. write : / ls_new_tabname_cnt, 'records deleted from', cdd_new_tabname. else. select count(*) from (cdd_new_tabname) into ls_new_tabname_cnt_after_del. if ls_new_tabname_cnt_after_del = 0. * Message cnt entries deleted from new_dbtab write : / 'No records deleted from', cdd_new_tabname. write : '-> Content of', cdd_new_tabname, 'was already empty'. cdd_subrc = 0. else. cdd_subrc = 4. * Message Error Delete data write : / 'ERROR deleting data from', cdd_new_tabname. exit. endif. endif. endif. endif. endif. select count(*) from (cdd_old_tabname) into ls_old_tabname_cnt. if ls_old_tabname_cnt = 0. * No entries to be copied write : / 'No data to be copied from', cdd_old_tabname, 'to', cdd_new_tabname. cdd_subrc = 0. exit. endif. if cdd_test eq abap_true. * ls_old_tabname_cnt records to be copied from old_dbtab to new_dbtab write : / ls_old_tabname_cnt, 'records will be copied from', cdd_old_tabname, 'to', cdd_new_tabname. else. clear lv_package_ctr. select * from (cdd_old_tabname) INTO table package size cdd_packsz. lv_package_ctr = sy-dbcnt. INSERT (cdd_new_tabname) FROM TABLE ACCEPTING DUPLICATE KEYS. lv_ins_subrc = sy-subrc. refresh . lv_ratio = lV_package_ctr / ls_old_tabname_cnt. lv_percent = ( lV_package_ctr / ls_old_tabname_cnt ) * 100. lv_percent_numc = lv_percent. write lv_percent_numc to lv_text(3). write: '% of data copied for ' to lv_text+3(21). write: cdd_old_tabname to lv_text+24(16). CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR' EXPORTING PERCENTAGE = lv_percent TEXT = lv_text. endselect. * Completeness check select count(*) from (cdd_new_tabname) into ls_new_tabname_cnt. if lv_ins_subrc = 0. cdd_subrc = 0. * Message cnt entries copied from old_dbtab to new dbtab write : / sy-dbcnt, 'records copied from', cdd_old_tabname, 'to', cdd_new_tabname. if ls_old_tabname_cnt EQ ls_new_tabname_cnt. * Message cnt entries copied from old_dbtab to new dbtab write : '-> Data of', cdd_new_tabname, 'is now complete with', ls_new_tabname_cnt, 'records'. else. if ls_old_tabname_cnt < ls_new_tabname_cnt. "new dbtab has more records than the old one ls_diff_cnt = ls_new_tabname_cnt - ls_old_tabname_cnt. write : '->', cdd_new_tabname, 'has', ls_new_tabname_cnt, 'records now, ', ls_diff_cnt, 'records more than', cdd_old_tabname. else. "ls_old_tabname_cnt < ls_new_tabname_cnt, records are missing ls_diff_cnt = ls_old_tabname_cnt - ls_new_tabname_cnt. write : '-> Data of', cdd_new_tabname, 'is not yet complete. There are only', ls_new_tabname_cnt, 'records, ', ls_diff_cnt, 'records are still mssing'. endif. endif. else. * Completeness check select count(*) from (cdd_new_tabname) into ls_new_tabname_cnt. if ls_old_tabname_cnt EQ ls_new_tabname_cnt. * Message cnt entries copied from old_dbtab to new dbtab write : / 'No records copied from', cdd_old_tabname, 'to', cdd_new_tabname. write : '-> Data of', cdd_new_tabname, 'was already complete with', ls_new_tabname_cnt, 'records'. cdd_subrc = 0. else. if ls_old_tabname_cnt < ls_new_tabname_cnt. ls_diff_cnt = ls_new_tabname_cnt - ls_old_tabname_cnt. write : / '->', cdd_new_tabname, 'has', ls_new_tabname_cnt, 'records now, ', ls_diff_cnt, 'records more than', cdd_old_tabname. else. "ls_old_tabname_cnt > ls_new_tabname_cnt. * not all records copied from old to new db tab cdd_subrc = 4. * Message Error Copy data write : / 'ERROR Copying data from', cdd_old_tabname, 'to', cdd_new_tabname. ls_diff_cnt = ls_old_tabname_cnt - ls_new_tabname_cnt. write : '-> Data of', cdd_new_tabname, 'is not yet complete. There are only', ls_new_tabname_cnt, 'records, ', ls_diff_cnt, 'records are still mssing'. endif. endif. endif. endif. endform. FORM READ_DTEL_TEXT USING Value(rdt_dtel_name) type rollname rdt_dtel_text type as4text. data lt_dd04l type table of dd04l. data ls_dd04l type dd04l. data ls_dd04v_wa type dd04v. data ls_dtel_name type ddobjname. ls_dtel_name = rdt_dtel_name. * read data element CALL FUNCTION 'DDIF_DTEL_GET' EXPORTING NAME = ls_dtel_name * STATE = 'A' LANGU = 'E' IMPORTING * GOTSTATE = DD04V_WA = ls_dd04v_wa * TPARA_WA = EXCEPTIONS ILLEGAL_INPUT = 1 OTHERS = 2. IF SY-SUBRC <> 0. * Implement suitable error handling here write : / 'ERROR reading Data element text for Data Element', ls_dtel_name. ELSE. rdt_dtel_text = ls_dd04v_wa-ddtext. ENDIF. endform.