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: 

to append leading zeros to a character field

Former Member
0 Kudos

Hi,

can some body tell me how to append leading zeroes to a character field

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Perez C,

thanks for reply but can u tell me if i can use replace stmt to replace the spaces with zeroes, since here i need to declare a constant zero of abt 30 zeroes..

9 REPLIES 9

Former Member
0 Kudos

Hi,

Use FM CONVERSION_EXIT_ALPHA_OUTPUT on the field.

Reward Points if this helps,

Regards,

Satish

0 Kudos

hi satish thanks for the reply ,

but this f m does not append zeroes if the first character is a alphabet.

0 Kudos

hi Rajitha,

try this:


data:
      chaR(10) type c value '0000000000',
      cha(10) type c value 'a123456',
      len  type i,
      len1 type i.

  len = strlen( cha ).
  len1 = 10 - len. "10 is max length
  move cha to CHAR+len1(len).

  write:
         'CHAR', num.

Hope it helps.

Lokesh

Message was edited by:

Lokesh Aggarwal

Former Member
0 Kudos

Hi Rajitha,

try this code..


DATA : matnr LIKE mara-matnr . "character type with 18 length
DATA : dummy LIKE mara-matnr VALUE '000000000000000000'.    "18 zeros.

WRITE '1234' TO matnr RIGHT-JUSTIFIED.
OVERLAY matnr WITH dummy.

WRITE 😕 matnr.

Message was edited by:

Perez C

Former Member
0 Kudos

Hi Perez C,

thanks for reply but can u tell me if i can use replace stmt to replace the spaces with zeroes, since here i need to declare a constant zero of abt 30 zeroes..

0 Kudos

..

Message was edited by:

Perez C

0 Kudos
DATA:
 w_char TYPE matnr.

WRITE 'ABC' TO w_char RIGHT-JUSTIFIED.
TRANSLATE w_char USING ' 0'.
WRITE:w_char.

Former Member
0 Kudos

hi try this code.

data: STRL TYPE I VALUE 0.

STRL = STRLEN( input ).

data: in(10) type c.

in = input.

strl = 10 - strl.

Do strl TIMES.

CALL FUNCTION 'STRING_CONCATENATE'

EXPORTING

STRING1 = '0'

STRING2 = in

IMPORTING

STRING = in.

ENDDO.

output = in.

regards,

sohi.

Former Member
0 Kudos

thanks for every body who contributed

thanks a lot rajesh