Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Formula Variables in Report Painter- Syntac error in formula

Former Member
0 Kudos

Dear Experts,

I'm creating the report where I need to calculate annualized P&L. The formula is as follows : (P&L account/Period(variable ))*12

I need to capture the From_period, which is entered by the user on the selection screen when running the report and use it as a variable in the formula above. Example: If User insert From Period 3, then the formula should be *P&L accoun / 3 * 12*

I have tried so many different way but nothing seems to work. one of the ways i tried was:

In the general selection Im using set variable 6P-S-PERIOVB.CCSS for period which consists of variable V_PERIO and B_PERIO.

So Im trying to create a folowing formula:

IF 1 >= u2018PER_FRu2019 AND 1 <= u2018PER_TOu2019 THEN 1 ELSE 16

IF 2 >= u2018PER_FRu2019 AND 2 <= u2018PER_TOu2019 THEN 1 ELSE 16

Unfortunately I keep getting Syntac error in formula. Please help me I'm really desperate to solve this issue after 5 days of unlucky research.

Thank you in advance

Regards

Ernesta

1 ACCEPTED SOLUTION

Former Member
0 Kudos

IF 1 >= u2018PER_FRu2019 AND 1 <= u2018PER_TOu2019 THEN 1 ELSE 16

IF 2 >= u2018PER_FRu2019 AND 2 <= u2018PER_TOu2019 THEN 1 ELSE 16

If you're really comparing 1 to the literal 'PER_FR' or to 'PER_TO', then 1 will never equal 6 characters...will never be true.

From the above, I'm not sure just what you're trying to accomplish...

3 REPLIES 3

Former Member
0 Kudos

IF 1 >= u2018PER_FRu2019 AND 1 <= u2018PER_TOu2019 THEN 1 ELSE 16

IF 2 >= u2018PER_FRu2019 AND 2 <= u2018PER_TOu2019 THEN 1 ELSE 16

If you're really comparing 1 to the literal 'PER_FR' or to 'PER_TO', then 1 will never equal 6 characters...will never be true.

From the above, I'm not sure just what you're trying to accomplish...

0 Kudos

I think the formula I was applying was too complicated for what I wanted to achieve. Basically I need to capture the Period From number which is entered by the user on the selection screen before running the report and use this period in the formula to calculate annualized PnL.

Another formula that I used was. X001 / 'PER_FR' * 12. But still geeting the same error.

Even after I changed the variables to 1PERIV and 1PERIB, but still no luck Any suggestions how to solve the issue would be more than helpful.

Thank you

Regards

0 Kudos

so, I would use parameters.....

P_fr_MO(2) TYPE N DEFAULT '01',

p_fr_yr(4) type n default '2011'.

Then, to set my range, i would do something like....

data: lv_to_mon(2) type n,

lv_to_yr(4) type n.

if p_fr_mo eq '01'.

lv_to_yr = p_fr_yr. "12th month, same year...

else.

lv_to_yr = p_fr_yr + 1. "any other month puts us into next year.

endif.

case p_fr_mo.

when '01'.

lv_to_mon = 12. "always for 12 month period...

when others.

lv_to_mon = p_fo_no - 1. '''example 10/2010 to 09/2011.

endcase.

then concatenate the from and to variables into what format is needed to read the data...

on the other hand, if the user gives us from and to, we have a different problem....one then has to calculate what part of a year they have and create a factor for multiplying any data values....

for instance if user says Jan (01) to (03) March, then I know that to month - from month + 1 is the number of months I have....

then 12 / that number is the factor to multiply the results by....

example...

data : factor(5) type p decimals 2

months(3) type n.

if p_to < p_from. "adjust if I cross a year boundary....Oct to Jan becomes 13 - 10 + 1 or 4 months.

p_to = p_to + 12.

endif.

months = p_to - p_from + 1.

factor = 12 / months. " factor 12 /4 months = 3 times the values obtained = 1 year.

something like this....hope this is helpful to you.

Edited by: DaveL on Oct 18, 2011 6:24 PM