Application Development 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: 

Character Field as Number, Need commas?

Former Member
0 Kudos
6,278

I move a quantity to a character field for a form display output. I left justify the character by shift character field left deleting leading spaces. This way it formats perfectly in the column on my report/form.

Is there any easy syntaxfunction module, etc., that will take char field 1000.0 and put inn a comma 1,000.0?

I don't want the value to shift back to the right (right-justify).

Thank-You

Edited by: TMM on Jan 30, 2009 11:30 AM

1 ACCEPTED SOLUTION

Former Member
0 Kudos
806

is your input 1000..? to use the WRITE TO...statement make sure the input is in numeric data type instead of character type...if it is a character type convert it to numeric and then do the WRITE TO statement...as mentioned above..

Please correct me if I am wrong in my assumption..

Thanks

Naren

8 REPLIES 8

Former Member
0 Kudos
806

Hi,

Just use write statement..

DATA: v_quan TYPE menge_d VALUE '1000',
      v_char TYPE char20.

WRITE v_quan TO v_char.

WRITE:/ v_char.

Thanks

Naren

0 Kudos
806

I am kind of doing that now. Like I said. I need to place commas like 1,000.0, And, I don't want the value to right justify. Thanks.

Former Member
0 Kudos
806

Hi,

After the write statement use the shift left to delete the leading space.

DATA: v_quan TYPE menge_d VALUE '1000',
      v_char TYPE char20.

WRITE v_quan TO v_char.

SHIFT v_char LEFT DELETING LEADING SPACE.

WRITE:/ v_char.

Thanks

Naren

0 Kudos
806

OK....How do I put the comma in....1,000

Former Member
0 Kudos
807

is your input 1000..? to use the WRITE TO...statement make sure the input is in numeric data type instead of character type...if it is a character type convert it to numeric and then do the WRITE TO statement...as mentioned above..

Please correct me if I am wrong in my assumption..

Thanks

Naren

0 Kudos
806

Probably my fault Naren, I probably needed to put more emphasis in my message that I need to put a COMMA after the 1 and before the zeroes.....1 , 0 0 0 . 0. When I move it to character fields it does not want to include a comma in the format of the output. The number in the char field will probably vary. But mostly never be more than 100,000.00. Thank-you.

0 Kudos
806

the commas should be automatic...

in this code:


* Input character.
DATA: v_input   TYPE menge_d VALUE '1000.000'.

  write: v_input left-justified.

the value written is 1,000.000

it is left justified

it HAS commas

this also works for type P

this also works when you write into another field, or into a field in an ALV table...

Perhaps if you pos ta short burst of your code, we can see why yours does not work.

Former Member
0 Kudos
806

Hi,

Ok..Please check this..

* Input character.
DATA: v_input   TYPE char20 VALUE '1000.0',
      v_output  TYPE char20,
      v_num     TYPE p DECIMALS 1.

* Move it to numeric variable.
v_num = v_input.

* Use the write statement to add the thousands separator.
WRITE v_num TO v_output.

* Make sure in the user settings the decimal notation is 1,234,567.89
* otherwise use this code.
SET COUNTRY 'US'.
WRITE v_num TO v_output.
SET COUNTRY space.

* Remove the leading spaze.
SHIFT v_output LEFT DELETING LEADING space.

* Display
WRITE:/ v_output.

Thanks

Naren