2009 Jan 30 4:28 PM
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
2009 Jan 30 4:44 PM
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
2009 Jan 30 4:31 PM
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
2009 Jan 30 4:33 PM
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.
2009 Jan 30 4:37 PM
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
2009 Jan 30 4:38 PM
2009 Jan 30 4:44 PM
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
2009 Jan 30 4:47 PM
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.
2009 Jan 30 6:13 PM
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.
2009 Jan 30 5:00 PM
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