Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

optimise

Former Member
0 Likes
538

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.

3 REPLIES 3
Read only

RaymondGiuseppi
Active Contributor
0 Likes
512

Try to use FOR ALL VALUES IN if your range/select-option only contains EQ test

WHERE rsnum IN r_rsnum

becomes

FOR ALL ENTIRES IN r_rsnum
WHERE rsnum = r_rsnum-low

Else 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.

Read only

Former Member
0 Likes
512

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.

Read only

Laxmana_Appana_
Active Contributor
0 Likes
512

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