Application Development and Automation 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: 
Read only

type conversion

Former Member
0 Likes
980

Hi all!

i want to map an integer value into a char2 field. the char 2 field must have a leading zero. => INT value 1 should become CHAR2 '01'.

how do you do that? thanks in advance.

christoph

1 ACCEPTED SOLUTION
Read only

ssimsekler
Product and Topic Expert
Product and Topic Expert
0 Likes
950

Hi Cristoph

First assign integer value to the character variable. Then use the statement <b>"OVERLAY"</b>.

<u><b>e.g.</b></u>

lv_char = lv_int .
OVERLAY lv_char WITH '00' .

*--Serdar

5 REPLIES 5
Read only

Former Member
0 Likes
950

Is it okay, if you use NUMC ?

data: lv_intvalue type i,

lv_numcvalue(2) type n.

lv_intvalue = 1.

lv_numcvalue = lv_intvalue.

write: lv_numcvalue.

alternatively you can use FM, <b>CONVERSION_EXIT_ALPHA_INPUT</b>

Regards,

Subramanian V.

Read only

ssimsekler
Product and Topic Expert
Product and Topic Expert
0 Likes
951

Hi Cristoph

First assign integer value to the character variable. Then use the statement <b>"OVERLAY"</b>.

<u><b>e.g.</b></u>

lv_char = lv_int .
OVERLAY lv_char WITH '00' .

*--Serdar

Read only

0 Likes
950

Personally I much prefer the use of NUMC type variable and the CONVERSION_EXIT_ALPHA_INPUT FM, it's much cleaner and makes proper use of data types, the second solution (right-justification of field value and overlay) will work - but it's really a workaround rather than a true solution.

Particularly if the variable has to be used elsewhere appropriat use of correct data types is a better way forward.

Read only

Former Member
0 Likes
950

Use NUMC only it is very easy conversion..

Read only

former_member183804
Active Contributor
0 Likes
950

One may use the UNPACK statement.

Best Regards

Klaus


REPORT  KZI_TEST_01.

  data:
    my_i type i value 2,
    my_n type n length 2,
    my_c type c length 2.

  my_n = my_I.
  unpack my_I to my_C.

  write: / my_N, my_C.