The performance of a report has a strong relation to the selection parameters on the report selection screen. So a common way to attack performance problems is to make e.g. a plant or date-range mandatory fields, which should then limit the selection. It also restricts the end user in the way the report can be used. So here's an alternative way to control what selections are allowed, without restricting the end user in determining how this selection is determined.
Your report is typically an ALV with thousands of records. But when the end user comes along and enters no selection parameters, the report is to select and present hundreds of thousands of entries, just so the end user can see for himself/herself that the actual output is of no use. Here's an approach to avoid this:
When performing the main selection (typically a JOIN
), select using UP TO nn ROWS
.
SELECT a~matnr a~charg a~lvorm a~vfdat
b~mtart c~werks c~prenc
UP TO 10000 ROWS
INTO CORRESPONDING FIELDS OF TABLE lt_mch1_mara_marc
FROM mch1 AS a
INNER JOIN mara AS b
ON a~matnr = b~matnr
INNER JOIN marc AS c
ON a~matnr = c~matnr )
FOR ALL ENTRIES IN lt_lqua
WHERE a~matnr = lt_lqua-matnr AND
a~charg = lt_lqua-charg AND
a~lvorm IN so_lvorm AND
a~vfdat IN so_vfdat "plus many more fields
Then after performing this selection check whether the maximum number of entries were selected.
IF lines( lt_mch1_mara_marc ) = 10000. * Message: The selection holds over & results - please limit the selection MESSAGE I123(ZX) WITH 10000. ELSE. * Continue processing here ENDIF.
If the selection was limited - simply throw an error message "The selection holds over nnn results - please refine your selection" with a long text explaining what to do:
U1 &CAUSE& AS The report has performed a selection that yields too many results to be processed. U1 &SYSTEM_RESPONSE& AS With over &v1& selection results the report was stopped. U1 &WHAT_TO_DO& AS Please supply values for the parameters in the selection screen and run the report again. By specifying the results you want to see in more detail, the number of selection results will be decreased.