2007 Mar 13 10:28 AM
Hi,
I am having a value as '6009.12300 ML' belongs to type C.
Now i don't want the zeroes after decimal such as 6009.123 ML .
how cud i do this?
i tried search ,split,shift,trailing zeroes but could nt get it?
Thanks,
Ponraj.s.
2007 Mar 13 10:30 AM
Hello,
data: wa_input type i,
wa_output type i.
wa_input = '1.000'.
CALL FUNCTION 'ROUND'
EXPORTING
INPUT = wa_input
IMPORTING
OUTPUT = wa_output
EXCEPTIONS
INPUT_INVALID = 1
OVERFLOW = 2
TYPE_INVALID = 3
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
write:/ wa_output.
Regards,
Vasanth
2007 Mar 13 10:30 AM
Hello,
data: wa_input type i,
wa_output type i.
wa_input = '1.000'.
CALL FUNCTION 'ROUND'
EXPORTING
INPUT = wa_input
IMPORTING
OUTPUT = wa_output
EXCEPTIONS
INPUT_INVALID = 1
OVERFLOW = 2
TYPE_INVALID = 3
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
write:/ wa_output.
Regards,
Vasanth
2007 Mar 13 10:38 AM
HI vasanth.. In your program You have taken <b>wa_input as type i</b>.
and u are giving value '1.000'.
the value will be converted there it self as 1 only ,integer doesn't tale decimals ,before going to call the function module it will be converted as 1..
I think you should change the data type of wa_input
Regards Rk
2007 Mar 13 10:33 AM
hi,
just execute this. u will get the idea.
data: a(16) type p decimals 4 .
data: b(16) type p decimals 2 .
data: c(30) .
a = '56.4400'.
write:/ a .
move: a to b .
write:/ b .
write a to c decimals 2 .
write:/ c .
the results will be
a = 56.4400
b = 56.44
c = 56.44Regards
Anver
2007 Mar 13 10:41 AM
Hi Vasanth,
I've tried the function module directly in se37, am not getting output. only exception ,what we have to pass in the field decimal?
Hi Aversha,
My value contains like this '5134.4500 ML' also 3215.642000 GM' .no.of zeroes is not constant so i need like this
'5143.45 ML' and '3215.624 GM'.I hope ur logic wont work with this.
any other idea?
Thanks,
Ponraj.s.
2007 Mar 13 10:39 AM
data : text1(6),
text2(6),
text(13) type c value '325.2300'.
split text at '.' into text1 text2.
shift text2 right deleting trailing '0'.
shift text2 left deleting leading space.<may be spaces>
clear text.
concatanate text1 text2 into text separated by '.'.
regards
shiba dutta
2007 Mar 13 10:42 AM
Execute teh code
data : val(20) type c value '6009.12300 ML',
v1(15) type c,
v2(6) type c.
data : in(10) type c,
dec(6) type c, "increase this for ur need
final(20) type c.
*write:/ val .
split val at ' ' into v1 v2.
*write:/ v1 .
*write:/ v2.
*
in = trunc( v1 ).
*write:/ in.
dec = FRAC( V1 ). "this will eliminate zeros if any
*write:/ dec.
concatenate in dec+1(5) into v1.
concatenate v1 v2 into final separated by space.
write:/ final."ur final o/p
see if this is working for you .
regards,
vijay
2007 Mar 14 8:02 AM
2007 Mar 22 1:51 PM
yes, my query is resolved...
sorry for poiting late.please regret...
2007 Mar 13 11:22 AM
Hi Ponraj Sundarraj,
You can go through the following code.
DATA: lv_string(20) VALUE '6009.12300 ML'.
DATA: lv_length TYPE i.
DATA: lv_len TYPE i.
DATA: lv_char.
lv_length = strlen( lv_string ).
lv_length = lv_length - 4.
WHILE lv_length > 0.
lv_char = lv_string+lv_length(1).
IF lv_char EQ '0'.
lv_len = lv_length + 1.
lv_stringlv_length = lv_stringlv_len.
ELSE.
EXIT.
ENDIF.
lv_length = lv_length - 1.
ENDWHILE.
WRITE: lv_string.
Regards,
Balakrishna.N
2007 Mar 13 11:26 AM
Hi,
I tested the following code segment, it works well to suit your requirement.
Just look at the code.
DATA C(20) VALUE '6009.12300 ML'.
DATA: LEN TYPE I,
FLAG TYPE I.
LEN = STRLEN( C ).
DO LEN TIMES.
LEN = LEN - 1 .
IF ( C+LEN(1) EQ '0' ) .
C+LEN(1) = ' ' .
FLAG = 1 .
ELSE.
IF FLAG = 1 .
EXIT .
ENDIF .
ENDIF .
ENDDO.
CONDENSE C NO-GAPS.
WRITE C.
Reward if helpful.
Regards,
Sandhya
2007 Mar 22 1:53 PM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |