cancel
Showing results for 
Search instead for 
Did you mean: 

Fox Formula - Calculate with Time-Characteristics

0 Kudos

Hello,

I have the requirement to calculate with the fiscal period.

Simple compute: average_keyfigure = ytd_keyfigure / fiscal_period.

Fox formula says that fiscal_period is not the type F. So calculating ist not possible.

How can a divide with the fiscal period?

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

One option is to run a foreach for the periods and increment a counter inside the loop.

Will look like this,

DATA COUNTER TYPE I.

COUNTER = 0.

FOREACH PERIOD.

COUNTER = COUNTER+1.

ENDFOR.

Later you can use this counter value for mathematical operation.Will this work for you?

0 Kudos

When you do it like this, the FOREACH-loop only loops over existing data records. May be there is no data record for period July, the counter counts one period less.

And that's the reason why I have to divide by the actual period.

In german: Die erste Methode ermittelt einen Mittelwert (es werden nur Perioden mit Werten berücksichtigt). Die gewünschte Methode soll den echten Durchschnitt bis zum letzten Datensatz ausgeben, auch wenn nicht in jeder davorliegenden Periode ein Datensatz vorhanden ist.

Sorry, but in german it's ever easier.

Former Member
0 Kudos

Use the VARI function then:

fiscal period = VARV(...)

Integer = VARI(0FISCPER3,1,fiscal period).

The VARI function returns an integer.

(I don't have access to the system now so I cannot check the syntax).

PS for the foreach loop use FOREACH 0FISCPER IN SELECTION, then it will loop over all possible values.

D

Former Member
0 Kudos

Hi,

Here some sample code which should help you further calculate with time characteristics

D

DATA LV_COUNTER TYPE I.

DATA LV_PERIODS TYPE I.

DATA LV_PERIOD_FROM TYPE 0FISCPER3.

DATA LV_PERIOD_TO TYPE 0FISCPER3.

DATA LV_FISCPER3 TYPE 0FISCPER3.

DATA LV_DISTR_AMOUNT TYPE F.

*TRANSFER VARIABLE PERIOD FROM AND PERIOD TO INTO LOCAL VARIABLE AND COUNT INTERVAL OF PERIODS.

BREAK-POINT.

LV_PERIODS = VARC(0I_PER3).

LV_PERIOD_FROM = VARI(0I_PER3,1).

LV_PERIOD_TO = VARI(0I_PER3,LV_PERIODS).

  • DO TOP-DOWN DISTRIBUTION FOR ALL ADJUSTMENT VALUES ON PERIOD = #

LV_COUNTER = 0.

LV_DISTR_AMOUNT = { 0G_QVVGRM,#} / LV_PERIODS.

DO.

LV_FISCPER3 = TMVL(LV_PERIOD_FROM,LV_COUNTER).

{ 0G_QVVGRM, LV_FISCPER3} = { 0G_QVVGRM, LV_FISCPER3} + LV_DISTR_AMOUNT.

{ 0G_QVVGRM,#} = { 0G_QVVGRM,#} - LV_DISTR_AMOUNT.

LV_COUNTER = LV_COUNTER + 1.

IF LV_FISCPER3 >= LV_PERIOD_TO.

EXIT.

ENDIF.

ENDDO.

Former Member
0 Kudos

Hi,

1) you can use the VARI function to make the difference between two posting periods.

2) The following statement can also be used to transfer values to another infoboject:

DATA LV_STRING TYPE STRING.

DATA VAR_A TYPE ...

DATA VAR_B TYPE ...

LV_STRING = VAR_B.

VAR_A = LV_STRING.

VAR_A and VAR_B have a different type.

D

0 Kudos

Hi and thank you for answer,

but it dosn't work:

My coding:

DATA PER TYPE 0FISCPER3.

DATA ABC TYPE STRING.

DATA PERIODEN TYPE F.

FOREACH PER.

ABC = PER.

PERIODEN = ABC.

...

The statement PERIODEN = ABC is incorrect, SAP says: Type I and Type STRING not be the same.