cancel
Showing results for 
Search instead for 
Did you mean: 

Execution of default macro only on specified aggregation level

Former Member
0 Kudos

Hello,

I have a macro in a planning book and I want to realize that this macro will only be executed on a specified aggregation level (product). I do not know exactly how to realize this.....

The macro should be executed as a default macro.

In the macro definition itself I have the option in 'Settings for execution' to execute the macro on certain levels. Then I have the option to select values like 'AGG_LEVEL', 'Level 1', 'Level 2' etc.

But I do not know how to match exactly the execution on level 'product'......

Is somebody able to help?

Thanks and kind regards

Heinz

Accepted Solutions (0)

Answers (1)

Answers (1)

rajkj
Active Contributor
0 Kudos

Heinz,

You can use the ACT_LEVEL and the following code snippet,

IF (AGG_LEVEL( '9AMATNR' ) )  // this ensures the current planning object is product

   IF( ACT_LEVEL = 2 )  // ACT_LEVEL gives you the current level

     -----

   ENDIF

ENDIF

Thanks,
Rajesh

Former Member
0 Kudos

Hello Rajesh,

thanks for your reply.

I do not know what you mean by the ACT_LEVEL statement. I tried your code snippet, but with the ACT_LEVEL statement it does not work. Nothing happens in calculation. The first statement with AGG_LEVEL is clear and this must be correct - but I do not know what is the purpose of ACT_LEVEL and why it does not work.

Please reply again.

Thanks and kind regards

Heinz

rajkj
Active Contributor
0 Kudos

Hi Heinz,

At macro definition level, you can choose whether your macro needs to be executed at aggregated level or detailed level or certain level or at all levels. The macro will be executed only at that level. But, this will consider all the characteristics.

If you want to have some flexibility and control the macro execution dynamically (based on some business logic), you may use macro functions. It allows you to consider only required characteristics such as product (as you mentioned).

ACT_LEVEL gives you the current level of drill down or up. If you want to kick off your functionality at a certain level, then this macro function is handy. You can compare the ACT_LEVEL with a required drill down/up level (static).

Thanks,

Rajesh

Former Member
0 Kudos

Hi Rajesh,

ok, but my macro is a executed as a start or a default macro when opening the planning book. So, it will not react on user actions with drill-down e.g.

That is the point I do not understand: what to do with a start or default macro? And why do you specify in your ACT_LEVEL statement the number '2'. You mentioned ACT_LEVEL = 2 - why? Why not ACT_LEVEL = 3 or 4 e.g.

Please reply again

Thanks

Heinz

rajkj
Active Contributor
0 Kudos

Hi Heinz,

Default execution depends on how you load your data view. For instance, if you load all the products belonging to particular location, the macro can be executed due to default event association. Probably, it's better to test the macro manually until you get the expected results without placing it under any event.

I compared the ACT_LEVEL with 2 just for illustration purpose only. It can be defined per your requirements.

Thanks,

Rajesh

Former Member
0 Kudos

Hi Rajesh,

but how to find out the planning level of material with this macro functionality.

Even if I choose to execute the macro on a certain level in the macro definition - how to know which is the planning level of product....

The same if I use the function ACT_LEVEL in the macro - how to know which is the needed planning level where the macro should do the calculation.

I do not understand how to specify this planning level 'product' and execute the macro only on this level....

Thank you very much again

Heinz

rajkj
Active Contributor
0 Kudos

Hi Heinz,

I may need some more details on your business requirement for better understanding. Anyway, please validate the following stuff.

At what level the macro needs to be executed is based on the business decision. We have two options -

1. All products (kind of hard coding)

The macro needs to be executed irrespective of the product at level 1 (assuming no hierarchies and you loaded all the products of a location).

IF( AGG_LEVEL( '9AMATNR' ) =  1 )

  IF( ACT_LEVEL = 1 )

     -------

2. The required level is location product specific

IF( AGG_LEVEL( '9AMATNR' ) =  1 )

  IF( ACT_LEVEL = MATLOC_EXTRA( n ; ACT_PRODUCT , ACT_LOCATION , ACT_VERSION ) )

-----

where n is the extra field number that you maintain in the location master record (t.code /sapapo/mat1 - last tab extras). This allows you to define the required level on product master record and based on the value, you trigger the macro.

Thanks,
Rajesh

Former Member
0 Kudos

Hello Rajesh,

my issue is the same if I execute the macro via batch job and set the aggregation level of this batch job to product (set flag on characteristic 'product' of aggregation level).

So, the macro functionality should only be executed on this product level.

But my issue is that I do not want to execute this via batch job, I want to execute this macro whenever you enter the planning book (start or default macro).

I hope the requirement gets a bit clearer for you.

Thanks and kind regards

Heinz

rajkj
Active Contributor
0 Kudos

Hi Heinz,

It's clear now and we both gave importance to the different aggregation levels. From your post, I understand that we have only detailed and aggregated levels.

With this context, you can set the execution level to AGG_LEVEL in your macro definition. To make sure, the macro triggers only if product is at the aggregation level, consider using a IF condition.

IF ( AGG_LEVEL( 'product characteristic' ) = 1 )

...

ENDIF

Thanks,
Rajesh