hi ppl,
I want to put the select query mentioned below outside the loop to resolve performance issue. The 'for all entries' does not support aggregate functions like 'sum' and 'group by'. plz have a look at my approach and suggest some changes.
the code:
LOOP AT T_UNITS.
V_TABIX = SY-TABIX.
CONCATENATE TEXT-S01 T_UNITS-UNIT INTO VL_TEXT SEPARATED BY ' '.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
PERCENTAGE = 0
TEXT = VL_TEXT.
get GLPCA postings
SELECT AWTYP AWORG RACCT REFDOCNR SUM( HSL ) FROM GLPCA "1062
INTO TABLE T_GLPCA
WHERE RPRCTR = T_UNITS-UNIT
AND RACCT IN S_HKONT
AND KOKRS = V_KOKRS
AND RYEAR = P_GJAHR
AND POPER <= P_MONAT
GROUP BY AWTYP AWORG RACCT REFDOCNR.
lopp at t_glpca.
...
...
endloop.
endloop.
my approach:
all this put outside the loop 'loop at t_units'.
SELECT rprctr AWTYP AWORG RACCT REFDOCNR HSL FROM GLPCA "1062
INTO TABLE T_GLPCA
For all entries in t_units
WHERE RPRCTR = T_UNITS-UNIT
AND RACCT IN S_HKONT
AND KOKRS = V_KOKRS
AND RYEAR = P_GJAHR
AND POPER <= P_MONAT.
loop at t_glpca.
v_tabix = sy-tabix.
select sum( hsl ) from glpca into t_glpca-hsl.
modify t_glpca index v_tabix.
endloop.
The select query 'select sum( hsl ) from glpca into t_glpca-hsl' is consuming lot of time.
thanks in advance
Archana