cancel
Showing results for 
Search instead for 
Did you mean: 

APO DP Macro: Using value from previous period in current period result

Former Member
0 Kudos

APO Experts,

I have an issue where I have a macro that needs to do the following:

Add Key Figure A from period 1 to Key Figure B (from period 1) into results row Key Figure C (from period 1) and then have a second step that adds Key Figure C (from period 1) to Key Figure D (from period 2) into results row Key Figure E (from period 2).

My current macro looks like this:

Step One (future)

Row: Key Figure C (from current to future) =

Key Figure A (from current to future)

+

Key Figure B (from current to future)

Step Two (future)

Row: Key Figure E (from current to future) =

Key Figure C (from current -1 to future)

+

Key Figure D (from current to future)

The current behavior of this macro is that period 1 calculates appropriately (i.e. KFE uses the value of KFC which was calculated for the period 0), but no more of the periods are calculated correctly (they calculate as though KFC = 0). If I run the macro again, period 2 now calculates correctly, and I need to manually execute the macro for each period across the time stream to get all the values correct.

I think the problem is that macros don't save data between periods during macro execution, so the value for KFC (period 1) has not been saved by the time the second step of the macro fires. I have also tried assigning the results row for KFC to an auxilliary table row and then using the auxilliary in step 2, but still don't get the results I need. I think that there may be a way to use a layoutvariable to do this but I haven't explored that option further yet.

Any help here will be most appreciated,

Sean Mawhorter

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Sean,

I would have expected that to work. Why dovt you create a collective macro? Split the two steps into two individual macros. Then assign these macros to a collective macro in the required sequence and run it. I am pretty sure it will work. Let me know how it goes.

Cheesr!

Abhi

Answers (2)

Answers (2)

Former Member
0 Kudos

While the comments above are absolutely valid, the client had a requirement to see the data calculate real time. My final solution for this was to replicate the steps of the macro across the time horizon (i.e. each period had its own step). While not an optimal solution, it is a solution that works for our purposes (we have a relatively small dataset). Thanks so all who responded.

Former Member
0 Kudos

Hi Sean,

You are almost right, the data is saved until all the steps defined in an activity is executed. So you will have to schedule another job to run after this or use a auxillary table element to store the values temporarily and then use it for further calculations within a macro.

Hope this helps.

Thanks

Mani

Former Member
0 Kudos

Mani,

Thanks for your reply. Based on your comment, is it then not possible to have this macro run as a default macro so that the user can see this in real time?

The actual user requirement is this: We are replicating the net requirements calculation in DP and passing the result to a custom application in the R/3 system. The receipt elements many times are aggregated into monthly quantities even though the forecast is created in weekly buckets. So to show the proper net requirement quantity I need to be able to "roll" the remaining receipt quantities (in buckets where the total supply exceeds the total demand) and push the leftover receipt quantity to the next period. I have this macro working in that when I execute it, the first column is calculated correctly but it does not pass a remaining quantity to the next column. If I execute it again, the remaining quantiy is passed to the 2nd column and the 2nd column calculates the remaining quantity correctly but does not pass it to the 3rd column. Repeatedly executing the macro (for as many future columns as are in the data view) eventually achieves the correct results but obviously does not work for an end user procedure.

Any help for this would be most appreciated as our design is contingent on this to some degree.

Thanks,

Sean

Former Member
0 Kudos

Sean,

Your current design will not work if run as default.

However in the macro workbench, in addition to plng tables, you will see auxillary tables. The values for this are temporary and also reflected immediately, so you can use this alone or in combination with planning tables(if you want to save the calculated data, which i think is the case).

You can use the auxillary rows to pass on the excess quantity and use if for calculation. I have given a small snippet below:

Step One (future)

Row: Key Figure C (from current to future) =

Key Figure A (from current to future)

+

Key Figure B (from current to future)

Step Two (future)

Row: Key Figure E (from current to future) =

Key Figure C (from current -1 to future)

+

Key Figure D (from current to future)

Add something like this to step 1


Aux Row (temp) = Key Figure A (from current to future) + Key Figure B (from current to future)

Then to step 2 change it as follows


Row: Key Figure E (from current to future) =
Aux Row Key Figure (temp) (from current -1 to future)
+
Key Figure D (from current to future)

This shud do the work.

Hope this helps.

Thanks

Mani