SAP Remote Table Comparison: The following ABAP Program will remote compare table.
SAP Remote Table Comparison ABAP Code
Here the full ABAP Source to enable compare remotely the Some SAP Table.
First step is to Compare the Table Structure between two distant SAP Systems.
The Second Step is to compare local SAP Table Data and the Remote SAP Table.
For all the detail about this?Step-step Guide how to SAP remote table comparison with ABAP Code
DATA: lv_str TYPE string. DATA: lt_dfies_t TYPE STANDARD TABLE OF dfies. DATA: lt_dfies_s TYPE STANDARD TABLE OF dfies. DATA: l_i TYPE i. DATA: ls_field TYPE rfc_db_fld, lt_field TYPE TABLE OF rfc_db_fld. DATA: lt_option TYPE TABLE OF RFC_DB_OPT. DATA: lt_keyfield TYPE ugmd_t_fieldname, l_keylen TYPE i. DATA: lt_data TYPE STANDARD TABLE OF tab512. FIELD-SYMBOLS: TYPE ANY, TYPE ANY TABLE, TYPE ANY TABLE, TYPE ANY TABLE, TYPE ANY TABLE, TYPE ANY, TYPE dfies, like LINE OF lt_option. " Get Fields List of Table ( Target ) CALL FUNCTION 'DDIF_FIELDINFO_GET' DESTINATION p_target EXPORTING tabname = p_table TABLES dfies_tab = lt_dfies_t EXCEPTIONS not_found = 1 internal_error = 2 OTHERS = 3. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. RETURN. ENDIF. " Get Fields List of Table ( Source ) CALL FUNCTION 'DDIF_FIELDINFO_GET' EXPORTING tabname = p_table TABLES dfies_tab = lt_dfies_s EXCEPTIONS not_found = 1 internal_error = 2 OTHERS = 3. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. RETURN. ENDIF. " Check if Tables Metadata is the same between Target & Source IF lt_dfies_t[] NE lt_dfies_s[]. CALL FUNCTION 'POPUP_TO_INFORM' EXPORTING titel = 'Processing terminated'(001) txt1 = 'The metadata of the tables does not agree'(002) txt2 = space. EXIT. ENDIF. " Build List of Fields to be retrieved LOOP AT lt_dfies_s ASSIGNING. IF -keyflag NE space. INSERT -fieldname INTO TABLE lt_keyfield. ADD -leng TO l_keylen. ENDIF. l_i = -offset + -leng. IF l_i GT 512. EXIT. ENDIF. ls_field-fieldname = -fieldname. ls_field-offset = -offset. ls_field-length = -leng. * ls_field-TYPE = -DATATYPE. ls_field-type = -inttype. ls_field-fieldtext = -fieldtext. INSERT ls_field INTO TABLE lt_field. ENDLOOP. " Optionnal ! " Build WHERE Clause CLEAR: lv_str . CONCATENATE '''' -kunnr '''' INTO lv_str. APPEND INITIAL LINE TO lt_option ASSIGNING . " Example which table KNA1 : we filter on KUNNR CONCATENATE 'KUNNR = ' lv_str INTO SEPARATED BY space. " Read Data from Remote Table CALL FUNCTION 'RFC_READ_TABLE' DESTINATION p_target EXPORTING query_table = p_table no_data = ' ' rowskips = 0 rowcount = 0 TABLES OPTIONS = lt_option fields = lt_field data = lt_data EXCEPTIONS table_not_available = 1 table_without_data = 2 option_not_valid = 3 field_not_valid = 4 not_authorized = 5 data_buffer_exceeded = 6 OTHERS = 7. IF sy-subrc NE 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. EXIT. ENDIF.