cancel
Showing results for 
Search instead for 
Did you mean: 

Converting from integer to character.

Former Member
0 Kudos
23,102

Hi,

I need to convert an integer to a 10 digit character.Could you help me to know how I could do it?

e.g. if the integer is 6000034, the converted value must be 0006000034.

I need to have the leading zereos.

Thanks,

Sandeep.

Accepted Solutions (1)

Accepted Solutions (1)

horst_keller
Product and Topic Expert
Product and Topic Expert

And nowadays you simply write:

text = |{ CONV string( num ) WIDTH = 10 ALPHA = IN }|.


or


TYPES numc TYPE n LENGTH 10.

text = CONV numc( num ).

Answers (11)

Answers (11)

Former Member
0 Kudos

Hi,

data : int type i value '6000034'.

data : temp(10) type i.

unpack int to temp.

now temp will hold value - 0006000034

reward points if helpful.

Regards,

Hemant

Former Member
0 Kudos

hi sandeep.

try this ..u will definately get output as u want.

DATA: CHAR TYPE i.

DATA: OUTPUT(10).

data: op(10) type c.

CHAR = 6000034.

op = char.

WRITE: op TO OUTPUT.

TRANSLATE OUTPUT USING '. '.

CONDENSE OUTPUT NO-GAPS.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = OUTPUT

IMPORTING

OUTPUT = OUTPUT.

.

Former Member
0 Kudos

hi

good

use CONVERSION_EXIT_ALPHA_INPUT converts any number into a string fill with zeroes, with the number at the extreme right

Example:

input = 123

output = 0000000000000...000000000000123

thanks

mrutyun^

Former Member
0 Kudos
REPORT ychatest.

DATA : v_num TYPE i VALUE 6000034,
       v_char(10).

v_char = v_num.
WRITE v_char TO v_char RIGHT-JUSTIFIED.

TRANSLATE v_char USING ' 0'.

WRITE v_char.
Former Member
0 Kudos

Hi Sandeep,

try this.

data: v_int type i value '6000034.

data: v_char(10) type c.

v_char = v_int.

unpack v_char to v_char.

write v_char.

Reward if it helps.

Regards,

Hemant.

Former Member
0 Kudos

try this CONVERSION_EXIT_ALPHA_OUTPUT

Regards,

Jayant

Former Member
0 Kudos

Hi sandeep,

the following code snippet solves ur problem.

data : abc type i value 6000034,

abc1(10) type c.

abc1 = abc.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = abc1

IMPORTING

OUTPUT = abc1

.

abc1 has ur required output.

please reward if helpful.

regards,

Ravi G

Former Member
0 Kudos

Hello,

Use this sample.


DATA: CHAR TYPE I.
DATA: OUTPUT(10).
CHAR = 6000034.
WRITE: CHAR TO OUTPUT.
TRANSLATE OUTPUT USING '. '.
CONDENSE OUTPUT NO-GAPS.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
     EXPORTING
          INPUT  = OUTPUT
     IMPORTING
          OUTPUT = OUTPUT.

WRITE: OUTPUT.

REgards,

VAsanth

Former Member
0 Kudos

Hi,

use unpack int1 to int2.

Regards

Nilesh

amit_khare
Active Contributor
0 Kudos

var = 6000034.

data: v_var(10) type n.

unpack var to v_var.

move v_var to v_char.

Former Member
0 Kudos

Hi

data v_var(10) type N.

Move 6000034 to v_var.

you can also use the fun modules

CONVERSION_EXIT_ALPHA_INPUT

CONVERSION_EXIT_ALPHA_OUTPUT

Reward points if useful

Regards

Anji

Message was edited by:

Anji Reddy Vangala

luis_gijon
Explorer
0 Kudos

This message was moderated.