cancel
Showing results for 
Search instead for 
Did you mean: 

FOX Formula

Former Member
0 Kudos

Hello experts.

I'm trying to do a formula fox to calculate a cost center that its equal to responsible cost center, but it gives an error. Could anyone help me?

Here's my code:

DATA TXAMT_AI TYPE F.

DATA TXAMT_AFT TYPE F.

DATA CCUSTO TYPE 0COSTCENTER .

DATA CCRESP TYPE 0RESP_CCTR.

  • atribuição de valores às variáveis

TXAMT_AI = VARV('NCOAM01').

TXAMT_AFT = VARV('NCOAM02').

CCRESP = OBJV().

CCUSTO = CCRESP.

                  • ACTIVOS INTANGÍVEIS ********************

  • amt de AI - despesas instalação

{#,CCUSTO,6631000000,#} = ( { #,#,4310000000,CCRESP} * TXAMT_AI) / 100.

There's an registry with responsible cost center and I want to calculate the cost center...

Thanks in advance.

Vitor Ramalho

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Vitor,

OBJV() indeed can only be used if the characteristic is not be changed. What you can do is the following:

DATA TXAMT_AI TYPE F.

DATA TXAMT_AFT TYPE F.

DATA CCUSTO TYPE 0COSTCENTER .

DATA CCRESP TYPE 0RESP_CCTR.

DATA LV_STRING TYPE STRING.

  • atribuição de valores às variáveis

TXAMT_AI = VARV('NCOAM01').

TXAMT_AFT = VARV('NCOAM02').

FOREACH CCRESP.

LV_STRING = CCRESP.

CCUSTO = LV_STRING.

                  • ACTIVOS INTANGÍVEIS ********************

  • amt de AI - despesas instalação

{#,CCUSTO,6631000000,#} = ( { #,#,4310000000,CCRESP} * TXAMT_AI) / 100.

ENDFOR.

With the foreach loop you will loop over all existing combinations of CCRESP (for which plan data exists) in your plandata.

Let me know this works.

regards

D

Former Member
0 Kudos

Thanks for the tip by the way Manyak!

Former Member
0 Kudos

Hi Dries.

It didn't work.

Do you have any other idea?

Thanks.

Vitor Ramalho

Former Member
0 Kudos

Hi,

did you get an error or the function did not provide the correct result. For the latter, please debug your function by adding:

1) break-point. in your FOX

2) defining a planning sequence and creating a selection variant

3) run SE38 and program rspls_plseq_execute. -> hit execute and then choose the planning sequence with the variant created in 2). Check what goes wrong.

regards

D

Former Member
0 Kudos

Hi Dries.

The problem it was on the foreach. It must be like this:

FOREACH ORDEM, CC, CCRESP.

Thanks a lot for your help.

Vitor Ramalho

Answers (2)

Answers (2)

Former Member
0 Kudos

"Isn't the responsible cost center an attribute of cost center"

You can try this if you dont use the same object to store data of cost centre and responsible cost centre.

Ravi Thothadri

Former Member
0 Kudos

Hi,

what is your error?

please note that

TXAMT_AI and TXAMT_AFT should be of the same type as NCOAM01. Otherwise you get error that the local variable has a wrong data type.

TXAMT_AI = VARV('NCOAM01').

TXAMT_AFT = VARV('NCOAM02').

grtz

D

Former Member
0 Kudos

ALso

CCRESP And CCUSTO should be of the same type because of the following statement:

CCUST0 = CCRESP

grtz

D

Former Member
0 Kudos

Hello Dries.

Thats the error.

But it's also what I want to do. I want to create a new registry with the CCUSTo equal to CCRESP knowing that they are of different types. There's a way to do that??

Thanks.

Vitor Ramalho

P.S. Points wil be regarded.

Former Member
0 Kudos

Hi,

for time related characteristics there are work-arounds with TMVL. However in your case, I'm not aware of a work around via FOX two totally independent characteristic. An exit function can always provide a solution of course.

One remark: Isn't the responsible cost center an attribute of cost center. If so, you can try ATRV of ARTVT functions.

regards

D

Former Member
0 Kudos

Hi Vitor,

Are you sure the error you have is in the statement CCUSTO = CCRESP.? Do you get an error while running the function or while checking the syntax? Can you specify the exact error message?

The two infoobjects on which you have created these variables (0COSTCENTER, 0RESP_CCTR) have the same data type so I am not really sure why this should not work. I have used it in Integrated Planning and this kind of statement works.

You can try creating a variable of type STRING and do the below:

STR = CCRESP.

CCUSTO = STR.

Former Member
0 Kudos

Hi Mayank.

I get the error when i'm checking the syntax, and your'e right, the error occours because of the statement CCRESP = OBJV().

The error is "Formula error: Type 0RESP_CCTR is not allowed for the function".

I'm working with BPS.

Could you help get a solution?

Thanks in advance.

Vitor Ramalho

Message was edited by:

Vitor Ramalho

Former Member
0 Kudos

Hi,

I think your problem is evident. The characteristic 0RESP_CCTR is marked in your planning function as 'to be changed'. OBJV() can be used only for characteristics which are not marked for 'to be changed'.