Step-step Guide how to SAP remote table comparison with ABAP Code

binary 208216 1920 e1460535901166

SAP remote table comparison: This article will help you compare two remote tables. First, it will check if the SAP DDIC strutures of both tables are the same. If it is the case, it will compare the data in these tables.

SAP Remote Table Comparison

It happens in SAP to compare the values of table between Two systems ( DEV/QUAL or QUAL/PROD ) and especially for customizing table.
This comparison makes the troubleshooting easier by removing an potential customizing/Data problem.


This articles will go through how to SAP Remote Table comparison step by step

  • Check MetaData Compliance
  • Populate Fieldlists
  • Build Options/ Filter
  • Remote Retrieve Data
  • Compare two internal Tables
  • sample ABAP Program

Check MetaData Compliance

The standard function DDIF_FIELDINFO_GET retrieves the metadata of a table in input.
This function can be called remotely in order to retrieve the target table we want to campare.

In this sample, this function is called twice:

  1. The first call to Get Fields List of Table (Target)
  2. The second call to Get Fields List of Table (Source)

If there is no compliance in metadata, no need to go further.

Populate Fieldlists

The return of BAPI DDIF_FIELDINFO_GET-DFIES_TAB[] contains list of fields with the whole metadata description.
We need the following information

Field Name Field Type Description
FIELDNAMEFIELDNAMEField Name
OFFSETDOFFSETOffset of a field
LENGTHDDLENGLength (No. of Characters)
TYPEINTTYPEABAP data type (C/D/N/…)
FIELDTEXTAS4TEXTShort Description of Repository Objects

Build Options/ Filter

The Option table is a table of Where clause.
This is used to filter data retrieved from remote table.

As an sample, let’s add filter on KUNNR when retrieving data from a remote KNA1 table

CONCATENATE 'KUNNR = ' lv_str INTO  SEPARATED BY space.

NB:
don’t forget to add quote to value.

 CONCATENATE '''' -kunnr ''''  INTO lv_str.

Remote Retrieve Data

RFC_READ_TABLE is used to read data from a SAP table localy or remote.
As exporting parameter, query_table is the table name.
The main tables parameters are

Table Parameter Description
OPTIONS filter the data ( where clause )
FIELDS List of fields to retrieved from the table
DATA The data retrieved from the table

Compare two internal Tables

SAP Remote Table Comparison: sample ABAP Program

follow the link for the complete ABAP Program to remote compare table.

For more information check the standard program:
UGMD_TABLE_DELTA_TO_TRANSPORT