‎2007 Jan 31 10:09 AM
Hi i use the select count in loop and i now that its not good for performence . in this loop i count employee that in org. unit and in wa_teken_itab-objid i have every time other org unit . maybe someone have idea how can change it for a better select
regards
LOOP AT teken_itab INTO wa_teken_itab.
SELECT stell COUNT( * ) AS ex_immobile_num "job
FROM pa0001
INTO wa_count_immobile_itab
WHERE ( persg EQ '6' OR persg EQ '7' OR persg EQ '8' ) "Employee Group
AND orgeh = wa_teken_itab-objid
AND orgeh NE '00009999' "Org Unit
AND begda <= so_date
AND endda => so_date
GROUP BY stell.
IF sy-subrc = 0.
APPEND wa_count_immobile_itab TO count_immobile_itab.
CLEAR wa_count_immobile_itab.
ENDIF.
ENDSELECT.
ENDLOOP.
‎2007 Jan 31 10:24 AM
Hi,
Instead of using select in loop you can go for Select for all entries option.
Ashvender
‎2007 Jan 31 10:24 AM
Hi,
Instead of using select in loop you can go for Select for all entries option.
Ashvender
‎2007 Jan 31 10:34 AM
o.k... but its a problem becouse u cant do select for all entries in count statment
regards
‎2007 Jan 31 10:50 AM
Hi,
Ok. If select for all entries cannot be used then make it as Select Single statement or Select .... INTO TABLE statement instead of Select & Endselect.
Ashvender
‎2007 Jan 31 11:01 AM
Antonio,
LOOP AT teken_itab INTO wa_teken_itab.
SELECT stell COUNT( * ) AS ex_immobile_num "job
FROM pa0001
INTO wa_count_immobile_itab
********************************************
FOR ALL ENTRIES IN wa_teken_itab
WHERE orgeh = wa_teken_itab-objid and
***************************************************
( persg EQ '6' OR persg EQ '7' OR persg EQ '8' ) "Employee Group
AND orgeh NE '00009999' "Org Unit
AND begda <= so_date
AND endda => so_date
GROUP BY stell.
IF sy-subrc = 0.
APPEND wa_count_immobile_itab TO count_immobile_itab.
CLEAR wa_count_immobile_itab.
ENDIF.
********************
ENDSELECT.
******************
ENDLOOP.