2009 May 06 2:30 PM
Hi all,
I am having value A which is defined in deciamls.
A = '1.765'.
i want to move the value to B only the digit one.
what B should be defined oF? how many values before the decimal i need to move that many values to b.
generally not more that 2 char A is having before decimal.
A = ' 12.375 ' B = 12
A = 8.65' b = 8.
how can we achieve?
regards
sas
2009 May 06 2:37 PM
>
> Hi all,
>
> I am having value A which is defined in deciamls.
>
> A = '1.765'.
>
> i want to move the value to B only the digit one.
>
> what B should be defined oF? how many values before the decimal i need to move that many values to b.
>
> generally not more that 2 char A is having before decimal.
>
> A = ' 12.375 ' B = 12
>
> A = 8.65' b = 8.
>
> how can we achieve?
>
> regards
> sas
A = FLOOR( A ) .
B = A .
Hi all,
I am having value A which is defined in deciamls.
A = '1.765'.
i want to move the value to B only the digit one.
what B should be defined oF? how many values before the decimal i need to move that many values to b.
generally not more that 2 char A is having before decimal.
A = ' 12.375 ' B = 12
A = 8.65' b = 8.
how can we achieve?
regards
sas
2009 May 06 2:35 PM
field1 type p decimals 0...
field1 = '12.22'
value of field will be 12.....
2009 May 06 2:36 PM
I this case, declare b as type i.
b = floor(a).
b will have the value that you wanted.
Hope it helps.
2009 May 06 2:37 PM
>
> Hi all,
>
> I am having value A which is defined in deciamls.
>
> A = '1.765'.
>
> i want to move the value to B only the digit one.
>
> what B should be defined oF? how many values before the decimal i need to move that many values to b.
>
> generally not more that 2 char A is having before decimal.
>
> A = ' 12.375 ' B = 12
>
> A = 8.65' b = 8.
>
> how can we achieve?
>
> regards
> sas
A = FLOOR( A ) .
B = A .
2009 May 06 2:42 PM
HI PAWAN
FLOOR is fine or TRUNC keyword is fine?
please any one answer before i relase my transport
Regards
sas
2009 May 06 2:44 PM
I guess in your case FLOOR would do.
Hey. I dont see a keyword called TRUNC. Are you sure about that?
Thanks,
Babu Kilari
Edited by: Babu Kilari on May 6, 2009 7:23 PM
2009 May 06 6:26 PM
>
> I guess in your case FLOOR would do.
>
> Hey. I dont see a keyword called TRUNC. Are you sure about that?
>
> Thanks,
> Babu Kilari
>
> Edited by: Babu Kilari on May 6, 2009 7:23 PM
Hi Babu,
Thanks for your response. If u take F1 help on FLOOR u would observe the TRUNC just down the FLOOR word.Just make a note
My question is for this scenario what best suits FLOOR or TRUNC. sap help is not clear enough to understand is there any one here....
PS: Transport stoped
Regards
sas
2009 May 07 4:43 AM
Hey Sas,
I could see that now. Thanks for the information yaar. If you see that table, Return value description says that trunc function gives you the Value of the integer part of the argument passed. So, this can also be used for your purpose.
But, when you consider the floor function it does the same functionality but generally it is used in a scenario where you are trying to round off the value to the closest integer. Ciel function works in a different way as it round offs the value to the highest integer. So, these two functions depend on the decimal part of the argument that you pass.
So, In your case Floor/Trunc gives you the same result.
Note: The actual difference come in to picture if you are passing the negative values as an argument to the function. For example,
b=FLoor(-5.45) would give you -6
b=Trunc(-5.45) would give you -5
Now you can decide which one to use.
If you are sure that you are not passing negative values, then use either
If you are not sure, then use TRUNC.
Hope this clears the dilemma....
Thanks,
Babu Kilari
Edited by: Babu Kilari on May 7, 2009 9:15 AM
Edited by: Babu Kilari on May 7, 2009 9:18 AM
2009 May 07 6:32 AM
Thanks for CRYSTAL clear response Babu.
Its pretty much clear now...actually i am passing the months value to this which are coming in decimals just to take the value...so Months are always +ve i think either can work
Regards
sas
2009 May 06 2:45 PM
2009 May 06 3:28 PM
>
> hi,
>
>
data : a type i value '1.765', > b type i, > c type i. > split a at '.' into b c. > write :/ b , c.>
> Thanks and regards
That doesn't even syntax check!
"A" must be a character-like data object (data type C, N, D, T, or
STRING) field string).
2009 May 07 6:41 AM
Hi MAtt,
I regret posting that kind of a reply. I apologize for my mistake.
2009 May 06 2:50 PM
Hi,
Check this
data: v_data1 type p decimals 3 value '12.860',
v_char1 type char20,
v_char2 type char20,
v_char3 type char20.
write v_data1 to v_char1.
split v_char1 at '.' into v_char2 v_char3.
write:/ v_char2, v_char3.In the above v_char2 holds the digit value
thanks\
Mahesh
2009 May 06 3:45 PM
DATA: a(10) TYPE c ,
lv_num1(10) TYPE c,
lv_num2 TYPE c.
a = '12.12'.
SPLIT a AT '.' INTO lv_num1
lv_num2.
write: lv_num1.
Edited by: BrightSide on May 6, 2009 3:59 PM
2009 May 06 6:03 PM
Hi,
it will resolve your issue
data: a type p decimals 2 value '8.65',
b type i.
b = TRUNC( a ).
Regards,
Peranandam
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |