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: 

adding zeros to a string

Former Member
0 Kudos

Hi all,As you know mara-matnr field's lenght is 18 char, however in some cases the users do not fill all the length, for example they make it 15 char.

Here I need to add zeros at the beginning of the matnr, as it requires.

For instance, if the user has entered the matnr as 13 char: 1234567891234

then I need to make it as 000001234567891234..

How can I do it?

Thanks.

6 REPLIES 6

Former Member
0 Kudos

Hi,

Use UNPACK matnr TO matnr.

Regards,

Raghavendra

JozsefSzikszai
Active Contributor
0 Kudos

hi Deniz,

use the FM CONVERSION_EXIT_MATN1_INPUT.

ec

Former Member
0 Kudos

Hi,

use Fm,.

CONVERSION_EXIT_MATN1_INPUT

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

EXPORTING

input = zzmat

IMPORTING

output = zzmat.

Thanks.

hymavathi_oruganti
Active Contributor
0 Kudos

USE THE FUNCTION MODULE,

<b>conversion_exit_alpha_input.</b>

conversion_exit function modules are for the purpose of converting a fiedl from user format to sap format and vise versa. there are many conversion exit fn modules.

u can give converion_exit* in se37 and see many fn modules.

example: conversion_exit_alpha_output this is to convert from sap format to user format.

this means example in mara table the length of matnt would be 18. but if we give 1 value . it takes 0000000000...1. but the user needs the output as only 1. then we can use conversion_exit_alpha_input to convert from sap to user format.

conversion_exit_alpha_input cn be used viceversa.

Message was edited by:

Hymavathi Oruganti

Former Member
0 Kudos

hi try it like this

TRANSLATE temp1 USING ' 0'.

temp1 -> is the field name which one u want to fill '0'.

regards

baskaran

former_member188827
Active Contributor
0 Kudos

try

data zmatnr TYPE matnr value '123'.

data zch(18).

data zint type i.

data i TYPE i VALUE 1.

zint = 18 - strlen( zmatnr ).

WHILE i le zint.

CONCATENATE '0' zch into zch.

i = i + 1.

ENDWHILE.

CONCATENATE zch zmatnr into zch.

WRITE / zch.