cancel
Showing results for 
Search instead for 
Did you mean: 

FOX Formular Loop

Former Member
0 Kudos

Hi,

I would like to multiply a keyfigure with a percentage-value inside a loop. The code looks like this:

DATA QUARTAL TYPE 0CALQUARTER.

DATA PVALUE TYPE I.

PVALUE = { 0PERCENT, # ,'0000000000000500', 'I', YASPARA }.

FOREACH QUARTAL.

IF QUARTAL <> '#'.

{ 0AMOUNT, QUARTAL, '0000000000000700', # , YASPLAN } =

{ 0AMOUNT, QUARTAL, '0000000000000700', # , YASPLAN } * PVALUE.

ENDIF.

ENDFOR.

After i run the function, i always get 0 for all quarters although before the function there are different values. After debugging using a BREAK-POINT i found out that before the loop PVALUE is 30 and inside the loop becomes 0. Any suggestions why PVALUE is set to 0 in the loop?

Thanks,

Holger

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Dear Hogler,

Can you once try adding this line after the statment PVALUE = { 0PERCENT, # ,'0000000000000500', 'I', YASPARA }. in your original code?

MESSAGE I001(UPF) WITH 'Percent is ' PVALUE.

and see what output you get?

Former Member
0 Kudos

looks strange.There is nothing inside the loop which could make pvalue to 0.If you hardcode 30 in place of pvalue inside the loop will the function work? This is just to make sure that the other operand is not getting 0 value.

Former Member
0 Kudos

Hi ragav,

if i set PVALUE=30. it works fine. If i copy the whole expression ({ 0PERCENT, # ,'0000000000000500', 'I', YASPARA }.) inside the loop....

IF QUARTAL <> '#'.

{ 0AMOUNT, QUARTAL, '0000000000000700', # , YASPLAN } =

{ 0AMOUNT, QUARTAL, '0000000000000700', # , YASPLAN } *

{ 0PERCENT, # ,'0000000000000500', 'I', YASPARA }.

ENDIF.

its 0 again....

> looks strange.There is nothing inside the loop which

> could make pvalue to 0.If you hardcode 30 in place of

> pvalue inside the loop will the function work? This

> is just to make sure that the other operand is not

> getting 0 value.

Former Member
0 Kudos

it will definitely not work for the following reason,

you specify foreach quartal.

and check for quartal <> '#'.

but the percent value will be pulled for quartal value with #.

you are doing this because percent value will not be by quarter.

Hope this helps.

Former Member
0 Kudos

I agree that the last example wouldn't work with the IF-check...but if i remove the IF-statement the functions still returns 0....

Former Member
0 Kudos

I agree with that and it is bound to happen that way even if you dont have if statement.

The reason is foreach quartal.

percent values are not by quarter.

This would only work if you find # against 0calquarter in the cube along with percent values.

Hope this clears your doubt.

Former Member
0 Kudos

but there is a # for 0CALQUARTER in my cube with a percent value...and i receive a value for PVALUE before i enter the loop...just its lost when i enter the loop.

Former Member
0 Kudos

can you give the dataset of percent value that is stored in the cube? i mean the accompanying characteristics.

Former Member
0 Kudos

sure.....

the cube with percent-values looks like this....

0SEM_POSIT / 0VERSION / YA_MIMPTY / 0DAY / 0CALQUARTER / 0AMOUNT / 0PERCENT / 0QUANTITY

0000000000000500 001 I 03.07.2007 0,00 30,000 0,000

0000000000000500 001 S 03.07.2007 0,00 30,000 0,000

0000000000000500 001 T 03.07.2007 0,00 40,000 0,000

the cube with amount-values looks like this....

0SEM_POSIT / 0VERSION / 0DAY / 0CALQUARTER / 0AMOUNT

0000000000000700 001 03.07.2007 20074 5.737,87

0000000000000700 003 03.07.2007 20074 5.737,87

0000000000000700 002 03.07.2007 20074 5.737,87

Former Member
0 Kudos

for what characteristics do you have restrictions in level/filter?

Former Member
0 Kudos

on my planing level i have the following restrictions:

0SEM_POIST: 500, 700

0DAY: Variable with today-value

0VERSION: 1,2,3

Planning-Area: both cubes

Filter inside the function:

0VERSION: 1

0DAY: Variable with today-value

Former Member
0 Kudos

do you have percent and amount in two different cubes? if so bring in info provider characteristic in the fields to be changed.

Also just another thought,

Did you try this,

foreach quartal.

pvalue = {percent,.............}.

{amount1,......} = {amount2,.....} * pvalue.

endfor.

Former Member
0 Kudos

I tried all the points u mentioned...but without success. When i debug the loop i can see that first the value of variable PVALUE is set to 30. Later before the calculation the value changes to 0.....

Former Member
0 Kudos

in side the for loop when u have ,

pvalue = {percent,........}.

do you get 30?

and when u process this statement

{amount1,.....} = {amount2,.......} * pvalue.

does pvalue become zero now?

Former Member
0 Kudos

during the first loop PVALUE is 30, but because the first QUARTER is # there is no value for amount. After the first loop PVALUE is set to 0 and the first QUARTER is 20074. For this QUARTER there is an amount of 5234...but the overall result is zero again, because PVALUE is 0...

Former Member
0 Kudos

can you put the full code you have written here please?