Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Add commas to an integer

Former Member
0 Likes
1,183

I have an integer that used to be a string. This number is at least 10,000 (stored as 10000) and I would like to display it with the proper commas. Is there any way to do this short of looping through the string and inserting them?

Regards,

Davis

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
876

Hi,

You may be declared as char type thats why it is coming as a number without commas. But if you declare it as an integer then you get the commas.

Thanks

Sarada

6 REPLIES 6
Read only

Former Member
0 Likes
877

Hi,

You may be declared as char type thats why it is coming as a number without commas. But if you declare it as an integer then you get the commas.

Thanks

Sarada

Read only

0 Likes
876

I tried converting it to an integer but it does not add the commas. The issue is that the value is initially a character field (type ATWRT)

Regards,

Davis

Read only

0 Likes
876

Move it to an integer and again move into a char field as below ..

If U have v_atwrt as 10000010...

data : v_i type i ,

v_c(12).

v_i = v_atwrt+0(8). <-- move char to I

write v_i to v_c. <-- v_c contains 10,000,010

Read only

0 Likes
876

Srinivas, thanks. The issue was that I was doing the following:

temp_int = wa_items-ntgew.

temp_char = temp_int.

When I needed to do:

temp_int = wa_items-ntgew.

write temp_int to temp_char.

Thanks again,

Davis

Read only

former_member187255
Active Contributor
0 Likes
876

Davis,

Try this...

write : l_amt USING EDIT MASK 'RR___,___,___.__'.

Hope this helps..

Chandra.

Read only

Former Member
0 Likes
876

Move the integer to a char variable ... and the character variable will

display it with the proper commas.

data : v_i type i ,

v_c(12).

v_i = 10000010.

write v_i to v_c. <-- v_c contains 10,000,010