‎2018 Dec 04 10:36 AM
Hi Expert,
I am using two open Cursor to call the data from two database table then I am trying to compare the data to find out the different data and records between them, but everything was in vain because the first cursor called 10000 records let us say material numbers.. the sound cursor call 10000 material numbers but they are totally different from the first cursor called data.....
The operation is going wrongly as no one of the first 10000 is in the second 10000 although they are in the second database but has not been called in this pass of looping....
I have tried to make append lines to a new intern tables and then to compare them but this is not a solution as I have millions of records and this will be like a select statement....
Please, any advises solving this..
Best Regards
Jenie
‎2018 Dec 04 12:24 PM
SELECT... FROM table1 INTO TABLE first_data_set PACKAGE SIZE 10000.
SELECT ... FROM table2 INTO TABLE second_data_set
FOR ALL ENTRIES IN first_data_set
WHERE key eq first_data_set-key
" compare first_data_set with second_data_set.
...
ENDSELECT.No need for a cursor.
‎2018 Dec 04 12:24 PM
SELECT... FROM table1 INTO TABLE first_data_set PACKAGE SIZE 10000.
SELECT ... FROM table2 INTO TABLE second_data_set
FOR ALL ENTRIES IN first_data_set
WHERE key eq first_data_set-key
" compare first_data_set with second_data_set.
...
ENDSELECT.No need for a cursor.
‎2018 Dec 04 12:55 PM
‎2018 Dec 04 3:53 PM
Oh yes. A far better solution - combine my answer with yours. i.e. with order, but without cursor.
‎2018 Dec 05 12:32 AM
this is what i tried to tell her in other post but seem like she need sample code instead :).
‎2018 Dec 04 12:54 PM
Well you could try to optimize if the select are 'ordered' (select order by) some pseudocode could be
open cursor 1.
open cursor 2.
do
Fetch a package from table 1 into internal table 1
if no record, exit
loop at internal table 1 into record 1.
while cursor 2 open and second table last value lower than record 1 key
fetch a package of table2
if no record, close cursor 2 and exit
endwhile
compare data with record 1 with internal table 2
endloop
enddo