Skip to Content
author's profile photo Former Member
Former Member

How to find difference in entries between two DB tables

Hi Experts,

I want to find out the difference in entries between 2 tables....MARA in ECC and COMM_PRODUCT in SRM.

I want to find out the materials in MARA which do not match with COMM_PRODUCT. The field for comparison is MATNR in MARA and PRODUCT in COMM_PRODUCT.

Could you kindly help me out with this.

Thx.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • Posted on May 26, 2012 at 09:43 AM

    Do you want to do this programatically or is it a one time activity.

    If one time activity, i would suggest to download the data from two table from differnent systems in Excel and applyVLOOKUP to check the data... I believe, in both the systems MATNR & Product should have same value without any transformation..

    If you have a huge data, you can write a simple RFC to fetch the data from another system based on some filteration criteria (as data is huge, try fetching data in batches) and then compare the data in the any one of the system..

    hope this helps you in deciding the approach

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 25, 2012 at 06:17 AM

    Hi Eshwar,

    Try the Tcode SQVI in this you can check the relation ship between the tables and fields.

    Thanks&Regards,

    Venkatesh

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 28, 2012 at 03:12 PM

    Hi Eshwar,

    You need to crete a Zprogram for that in ECC system. In this follow the below steps:

    1. Call RFC RFC_READ_TABLE to get data from SRM system for COMM_PRODUCT in internal table gt_tab1. Perform the operation on gt_tab1 to get all data in columnwise manner as RFC fetched entire record row-wise without considering Column .Use SPLIT cmd for it inside LOOP-ENDLOOP.


    2.Write a select querry in ECC system fetching all the MARA table records inside gt_itab2

    3.inside LOOP-ENDLOOP on COMM_PRODUCT ,use read stmt to fetch data based on primary key from MARA and compare records in Field wise manner.

    4.If needed, collect all records with Mismatch in columns and store them in gt_itab3 and use GUI_DOWNLOAD to get Inconsistency file.

    NOTE: If records are too large, you can run report in Backgroung job

    Best Regards,

    Sachin

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 29, 2012 at 11:17 AM

    Manual process...

    Download data from COMM_PRODUCT and collect all Material numbers. Go to ECC table MARA from SE16 or SE11 and in the selection screen use EXCLUDE values option and paste copied entries there.

    Thanks,

    Naveen.I

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 05, 2012 at 12:01 PM

    Hi Eshwar,

    Fetch all the records from COMM_PRODUCT table into internal table itab_COMM_PRODUCT_ALL via the RFC call. Then select the entris from MARA into internal table itab_MARA for all entries in itab_COMM_PRODUCT_ALL where MATNR not equal to itab_COMM_PRODUCT_ALL-PRODUCT. itab_MARA will have the entries apart from COMM_PRODUCT table.

    Now fetch all the records from MARA into internal table itab_MARA_ALL, and copy the internal table itab_COMM_PRODUCT_ALL into itab_COMM_PRODUCT_TEMP. Loop at itab_COMM_PRODUCT_ALL and check the existence in itab_MARA_ALL. If found then delete the corresponding entry from itab_COMM_PRODUCT_TEMP. Finally, itab_COMM_PRODUCT_TEMP will have the entries apart from MARA table.

    As a result, itab_MARA & itab_COMM_PRODUCT_TEMP gives the differences between the entries in MARA and COMM_PRODUCT database tables.

    Hope this helps.

    Kind Regards,

    Satish Kanteti

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 06, 2012 at 01:09 PM

    HI,

    I had a solution without using sap. Just export Material number from both the tables in excel and use V-Lookup or if formula in excel to match the records.

    or create program as mentioned abobe.

    Regards,

    Ravi Singh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 07, 2012 at 08:16 AM

    Hi,

    The best and perhaps the best solution is "V-Look Up" in Microsoft Excel.

    Regards,

    Danish.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.