‎2007 Apr 14 9:15 AM
SELECT
rsnum
matnr
werks
sobkz
SUM( bdmng )
SUM( enmng )
shkzg
aufnr
postp
potx1
pspel
INTO TABLE t_output
FROM resb
WHERE rsnum IN r_rsnum
AND xloek EQ ' '
AND shkzg NE 'S'
GROUP by rsnum matnr werks sobkz shkzg aufnr postp potx1 pspel.
When the selection criteria has lesser number of records this code works. but as soon as the number increases to a moderate level it results in ABAP dump.
RSNUM is the 'Number of reservation', is the range that is passed through the select statement.
Please help me optimise this code.
‎2007 Apr 14 12:31 PM
Try to use FOR ALL VALUES IN if your range/select-option only contains EQ test
WHERE rsnum IN r_rsnumbecomes
FOR ALL ENTIRES IN r_rsnum
WHERE rsnum = r_rsnum-lowElse you could break the range in sub-set, as you group per RSNUM, no problem should arise.
APPEND LINES OF r_snum FROM 1 TO 100 TO r_rsnum_2
SELECT ...Regards.
‎2007 Apr 14 1:50 PM
Hi Amit,
I would suggest you dont do the SUM wihtin the select, since for that u need to use the GROUP statement within the SQL query and that hinters performance pretty badly.
Instead, first read all the records into an internal table and then sort the table based on your key fields and finally looping you use the COLLECT statements. Just ensure all the key fields (based on which you are grouping) are character/numeric fields, to support the COLLECT statement.
Hope this helps.
Regards,
Aditya
p.s. you can create a copy of the current report, and implement the above correction and test the performance response using ST05 and SE30 tools and then settle on the optimum option.
‎2007 Apr 14 2:57 PM
Hi Amit,
In range object , you can fill upto 2500 entries , if the rows exceeds 2500 , dump will occur.
instead of using range object , change the select with FOR ALL ENTRIES option
like
select rsnum into table i_rsnum.
if not i_rsnum[] is initial.
SELECT rsnum matnr werks sobkz
bdmng enmng shkzg aufnr
postp potx1 pspel
INTO TABLE t_output
FROM resb
for all entries in i_rsnum
WHERE rsnum = i_rsnum-rsnum
AND xloek EQ ' '
AND shkzg NE 'S' .
endif.
then find out sum of the values
loop at t_output.
Move-corresponding t_output to t_output_1.
collect t_output_1.
endloop.
Regards
L Appana