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: 

Convert Numeric to string (4)

former_member603051
Participant
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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.

6 REPLIES 6

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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.

Former Member
0 Kudos

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.

Vijay
Active Contributor
0 Kudos

hi,

try like this.....

data: v_abc type numc4,

v_xyz type char4.

v_abc = 10 ( assigned value as example).

v_xyz = v_abc.

regards

vijay.