Skip to Content
0
Former Member
Mar 03, 2011 at 05:30 PM

FOX Formula - loop in loop - populating Key Figure value

54 Views

Hello

Let me share the scenario:

I declare the fiscal year / period as a constant (it will be current fiscal period in the future). I find the previous period. Then I search for a value of a Key Figure YSTCK for this period. So far works fine. Than if found I would like to populate this value for every future fiscal year / periods. So I create loop in the loop. No success. In debugger I can see that the value of my Key Figure disappears from the variable.

There are single values of this Key Figure for every Fiscal year / period.

My code has been attached below.

Hope somebody is able to help.

The idea was to make a loop at every fiscal year / period and when the proper one (previous than declared) is found in the cube, read the value and start another loop, populating the values.

Please, take a look.

Thank you in advance.

A

DATA S_FISCPER TYPE 0FISCPER.

DATA S_FISCYEAR TYPE 0FISCYEAR.

DATA S_FISCPER3 TYPE 0FISCPER3.

DATA Y_FISCPER TYPE 0FISCPER.

DATA X_FISCPER TYPE 0FISCPER.

DATA D_FISCPER TYPE 0FISCPER.

DATA D_FISCYEAR TYPE 0FISCYEAR.

DATA D_FISCPER3 TYPE 0FISCPER3.

DATA Z_KF TYPE F.

Y_FISCPER = 2010004.

X_FISCPER = TMVL(Y_FISCPER,-1).

FOREACH S_FISCPER.

S_FISCYEAR = SUBSTR(S_FISCPER,0,4).

S_FISCPER3 = SUBSTR(S_FISCPER,4,3).

IF S_FISCPER = X_FISCPER.

Z_KF = {YSTCK, S_FISCPER, S_FISCPER3, S_FISCYEAR}.

FOREACH D_FISCPER.

D_FISCYEAR = SUBSTR(D_FISCPER,0,4).

D_FISCPER3 = SUBSTR(D_FISCPER,4,3).

IF D_FISCPER > X_FISCPER.

{YSTCK, D_FISCPER, D_FISCPER3, D_FISCYEAR} = Z_KF.

ENDIF.

ENDFOR.

ENDIF.

ENDFOR.