11-02-2007 9:01 AM
Hello,
I have one internal table and with same structure of view.
I want to compare internal table to DB table.
Want to filter records which doesnt exist in DB table.
Can any one help me how to do it?
Regards,
Chitra R.
11-02-2007 9:04 AM
Hi,
Select data from that database table into internal table.
Loop on first internal table and read this internal table if sy-subrc is no equal to zero then delete record from first internal table.
Regards,
Prashant
11-02-2007 9:05 AM
ya do one thing..
just do a SELECT using for all entries comparing the primary key fields into another internal table..
For example internal table contains 10 records where as only 5 match with view data
SELECT *
FROM <VIEW>
INTO TABLE ITAB_NEW
for all entries in ITAB_OLD
WHERE key1 eq itab_old-key1
and key2 eq itab_old-key2....
Now you will get matching 5 records only into ITAB_NEW>.
hope ur prob solved...
dont forget to check ITAB_OLD[] is not initial before SELECT usign for all entries..
11-02-2007 9:05 AM
select * from databasetable into table itab2.
loop at itab1.
read table itab2 with key field = itab1-field.
if sy-subrc <> 0.
delete itab1 index sy-tabix.
endif.
endloop.
11-02-2007 9:23 AM
Thanks for the solution.
but select * from DB into itab.
incase more than 60k records from ur DB.then how will you fetch all records to our internal table?
11-02-2007 9:19 AM
Hi,
fetch the data from DB table into ITAB1
then compare the ITAB and ITAB1 like
IF ITAB[] = ITAB1[]
Regards,
Omkar.
11-02-2007 9:33 AM
Hi,
Fetch record from database one at a time in the work area.
Use READ command to read the internal table with the condition as the values fetched in the workarea(see syntax of READ).
If sy-subrc is not zero .Delete that record.
But this will result in hiting the database repeatedly.
Deserve Reward.
Gaurav