cancel
Showing results for 
Search instead for 
Did you mean: 

How to use CL_RSR_PARA change the parameter for planning sequence

Former Member
0 Kudos

Hi,

I am creating a program which will call " RSPLSSE_PLSEQ_EXECUTE" to run a planning sequence in a loop. And in that loop it will change the value of the variant which used for the planning sequence.

Simply I want to call a planning sequence many times and each time I change the parameter.

So I found the class CL_RSR_PARA. This class will read and update table RSRPARAMETRIZA to change variant. While I am not good at ABAP. So can someone help me figure out how to use the method CL_RSR_PARA=>CHANGE?

Could you please give me an example code?

Thanks!

Dongkai

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hello Dongkai,

I had a similar requirement to execute a Planning sequence which should be called multiple times with different variable values. the problem is that even if we have Exit Variables (ABAP) the variable will be called only once and so it will always run only for the first set of values. I tried clearing the variables using several standard FM and Classes but nothing worked. So I finally created a wrapper function module ( Should be RFC enabled ) which will do the following

1) This FM receives the variable values as set of input parameters

2) Save these variable values globally ( you can use singleton class or simply store as a global variable in a function grp )

3) Call RSPLSSE_PLSEQ_EXECUTE

4) if there are no errors then call RSPLSTD_DATA_SAVE to save the data in planning buffer

All your variable should read from these global where you set the values in Step2

Now in your program, you just need to loop around your values and call this wrapper fm asynchronously with construct STARTING NEW TASK

You should also handle the return of this wrapper function.

Also if you want to start multiple threads you can control that with the number of task you create, or simply create one task and wait for it complete.

this works fine for me ( so far ) and i couldnt find any other way to achieve this.

hope this helps

Regards RK

Former Member
0 Kudos

Hi RK,

Thanks very much!

Yes it is the solution I plan to use. And the difficult is:

1. How to change the parameter value in the loop?

    I plan to use CL_RSR_PARA while not sure how to use CL_RSR_PARA=>CHANGE.

2.  After call RSPLSSE_PLSEQ_EXECUTE, do I still need RSPLSTD_DATA_SAVE as you mentioned? As I notice the system program RSPLS_PLSEQ_EXECUTE does not do that.


3. If convenient, could you please show me your program as a example?


Cheers,

Dongkai

0 Kudos

Hello Dongkai,

1) There is no need to use  CL_RSR_PARA in this case, as your variables should read the values from the global memory where you have set.

2) Yes you have to call RSPLSTD_DATA_SAVE after the successful call of the planning sequence

3) My code has other things so its hard to share that. But Here is an example.

     Lets say you want to read the variables from a DSO, and DSO has just 2 fields like country,Sales      org etc

Now you 2 variables one for country, and another one for sales org which is of type EXIT Variables and its being used in your Filters, or PF

Your program gets the list of countries from this DSO, and call the wrapper function by starting new task with the country as parameter in a loop.

The wrapper function should set the value of country and/or sales org in a global memory ( like a global variable or single ton class ) and call the Planning sequence. Then your ABAP variable exit will be called for every time for country, and within this exit you have to just read it from the global memory where you have set the value before.

I hope this helps.

Regards

RK

Former Member
0 Kudos

Hi RK,

Thanks!

While still not understand what do you mean saving the parameter into global memory. As the function RSPLSSE_PLSEQ_EXECUTE need variant to run. Variant is the combination of pre-saved parameters using a particular technical name.

So during loop my DSO, my understanding is I have to update the variant, change the parameters value. If you say save the parameter into global memory, how to use it in function RSPLSSE_PLSEQ_EXECUTE?

Cheers,

DK

0 Kudos

Hello DK, No you don’t need to pass any variant to RSPLSSE_PLSEQ_EXECUTE. You can define a variable in your function grp and set the value to this variable in your wrapper FM. Then in the Exit Variable  read these values from the same Global variable. Thanks RK

Answers (1)

Answers (1)

sheldon_piao
Advisor
Advisor
0 Kudos

Hi Dongkai,


Seems the question is not relevant for planning application.

I think the question should be: How to use the method CL_RSR_PARA=>CHANGE to change the variant value stored in table RSRPARAMETRIZA.
This method is used to cooperate the variable via interface IF_RSR_VAR_RUNTIME, so it involves some variable class object. Maybe you can set the relevant break-point at the relevant part to debug and learn how the variant value is saved into table RSRPARAMETRIZA and how to process the change action.

If you would like to really understand this logic, maybe you can try posting the question at

to see whether there is relevant expert can answer this question or not.

By the way, can you share some information about why you want to change the parameter for planning sequence. For this question, maybe we can provide the suggestion to help you find a suitable solution.

Best Regards,
Sheldon.

Former Member
0 Kudos

Hi Sheldon,

Thanks for your reply!

Yes it should be a ABAP question. I have create it again in ABAP group.

The reason I do this is because I want to use a DSO to store the parameter, then go through the DSO to read each row and run the planning sequence based on that row. That DSO will only contain 1~3 rows each day while it keep changing.

Cheers,

Dongkai

sheldon_piao
Advisor
Advisor
0 Kudos

Hi Dongkai,

I think you may use customer exit variable to read the value from DSO which store the relevant characteristic value(s).
You can control the exit code to transfer the value to the relevant variable of the planning sequence.

Best regards,

Sheldon.

Former Member
0 Kudos

Hi Sheldon,

I understand what you mean, using RSR00001: EXIT_SAPLRRS0_001 to add some logic for a variable, in the logic go through the DSO.

While the reason I cannot use it is:

I need the planning sequence run 3 times, each time I using a different combination of parameters.

If I use exit variable:

1. The planning sequence still only run 1 time. While I need it run 3 times.

2. The parameter for the planning sequence is a combination, while exit variable can only handle 1 parameter not all.

Thanks,

Dongkai

sheldon_piao
Advisor
Advisor
0 Kudos

Hi Dongkai,

One planning sequence can contains several planning function steps.
You may use three steps in one planning sequence, and every step uses one exit variable to read its own value.

Best Regards,
Sheldon.

cornelia_lezoch
Active Contributor
0 Kudos

Hello Dongkai,

the standard way is to create a process chain

include 3 steps to start each time your sequence with the apropriate variant.

regards

Corenlia

Former Member
0 Kudos

Hi Cornelia and Sheldon,

Thanks for you help!

While the problem is I am not sure how many times the planning sequence will run as well. It might be 3, might be 2 or 4.

So the only way I can imagine is using a loop in a program to do that.

Cheers,

Dongkai