cancel
Showing results for 
Search instead for 
Did you mean: 

Fox Formula Calculation

0 Kudos

Dear Experts,

I have a requirement to calculate revenue using Price and Quantity for each material,month,sales org combination using FOX formula.

Problem is that price and quantity will be in different rows in the cube.

A new record with version C has to be created with a row for each combination also populated with Price, quantity and revenue.

Could you please advise how this can be achieved.

Accepted Solutions (0)

Answers (2)

Answers (2)

lucas_costa3
Active Contributor

What have you tried so far?

former_member186338
Active Contributor

"Do my job" question 🙂

0 Kudos

Hi Lucas,

Thanks for your response 🙂

I got it done trying in different ways in FOX. Below is the code i wrote and it worked.

Please review and advise if i can improve it.

CODE:

DATA CMONTH TYPE 0CALMONTH.

DATA CURRY TYPE 0CURRENCY.

DATA L_CURRY TYPE 0CURRENCY.

DATA L_UNT TYPE 0UNIT.

DATA UNT TYPE 0UNIT.

DATA VERS TYPE 0VERSION.

DATA ZVERS TYPE 0VERSION.

DATA QVERS TYPE 0VERSION.

DATA MID TYPE Z_MID.

DATA SORG TYPE Z_SORG.

DATA PRICE TYPE F.

DATA QTY TYPE F.

DATA REV TYPE F.

QVERS = 'B'.

ZVERS = 'C'.

FOREACH UNT.

IF NOT UNT IS INITIAL.

L_UNT = UNT.

FOREACH CURRY, VERS IN REFDATA.

IF NOT CURRY IS INITIAL AND VERS = 'A'.

PRICE = { Z_PRC, CURRY, #, VERS }.

QTY = { Z_QTY, #, L_UNT, QVERS }.

L_CURRY = CURRY.

{ Z_PRC, L_CURRY, L_UNT, ZVERS } = PRICE.

{ Z_QTY, L_CURRY, L_UNT, ZVERS } = QTY.

{ Z_REV, L_CURRY, L_UNT, ZVERS } = PRICE * QTY.

PRICE = 0.

QTY = 0.

ENDIF.

ENDFOR.

ENDIF.

ENDFOR.

lucas_costa3
Active Contributor
0 Kudos

Well if the code is working, all good then.