cancel
Showing results for 
Search instead for 
Did you mean: 

macro problem to calculate Key figures?

former_member245036
Participant
0 Kudos

Dear SAP,

  I have a problem in using macro to calculate key at detail locaotion level like this:

  For example:  I use macro to calculate key "So luong can dieu hoa" 

  So luong can dieu hoa(Location:1000) = Ton kho theo co cau(Location: 1000+2000) * Ty le co cau kho tien(Location: 1000)/100

  with Ton kho theo co cau( total) = Ton kho theo co cau(Location:1000) + Ton kho theo co cau(Location:2000)

Problem here is we want calculate So luong can dieu hoa at detail level of location but Ton kho theo co cau at total level.

so how can we design macro?

thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member245036
Participant
0 Kudos

Please help me. it's very important.

thanks

hungth

former_member187488
Active Contributor
0 Kudos

The request is quite strange. As far as I know. marco could not be executed like this.

rajkj
Active Contributor
0 Kudos

Hi Hungth,

Here is one alternative to achieve your requirement assuming you are allowed to define the procedure.

1. User will load the entire selection profile data on to data view, so that you can see all the key figures showing their total values.

2. In your macro book, capture the required key figure value at this level based on the following pseudo code. This macro should be added to the start event.

STEP - 1 Iteration

IF( AGG_LEVEL = 1 )

VEC_LAYOUTVARIABLE_SET( 'KF_TOTAL' ;

AREA Macro element of 'Ton kho theo co cau' for the entire horizon

)

3. Your user now drills down to required level and triggers another macro (this action may be manual or if you want automatic action add the macro to 'Level Change' event)

STEP1 - Entire horizon

Action box macro element - Set a variable

LAYOUTVARIABLE_SET( 'TOTAL' ;

   VEC_LAYOUTVARIABLE( 'KF_TOTAL' ; ACT_COLUMN ; ACT_COLUMN ) )

luong can dieu hoa(Location:1000) = LAYOUTVAL_VALUE( 'TOTAL' ) * Ty le co cau kho tien(Location: 1000)/100

I hope it is useful to you.

Thanks,

Rajesh

former_member245036
Participant
0 Kudos

Thanks so much for your answer but i have difficulty in implementing this macro in macro builder.

please guide me step by step.

thanks

hungth

former_member245036
Participant
0 Kudos

Dear Expert,

I have an error when generating first macro like this:

please explain and help us.

thanks so much

rajkj
Active Contributor
0 Kudos

Hi Hung,


Please check the following screenshots of macro implementation and let me know if you have any query.

Thanks,
Rajesh

Scenario Objective: Calculate Proportional Factors

Description: It is required to calculate the proportional factors based on the proportions of forecasts generated for a couple of locations (Loc 1 and Loc 2).

Proportional Factor (Loc 1 ) =  ( Forecast (Loc 1) / Total Forecast ) * 100

Where Total Forecast = Forecast (Loc 1) + Forecast (Loc 2)

Macros: 

I used a composite macro to capture the aggregate value and one more macro to update the key figure. Composite and normal macros are to be executed manually. They are not added to any events.

rajkj
Active Contributor
0 Kudos

Remaining snapshots.. SCN should have considered at least PDF file upload. It's really a pain.

rajkj
Active Contributor
0 Kudos

Here are another 3 images.

rajkj
Active Contributor
0 Kudos

The last 3 images.

former_member209769
Active Contributor
0 Kudos

Hi,

Commenting only for your usage of AGG_LEVEL.

You need to tell the system what aggregation you are talking about, so you need to give some characteristic also as an argument when you use this function.

e.g. You could check if AGG_LEVEL('9AMATNR') = 1

Replace 9AMATNR by the relevant characteristic for which you want to check the aggregation.

Thanks - Pawan