‎2006 Jun 06 6:31 AM
Hi..
I am doing some calculations in my code to get a value in a variable,Now, I
want to check whether that variable is having a decimal or not.
If it is having a decimal ie. it is a number like 1.7485, then I need to
initialize this variable.
Please tell me how shall I proceed?
Thanks
‎2006 Jun 06 6:36 AM
Use FRAC which will give you the decimal part of the input parameter.
Then you can decide to initialize it.
Regards,
Ravi
‎2006 Jun 06 6:50 AM
either use FRAC or pass it some string and use
if str CP '.' .
str = 0.
endif.
reward points if it helps
regds
gunjan
‎2006 Jun 06 6:37 AM
Hi,
I assume that the variable 1.7845 is an internal table field. Now declare two more variable in your internal table say itab-var & itab-decimal.
Now loop the internal table and split the variable at the decimal point.
loop at itab.
split itab-var at '.' into var decimal.
modify itab transporting var decimal
endloop.
Now var field will contain values before decimal points and decimal field will contain values after decimal points.
With this you can once again loop the internal table and initialize the varaiable.
loop at itab.
if itab-decimal ne space.
clear itab-fieldname.
modify itab transporting fieldname.
endif.
endloop.
Lakshminarayanan
P.S. Mark all helpful answers for points
‎2006 Jun 06 7:27 AM
check out the FM: SWA_DETERMINE_DECIMALS
If there are no decimal places, the return value will be zero.
Plz reward points if this helps!!
Thanx,
Rajeev
‎2006 Jun 06 7:27 AM
Hi Subhash,
You can do this using <b>FRAC</b> which returns Decimal part of the given number as follows:
For Ex:
DATA: M TYPE F VALUE '-3.5',
D TYPE P DECIMALS 1.
D = FRAC( M ).
Result:D = '-0.5'
and can initialize this variable.
<b>Kindly reward if helpful.</b>
Regards,
Shakuntala
‎2006 Jun 06 7:47 AM
Hi Subhash,
You can do this using <b>FRAC</b> which returns Decimal part of the given number as follows:
For Ex:
DATA: M TYPE F VALUE '-3.5',
D TYPE P DECIMALS 1.
D = FRAC( M ).
Result:D = '-0.5'
and can initialize this variable.
<b>Kindly reward if helpful.</b>
Regards,
Shakuntala