Overview
We use LP21 / RLLNACH1 (WM replenishment for fixed bins) in background processing. We have defined background jobs with 3-6 steps which executes RLLNACH1 for different storage types and storage locations. Execution times for biggest storage location were between 45 and 90 minutes. The job is scheduled 6 times every day, which gives total execution time from 4,5 to 7 hours! Every job execution creates 100 - 150 transfer orders, so it should not last so long.
Problem cause
I checked source code and debug the program - it was not performing any long SELECT statements, but the most of the time spends in READ_MATERIAL_NEW_46 form.
I found instructions (RLLNACH1, lines 1461-1471):
LOOP AT inspl.
LOOP AT p_mard
WHERE matnr = inspl-matnr
AND werks = werks
AND lgort = inspl-lgort.
EXIT.
ENDLOOP.
IF sy-subrc <> 0.
DELETE inspl.
ENDIF.
ENDLOOP.
In our case tables p_mard and inspl contain:
- p_mard[] - 511000 rows
- inspl[] - 59000 rows
When we check definition of P_MARD table:
DATA: BEGIN OF P_MARD OCCURS 100.
INCLUDE STRUCTURE MARD.
DATA: END OF P_MARD.
it appears to be a standard table.
It is obvious, that searching this table with simple LOOP is very inefficient.
Solution
I created a modification:
*{ REPLACE 1
*\ LOOP AT inspl.
*\ LOOP AT p_mard
*\ WHERE matnr = inspl-matnr
*\ AND werks = werks
*\ AND lgort = inspl-lgort.
*\ EXIT.
*\ ENDLOOP.
*\ IF sy-subrc <> 0.
*\ DELETE inspl.
*\ ENDIF.
*\ ENDLOOP.
*** RLLNACH1 performance
SORT p_mard[] BY matnr werks lgort.
LOOP AT inspl.
READ TABLE p_mard[]
TRANSPORTING NO FIELDS
WITH KEY matnr = inspl-matnr
werks = werks
lgort = inspl-lgort
BINARY SEARCH.
IF sy-subrc <> 0.
DELETE inspl.
ENDIF.
ENDLOOP.
*** RLLNACH1 performance - end
*} REPLACE
Test results
Results of this change was very satisfactory.
Here are execution times before and after change:
- 5 days before
- 5 days after
- 6 executions every day
execution times | before [s] | after [s] | after / before |
MIN | 2750 | 103 | 3,7% |
MAX | 5088 | 216 | 4,2% |
AVG | 3441 | 164 | 4,8% |
As a result of the change described here, program execution time descreased over 25 times.