2022 Apr 22 6:14 AM
CODE# 1
IF GROSS_PRICE <> '0,00' AND NET_PRICE <> '0,00' .
"PRINT SOMETHING HERE"
CODE# 2
IF GROSS_PRICE <> '0' AND NET_PRICE <> '0' .
"PRINT SOMETHING HERE"
Will these code have different results?
CODE# 1
IF GROSS_PRICE <> '0,00' AND NET_PRICE <> '0,00' .
"PRINT SOMETHING HERE"
CODE# 2
IF GROSS_PRICE <> '0' AND NET_PRICE <> '0' .
"PRINT SOMETHING HERE"
Will these code have different results?
2022 Apr 22 6:58 AM
SAP inside format for decimal is the dot, not the coma. Did you try with a beautiful dot ?
2022 Apr 22 7:14 AM
You are comparing characters, not numbers, so "decimal places" don't mean anything.
If gross_price and net_price have numeric data types, ABAP will convert characters into numbers before comparing, and expects a valid number inside the quotes, i.e. comma is invalid (see ABAP documentation).
Of course, if they have numeric data types, you should write:
IF GROSS_PRICE <> 0 AND NET_PRICE <> 0.
"PRINT SOMETHING HERE"
2022 Apr 22 7:16 AM
Nice interview question by the way. I expect the interviewer to hear how comfortable you are with talking about ABAP concepts, not to give the "right answer".
2022 Apr 22 8:01 AM
even with ' it works
DATA montant TYPE kbetr.
montant = 10 / 3.
IF montant GT '3.2'.
WRITE 'Cassis'.
ENDIF.
IF montant LT '3.34'.
WRITE 'Pomme'.
ELSE.
WRITE 'Poire'.
ENDIF.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |