Is there a way for the following SELECT query to be improved?
The problem that I'm seeing here is that the same table (l_item_tab) is being queried twice in the SELECT query (due to the "table joins", a and b). How can I improve the data retrieval here? And I also can't change the SELECT query to be out of the loop - ledger is a select-option and multiple values are possible.
* Get Ledger SELECT * FROM t881 INTO TABLE lt_t881 WHERE rldnr IN s_rldnr. LOOP AT lt_t881. * Get FI-SL user-defined item table based on ledger PERFORM get_sl_item_tab USING lt_t881-rldnr CHANGING l_item_tab. " L_ITEM_TAB is populated here * Get SL line items SELECT * APPENDING CORRESPONDING FIELDS OF TABLE gt_glu1 FROM (l_item_tab) AS a WHERE rldnr IN s_rldnr " Ledger AND rbukrs IN s_bukrs " Company code AND ryyrkeg_wwsub IN s_wwsub " Subsystem AND racct IN s_racct " Account no AND ryymac IN s_yymac " Management area AND rtcur IN s_rtcur " Trx currency AND docnr IN s_docnr " Doc. number AND docty IN s_docty " Doc. type AND docct EQ c_docct_l " Doc. category (L = Local) AND ryear IN s_ryear " Fiscal year AND budat IN s_budat " Posting date AND yystodt IN s_stodt " Reversal date AND yystgrd IN s_stgrd " Reversal reason AND yyintref IN s_intref " Interface ID AND NOT exists ( SELECT * FROM (l_item_tab) AS b WHERE b~rldnr = a~rldnr AND b~docnr = a~docnr AND b~rbukrs = a~rbukrs AND ( ( ( b~docct = c_docct_y OR b~docct = c_docct_x ) AND b~refryear = a~ryear ) OR ( ( b~docct = c_docct_u OR b~docct = c_docct_t ) AND b~ryear = a~ryear ) ) ) . ENDLOOP.
Edited by: Rob Burbank on Jun 23, 2010 12:33 PM