cancel
Showing results for 
Search instead for 
Did you mean: 

Evaluating value before allocation

avihay_efrati2
Participant
0 Kudos

Hi,

BPC 7.5 NW - Script logic

I have the following script:

.....

*FOR %CUSTOMER2% = %CUSTOMER% AND %MODEL2% = %MODEL%

*FOR %SOURCE2% = %SOURCE%

*RUNALLOCATION

*DIM TIACCOUNT WHAT=PRICE; WHERE=PRICE

*DIM P_MONTH WHAT = %DUMMYMONTH%; WHERE=BAS(%BYEAR%.TOTAL)

*FACTOR=1

*ENDALLOCATION

*NEXT

*NEXT

*COMMIT

As you can see, it basically takes a value that the user keyed for a dummy month and spreads it across all months. it does the action for various combinations of dimension values that are in variables.

My question is - I want to verify that the amount I am about to spread is different than 0 before I spread it. I though of adding a *SELECTCASE right after the second *FOR statement but I got an error when I run it through the data manager (validation was OK).

Any ideas about how to do this?

Thanks,

Avihay

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member186338
Active Contributor
0 Kudos

Hi Avihay,

The *SELECTCASE statement is applicable to MDX expressions only (look on the example in the help). It's not applicable to WHEN/ENDWHEN, RUNALLOCATION and other.

For *RUNALLOCATION there is no way to check the value before allocating. But why do you think that 0 is an incorrect value? 0 can be used to clear previously allocated results...

You can replace *RUNALLOCATION with complex WHEN/ENDWHEN and in the *REC you can do some value checks using syntax like:

([A]>0)?[A]:0

B.R. Vadim

avihay_efrati2
Participant
0 Kudos

Hi Vadim,

Thanks for the reply.

The business scenarion is like this - the user has to plan price per material. I allowed the user to input price for a dummy month and then run the funtions to copy the results to all months. Later, the user can change the monthly price if this is required.

The users in some cases entered a price for the dummy month and on the same screen entered in other materials the prices directly at month leve.

Then the user run the package and all of the monthly data for materials in which there was no default price was cleared.

I wanted to check the dummy month price and if it is 0 I will not run the function and the user will have to delete the momthly price manually.

I will consider the *REC option you have suggested.

Thanks,

Avihay

former_member186338
Active Contributor
0 Kudos

Hi Avihay,

In general there are 2 cases:

1. User didn't enter the price value in the dummy month. Then there will be no record for this month and if you loop records for dummy month and copy values to real months then the month record will not be affected.

*XDIM_MEMBERSET P_MONTH AS %MNTHS%=BAS(%BYEAR%.TOTAL) //to assign var %MNTHS% the list of base members of %BYEAR%.TOTAL

*XDIM_MEMBERSET P_MONTH = %DUMMYMONTH%

*WHEN P_MONTH

*IS *

*FOR %MNTH% = %MNTHS%

*REC(EXPESSION=%VALUE%,P_MONTH=%MNTH%)

*NEXT

*ENDWHEN

2. If the user entered some price value in the dummy month, but then entered 0 in the same cell to clear it. In this case there will be record with 0 value which will appear in the WHEN ENDWHEN loop. If you want to avoid clearing of the month value in this case also then:

*XDIM_MEMBERSET P_MONTH AS %MNTHS%=BAS(%BYEAR%.TOTAL) //to assign var %MNTHS% the list of base members of %BYEAR%.TOTAL

*XDIM_MEMBERSET P_MONTH = %DUMMYMONTH%

*WHEN P_MONTH

*IS *

*FOR %MNTH% = %MNTHS%

*REC(EXPESSION=(%VALUE%>0) ? %VALUE% : ((%VALUE%<0) ? %VALUE% : [P_MONTH].[%MNTH%]),P_MONTH=%MNTH%)

*NEXT

*ENDWHEN

B.R. Vadim

former_member186338
Active Contributor
0 Kudos

And some comments in general:

To my mind it's not a good idea to enter data both in a dummy month and in real month's. The sequence of events becomes critical for user. They will make mistakes filling both dummy month and real month's. When you run DM package real month's will be cleared anyway in this case and the user will think that his real month input is OK.

Solutions:

1. Don't use dummy month's at all, ask users to enter data for all months (copy paste is simple )

2. Enter dummy month and real month's in one template and in DEFAULT.LGF if it's a dummy month value - copy it to all month's. In this case at least user will see the result of send immediately. But it's not a simple task to implement such DEFAULT.LGF:

It can be done using custom BADI or with FOR/NEXT that can be slow.

B.R. Vadim