‎2006 Feb 17 4:43 PM
Hi,
I want to write a code in ABAP in such a way that I should get the output in the right side format.
Ex:
1200 - > 1,200
12000 - > 12,000
120000 -> 120,000
1200000 -> 1,200,000
12000000 -> 12,000,000
120000000 - > 120,000,000
.
.
In more generic way if the value is 'abcdefg' it should be a,bcd,efg . So it counts from behind and puts comma after three places and does this moving foward if there are other digits in the number.
Please help.
Thanks.
‎2006 Feb 17 5:05 PM
hI Tushar
data: val(10) type c,val1(10) type c.
data: len type i,cnt type i value 0.
val = '12000000'.
len = strlen (val).
while len ne 0.
if cnt eq 3.
concatenate ',' val+len(3) val1 into val1.
cnt = 0.
endif.
cnt = cnt + 1.
len = len - 1
endwhile.
if cnt ne 0.
concatenate val+0(cnt) val1 into val1.
endif.
write val1.
regards
kishore
there is small change
Message was edited by: Harikishore Sreenivasulu
‎2006 Feb 17 4:47 PM
Hi Tushar,
If your value is Currency then you can use :
Write Field Currency <Currency key Ex: 'USD'>. This will set all the comma formats base on coutry specific.
Lanka
‎2006 Feb 17 4:52 PM
You should just be able to do this by writing from a type P field to a character field.
<b>This way it will not show the decimal places.</b>
report zrich_0003.
data: value1(15) type c value '12000000000'.
data: value2(15) type c.
data: p(15) type p decimals 0.
p = value1.
write p to value2.
write:/ value1, value2..
Regards,
Rich Heilman
‎2006 Feb 17 4:51 PM
Hi Tushar,
If you define the variable or the internal table field refering to any standard currency field,you will get the way you want.
DATA: V_CURR LIKE VBAP-NETPR.
V_CURR = '1200000'.
WRITE:/ V_CURR CURRENCY 'USD'.
‎2006 Feb 17 4:55 PM
‎2006 Feb 17 5:05 PM
hI Tushar
data: val(10) type c,val1(10) type c.
data: len type i,cnt type i value 0.
val = '12000000'.
len = strlen (val).
while len ne 0.
if cnt eq 3.
concatenate ',' val+len(3) val1 into val1.
cnt = 0.
endif.
cnt = cnt + 1.
len = len - 1
endwhile.
if cnt ne 0.
concatenate val+0(cnt) val1 into val1.
endif.
write val1.
regards
kishore
there is small change
Message was edited by: Harikishore Sreenivasulu
‎2006 Feb 17 5:38 PM