Requirement : Get all entries from Custom tabale and from LQUA and compare both tables and write rest of the entries from each table to excel files.There are 200,000 records in each table ZPHY_INV_HIS and LQUA. Please see below code, I couldn;t do more interms of performence and Program is taking almost 2 hours to give output. Please help me and let me know that how can i increase performence of this program.
SELECT * FROM ZPHY_INV_HIS INTO TABLE IT_PHY_INV_HIS.
SORT IT_PHY_INV_HIS BY STO_UNIT.
*Get all entries from LQUA table
SELECT LGNUM MATNR LGTYP LGPLA MEINS GESME LENUM LGORT
FROM LQUA INTO CORRESPONDING FIELDS OF TABLE IT_LQUA
WHERE LGNUM = I_LGNUM.
IF NOT IT_LQUA IS INITIAL.
SORT IT_LQUA BY LENUM ASCENDING.
LOOP AT IT_PHY_INV_HIS INTO WA_PHY_INV_HIS.
IF NOT WA_PHY_INV_HIS-STO_UNIT IS INITIAL.
READ TABLE IT_LQUA WITH KEY
LENUM = WA_PHY_INV_HIS-STO_UNIT BINARY SEARCH
INTO WA_LQUA
TRANSPORTING LGNUM MATNR LGTYP LGPLA GESME LENUM LGORT.
ENDLOOP.
I am not sure if this is something to do with READ statement because when i run in debugging mode in LOOP statment itself program is taking so much time to come out and for Select statements are fine as those tables have secondary indexs in it.