09-22-2008 8:24 AM
Hello
How can I convert numeric to string (4 characters)
n type i.
st (4) type c.
n= 1 , st = '0001'
n = 10 , st = '0010'
n = 20, st = '0020'
etc
Thanks in advance
09-22-2008 8:28 AM
Hi,
try this -
DAta:n type i value 1,
st(4) type n.
st = n.
Write:st.
or
DAta:n(4) type n value 10,
st(4) type c.
move n to st.
Write:st.
09-22-2008 8:28 AM
Hi,
try this -
DAta:n type i value 1,
st(4) type n.
st = n.
Write:st.
or
DAta:n(4) type n value 10,
st(4) type c.
move n to st.
Write:st.
09-22-2008 8:29 AM
Hi Ignacio,
Try this:
REPORT ychandra_test3.
data:
num(4) type n value 10,
str(4) type c.
str = num.
write: str.
Regards,
Chandra Sekhar
Edited by: Chandrasekhar Gandla on Sep 22, 2008 1:01 PM
09-22-2008 8:37 AM
Hi Ignacio,
You can do this by using field-symbols:
field-symbols: <fs> type any.
st(4) type c,
n type i.
assign st to <fs>
move <fs> to n.
Hope this will help.
Regards,
Nitin.
09-22-2008 8:38 AM
data: n type i,
st(4) type c.
n = 20.
move n to st.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = st
IMPORTING
OUTPUT = st.
09-22-2008 8:42 AM
If you can use a character variable (type C) instead of an I, like in the following example, execute the code below and check if it works for you. You would set the size of your string changing the number within the parenthesis. Later you can assign this character variable to a string variable.
DATA x(4) TYPE c value '1'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = x
IMPORTING
OUTPUT = x.
WRITE: / 'RESULT:', x.
x = 20.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = x
IMPORTING
OUTPUT = x.
WRITE: / 'RESULT:', x.
DATA z type string.
z = x.
WRITE: /, z.
09-22-2008 8:47 AM