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

Add leading zero to matnr in a conversion program

Former Member
0 Likes
21,386

Hi All,

When uploading matnr from a text legacy file , should i add leading zeroes to the sku value. For ex the data from the lagacy is 1000123456 (10 digits length). The values are always numbers. The matnr in SAP is 18 chars. Should my program transform it into 000000001000123456 before saving it into mara-matnr?

Regards, Oli

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
8,420

Hi,

You can use this FM CONVERSION_EXIT_ALPHA_INPUT to add leading zeros.


...

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  EXPORTING
    INPUT  = WA_MATNR
  IMPORTING
    OUTPUT = WA_MATNR.

...

Regards,

Ferry Lianto

10 REPLIES 10
Read only

Former Member
0 Likes
8,421

Hi,

You can use this FM CONVERSION_EXIT_ALPHA_INPUT to add leading zeros.


...

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  EXPORTING
    INPUT  = WA_MATNR
  IMPORTING
    OUTPUT = WA_MATNR.

...

Regards,

Ferry Lianto

Read only

8,420

Yes, you should convert it, you can use the function module CONVERSION_EXIT_MATN1_INPUT.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
8,420

Hi Oli,

Yes, it will implicitly use conversion exits for your values but prior to this you need to these values to the exact table field.

Otherwise, Use conversion exits before passing these values to a conversion program

<b>CONVERSION_EXIT_ALPHA_INPUT</b> is used to convert from external to internal format.

Thanks,

Vinay

Read only

Former Member
0 Likes
8,420

Thanks a lot to all of you for your prompt answer.

Read only

0 Likes
8,420

HI Oli bumchi...

as simply u can use UNPACK statement...

data matnr like mara-matnr.

matnr = '12345'.

Unpack matnr to matnr.

Regards

SAB

Read only

0 Likes
8,420

Are you sure that in configuration, the Indicator for lexicographical material numbers is unchecked? If it checked, then SAP will not then the all numeric material numbers will not get leading zeros by default. =====>

Indicator for lexicographical material numbers

Defines the way numeric material numbers are stored in the database.

Use

Caution

It is only possible to set or reset (cancel) this indicator if no numeric material numbers have been used yet in the system since they would no longer be interpretable after setting or resetting this indicator.

If this indicator is not set, numeric material numbers are padded with leading zeros and stored right-justified

Read only

0 Likes
8,420

i am facing similar issue... my matnr is not getting printed in alv... i appended extra zeros in front then it came... my question is matnr has implicit conversion right? so what is the need of expicit conversion function module...

Read only

Former Member
0 Likes
8,420

There's another, admittedly dirty(!) way of doing it -

SHIFT MATNR RIGHT DELETING TRAILING SPACE.

OVERLAY MATNR WITH '000000000000000000' ONLY SPACE.

Read only

0 Likes
8,420

Lets keep going, how many DIFFERENT ways to accomplish this.

Here's another....

data: c(18) type c value '12345'.
data: n(18) type n.

n = c.
c = n.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
8,420

Hi Oli,

use Funciton Module 'CONVERSION_EXIT_ALPHA_INPUT'


CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  EXPORTING
    INPUT  = input_value
  IMPORTING
    OUTPUT = output_value.