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

Adding Zero's before material using Functional Module

Former Member
0 Likes
4,184

Dear Friends,

Please suggest me how to add zeros before the material using functional module?

i have mateial of length 18 character

now i have material as "MCV23456" which is 8-digit,my requirement is to add addtional zeros before the

material.

INPUT=MCV23456

OUTPUT=0000000000MCV23456.

Please suggest suitable Functional Module

Thanks in advance

Jai

12 REPLIES 12
Read only

Former Member
0 Likes
2,810

Hello,

Try FM : CONVERSION_EXIT_ALPHA_INPUT

Read only

0 Likes
2,810

Hi

I already tried this FM is used for only mumeric values

Regards

Jai

Read only

0 Likes
2,810

Hi,

You can try the same function module "CONVERSION_EXIT_ALPHA_INPUT".

If this is only working for numeric values, then declare a temporary variable with type numeric and pass the value to temporary variable and use that in function module.

Regards,

Venkat

Read only

0 Likes
2,810

Come on guys, really? 3 people suggested CONVERSION_EXIT_ALPHA_INPUT for a mixed alpha-numeric field value? I guess BP is the only one paying attention today.

I just have to ask: why would you zero-fill a mixed field anyway?

Read only

0 Likes
2,810

BP - Barack Petroleum? LOL.... Thanks, though, Brad....

Read only

Former Member
0 Likes
2,810

There are different ways of doing this.. Call the Function Module "CONVERSION_EXIT_ALPHA_INPUT" or user Overlay like this.

DATA: matnr TYPE matnr.
matnr = '12345'.
SHIFT matnr RIGHT deleting TRAILING space.
overlay matnr WITH '000000000000000000'.

Correct the code

Read only

0 Likes
2,810

>

> There are different ways of doing this.. Call the Function Module "CONVERSION_EXIT_ALPHA_INPUT" or user Overlay like this.

>

>

DATA: matnr TYPE matnr.
> matnr = '12345'.
> SHIFT matnr RIGHT deleting TRAILING space.
> overlay matnr WITH '000000000000000000'.

>

> Correct the code

Ramesh has the answer, but, like Brad I am wondering why you would ever want to do this. Can you enlighten us?

Read only

Former Member
0 Likes
2,810

MCV23456 which is 8-digit

I see three characters that are not digits...Are you sure you need to do this? Material is an alpha field!

However, if you look at the domain for MATNR, you'll see that there is a conversion routine MATN1...But it doesn't shift and left zero fill...

Read only

0 Likes
2,810

>

>

MCV23456 which is 8-digit

>

> I see three characters that are not digits...Are you sure you need to do this? Material is an alpha field!

>

> However, if you look at the domain for MATNR, you'll see that there is a conversion routine MATN1...But it doesn't shift and left zero fill...

Man! you are just too literal. You probably correct people who use o instead of 0 when saying a number. Like 1"o" 4 5 instead of 1 "zero" 4 5. We all know what is meant even though it is not literally correct

Read only

agustin_cusse
Explorer
0 Likes
2,810

Hi,

You can use CONVERSION_EXIT_MATN1_INPUT.

Every time you need to see what conversion function a field is using go to SE11->Domain (MATNR in this case)->double click on "Convers. Routine". You will get the list of INPUT/OUTPUT FM's used in the conversion for this domain.

Read only

0 Likes
2,810

No, you can't by default...read the question and look at the value. MATN1 does nothing when the value contains alphas unless you force it by implementing BADI BADI_MATN1 or the old style enhancement provided...Configured material templates don't fire for non-numeric values either as far as I know.

You can implement some wacky code in the BADI to get that result though - don't know why you would want to anyway...

Read only

Former Member
0 Likes
2,810

Hi,

If you use CONVERSION_EXIT_ALPHA_INPUT for mixed values then the result is going to be material+spaces, using this external to internal converison f.m it adds leading zeros for numeric material only. if the material is going to be mixed value then you can calculate the length of the material and move 18 - length as leading zeros to new 18 character field followed by material.

Regards,

Manjunath