cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with Maintenance plan read, MPLAN_READ

0 Kudos

Hello,

I am working on a program to call maintenance plans manually to generate an order using FM MPLAN_MANUAL_CALL. Using FM MPLAN_READ to fetch ZAEHL to pass to the manual call. MPLAN_READ is giving wrong results when executed in loop and in SE37. Below is the structure of the logic.

Loop at mplans.

CALL FUNCTION 'MPLAN_READ'

EXPORTING mplan = warpl

no_buffer = 'X'

TABLES return = lt_return

strategy_cycles = lt_strat_cycles.

READ TABLE lt_strat_cycles INTO ls_strat_cycles INDEX 1.

lv_zaehl = ls_strat_cycles-zaehl.

CALL FUNCTION 'MPLAN_MANUAL_CALL'

EXPORTING warpl = warpl

manda = sy-datum

zaehl = lv_zaehl

IMPORTING return = lt_return.

REFRESH : lt_strat_cycles

Endloop.

Above logic is working fine and generating orders except few times.

Eg error: When looping on 3 mplans, for mplan3 the FM MPLAN_READ gave 2 strategy cycles in lt_strat_cycles. When i run FM MPLAN_READ with mplan3 in SE37 or if this mplan3 is the first in the loop then FM MPLAN_READ is returning only 1 strategy cycle.

Due to this issue of using wrong ZAEHL, order is not getting generated. I have also tried below FM before each MPLAN_READ but still no use.

FM 'MPLAN_BUFFER_CLEAR'

EXPORTING plan = warpl

with_items = 'X'.

Need help to fix the issue why MPLAN_READ in SE37 gives only one strategy cycle where as in the loop it gives 2. If this mplan is first in the loop, then it gives only one strategy cycle.

Or else, is there any other way to get the ZAEHL for the mplan?

Thanks,

Ram

Accepted Solutions (0)

Answers (2)

Answers (2)

peter_atkin
Active Contributor
0 Kudos

Have you tried a commit, before you clear the buffer?.

Alternativey, you could read the package from the task list data (table PLWP).

PeteA

peter_atkin
Active Contributor
0 Kudos
0 Kudos

Hi Peter,

In the referred question, issue was related to locking issue of the same maintenance plan calling in the loop.

My issue is not related to the locking nor calling same maintenance plan. My issue is the strategy cycles returned by the MPLAN_READ in LOOP vs SE37.

Thanks,

Ram