02-15-2009 8:27 AM
Hi all.
I'm looking for a FM that checks if a number is a decimal format or an integer format.
If it's not possible, a FM that splits a number to its 2 different parts will do it also .. meaning input 523.12 will be splitted to 523 and 12.
Thanks in advance,
Rebeka
02-15-2009 12:22 PM
I am not 100% clear on your requirement, but does using the MOD function supply the right answer?
DATA:
g_1(16) TYPE p DECIMALS 9 VALUE '1500000.1',
g_2(16) TYPE p DECIMALS 9.
g_2 = g_1 MOD 1.
IF g_2 NE 0.
WRITE 'decimal'.
ELSE.
WRITE 'int'.
ENDIF.
Sorry, just noticed that Gunpreet had posted a similar solution.
Edited by: Jerry Coleman on Feb 15, 2009 7:23 AM
02-15-2009 8:31 AM
store ur number in a char string, then
use this check
if v_str cp '*.*'
if the condition is true then the number is in decimal format else its in integer format.
then for splitting use SPLIT keyword.
SPLIT v_str AT '.' into v_left v_right.
кu03B1ятu03B9к
Edited by: kartik tarla on Feb 15, 2009 2:04 PM
Edited by: kartik tarla on Feb 15, 2009 2:06 PM
02-15-2009 8:37 AM
It's not correct cause in some of our international offices the decimals splitter is ',' (Germany, Switzerland and the like), meaning that 1,500,230.80 will be at these countries 1.500.230,80.
That's exactly the reason that I search for a std FM.
Thanks,
Rebeka
02-15-2009 8:41 AM
Well i think fms must be there but i'm not sure if they would take care of currency specific settings and split accordingly.
02-15-2009 10:57 AM
Hi,
SPLIT will only work in case on character or string type
try these codes:
Parameters: P_Num type p decimals 2 default '502.53'.
data:w_num type i.
W_num = p_num mod 1.
If w_num is '0' entered number has no decimal part.
else w_num = 53.(decimal part)
regards,
Gurpreet
02-15-2009 11:54 AM
Hi,
check this:
http://abaplovers.blogspot.com/2008/04/sap-abap-determining-attributes-of-data.html
Best regards
02-15-2009 12:22 PM
I am not 100% clear on your requirement, but does using the MOD function supply the right answer?
DATA:
g_1(16) TYPE p DECIMALS 9 VALUE '1500000.1',
g_2(16) TYPE p DECIMALS 9.
g_2 = g_1 MOD 1.
IF g_2 NE 0.
WRITE 'decimal'.
ELSE.
WRITE 'int'.
ENDIF.
Sorry, just noticed that Gunpreet had posted a similar solution.
Edited by: Jerry Coleman on Feb 15, 2009 7:23 AM