on 01-10-2014 8:20 AM
Dear Expert,
I need to setup the calculated characteristics for beloe scenario
The first MIC contains the measured temperature.
The second MIC shoud calculate, based on the temperature of the first MIC,
SAP Standard accepts IF, THEN, ELSE functions in formulas.
My problem is: How can I calculate in one forumla the desribed problem (how has the formula to be set up in detail):
If the temperature is between 12.5°C to 16.5°C then give back the value 8.05
If the temperature is between 16.6°C to 19.5°C then give back the value 8.03
If the temperature is between 19.6°C to 21.0°C then give back the value 8.02
If the temperature is between 21.1°C to 23.5°C then give back the value 8.01
If the temperature is between 23.6°C to 27.5°C then give back the value 8.00
If the temperature is between 27.6°C to 32.5°C then give back the value 7.98
Please help to suggest the ways.
Regards,
Sandeep
It can be done. The question is will it fit in the two 60 character fields that SAP gives you for the formula. it might!
Here is the full help text which clearly states this works with standard SAP. You will just have to get in your development system and try it out. Will probably need to nest your if/then statements.
The function module CHECK_FORMULA checks the syntax of a Literal or Variable formula. It accepts:
Example:
Operands
The following operands are allowed:
Functions
The FM supports the following functions:
ABS | absolute value |
Example: FORMULA = ABS(-2) | |
result: 2 | |
NOT | negation |
Example: FORMULA = IF NOT(2<3) THEN (5*6) ELSE (5-7) | |
result: -2 | |
SIN | sine function |
Example: FORMULA = SIN(PI/2) | |
result: 1 | |
COS | cosine function |
Example: FORMULA = COS(0) | |
result: 1 | |
TAN | tangent function |
Example: FORMULA = TAN(2*PI) | |
result: 0 | |
LOG | logarithm to base e (natural logarithm) |
Example: FORMULA = LOG(2.7182746352) | |
result: 1 | |
EXP | exponential function to base e |
Example: FORMULA = EXP(1) | |
result: 2.7182746352 | |
SQRT | square root function |
Example: FORMULA = SQRT(144) | |
result: 12 | |
ROUND | round to a whole number |
Example: FORMULA = ROUND(3.14159) | |
result: 3 | |
TRUNC | truncate; the whole number part of a real number |
Example: FORMULA = TRUNC(5/3) | |
result: 1 | |
MOD | modulus function |
Example: FORMULA = 10 MOD 3 | |
result: 1 | |
DIV | whole number part of a division |
Example: FORMULA = 10 DIV 3 | |
result: 3 |
Operators
The operators are classified in 6 priority groups. The operators in group 0 have the lowest priority and those in group 6 the highest.
The operators are:
group 0:
AND | logical AND |
OR | logical OR |
group 1:
= | equals |
<>, >< | not equals |
< | less than |
> | greater than |
<=, =< | less than or equal to |
> | greater than |
=>, >= | greater than or equal to |
group 2:
+ | plus value (of an expression) |
- | minus value (of an expression) |
+ | addition |
- | subtraction |
group 3:
* | multiplication |
/ | division |
group 4:
** | exponent |
group 5:
ABS | absolute value |
NOT | negation (of a logical expression) |
group 6: all other functions.
user-defined FORMULAs
You can define functions in a table like TFKT and use them as well as standard functions. The function name is the table key. The table and function names (separated by a colon) are specified in calls.
Example
The FORMULA PI*R**2 is in the table TFKT under the function name circlearea. It is called with FORMULA = TFKT:circlearea(...)
User-defined functions can be nested.
Example:
The expression PI*R**2 is defined as the function circlearea. The function cylinder can now be defined as cylinder = TFKT:circlearea*H.
If a user group needs another table than TFKT (e.g. to structure the key or include user fields), the reference table TFKT should be copied. User functions can be inserted from position 79.
Tables used to store FORMULAs must have a key length of 13 and a function length of 65.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Jim
If I remember correctly, (always a problem!), I tried to use an AND statement within the IF-THEN-ELSE statement and I didn't have any success with that. Or it had a problem using nested IF-THEN's. Can't remember which one.
I.e. you could do
IF CO0010 < 10 then 5.0 Else 6.0
But I don't think you can do
IF ((CO0010 <10) AND (CO0010 >= 5)) then 6.0 Else
IF ((CO0010 <15) AND (CO0010 >= 10)) then 11.0 Else
IF ((CO0010 <20) AND (CO0010 >= 15)) then 16.0 etc..etc..
I think Karen's answer to use the FM would be he best.
Craig
Jim,
Help me out in understanding one thing. When I first saw this query, I couldn't think of a solution except using FM. Then Karen and You also seemed going for it, the FM. I didn't go through the whole content of yours (as I'm using cell phone currently). Did you also suggested a solution via FM ?? Or without it using standard SAP?
ntn
I was suggesting standard SAP, but to be honest i've never tried nesting IF/THEN statements in the MIC. Maybe if i get some spare time one these days (if that exists anymore) i'll play around with it.
I would suggest Sandeep to give the standard a whirl, and if it doesn't pan out, get with an ABAP'er and make a Z formula.
Dear All,
Thanks for your reply,
I tried through standard SAP but as per Craig suggestion it work for one line formula not all multiple option also i am not able to put range e.g between 12.5°C to 16.5°C in formula.it work for <.>= etc.
I will now check with developer but please let me know if any other way to get it done
I am open for other ideas then the IF, THEN, ELSE function. It only must be possible to get out the correct value by an automated process.
Regards,
Sandeep
Hi Sandeep
This is only possible for one line formula by making key in table TFKT and formula text there. There is limit so you cann't beyond that. So it better to use formula parameter DO. Change the logic of function module which is attached to this parameter according to your requirement.
Regards'
Manish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sandeep
As per my knowledge standard SAP won't allow us to write like this formulas. For this we can use User exits: EXIT_SAPLQEEM_015 or EXIT_SAPLQEEM_011 to fulfill this requirements.
Regards
kesava
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't think this can be done by standard SAP route. You may need to use a FM to get this requirement done. Consult your abap person for this.
KJ
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Ru looking for formula or how to write the formula???
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
7 | |
7 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.