2010 Mar 15 4:30 AM
Hi all,
The following is my codes.
LOOP AT t_pa INTO w_pa.
SELECT pernr
begda
endda
INTO TABLE t_infty_data
FROM (w_pa-pa)
WHERE begda <= me->a_payperiod-begda
AND endda >= me->a_payperiod-endda.
Anyone have any idea how can perform the Select statement outside the loop? I used the loop because at program run tme, I do not know yet which database tables to select from. Thanks.
2010 Mar 15 4:48 AM
Hi,
if you know, that the select uses only one table, than you can create SELECT with FOR ALL ENTRIES before the LOOP statement.
If T_PA-PA contains different tables than you can do the select only inside the loop - because in the worst situation, you query one different table for each row of T_PA table.
Regards,
--
Przemysław
2010 Mar 15 4:48 AM
Hi,
if you know, that the select uses only one table, than you can create SELECT with FOR ALL ENTRIES before the LOOP statement.
If T_PA-PA contains different tables than you can do the select only inside the loop - because in the worst situation, you query one different table for each row of T_PA table.
Regards,
--
Przemysław
2010 Mar 15 10:36 AM
Hi
t_pa2[] = t_pa[]
sort t_pa2 by pa.
delete adjusting duplicates comparing pa.
LOOP AT t_pa2 INTO w_pa.
SELECT pernr
begda
endda
APPENDING TABLE t_infty_data *-------> add one more field with name of (w_pa-pa) by code as you want
FROM (w_pa-pa)
WHERE begda <= me->a_payperiod-begda
AND endda >= me->a_payperiod-endda.
endloop.
LOOP AT t_pa INTO w_pa.
read t_infty_data.... ---> first key is name of table (w_pa-pa).
.......
...........
........
endloop.
This way you make only one select for each table
Best Regards
Yossi Rozenberg
Best Regards
Yossi Rozenberg