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

ABOUT MATERIAL NUMBER

Former Member
0 Likes
1,261

hi, if the material number is with numbers, for example, 1000000001, we can use FM CONVERSION_EXIT_ALPHA_INPUT to add the leading zeros to make the material to 18 char.

But if the material number is with character, how should I make it to 18 char.

I need to CONCATENATE MATNR VKORG VTWEG INTO V_NAME. But the MATNR must be 18 char. Many thanks in advance!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,232

1st convert the material to 18 char by using FM

CONVERSION_EXIT_MATN1_INPUT.

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

EXPORTING

input = matnr

IMPORTING

OUTPUT = matnr

EXCEPTIONS

LENGTH_ERROR = 1

OTHERS = 2

.

IF sy-subrc <> 0.

ENDIF.

Than use the material for concatenation purpose...

CONCATENATE MATNR VKORG VTWEG INTO V_NAME.

Regards,

joy.

1st convert the material to 18 char by using FM

CONVERSION_EXIT_MATN1_INPUT.

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

EXPORTING

input = matnr

IMPORTING

OUTPUT = matnr

EXCEPTIONS

LENGTH_ERROR = 1

OTHERS = 2

.

IF sy-subrc <> 0.

ENDIF.

Than use the material for concatenation purpose...

CONCATENATE MATNR VKORG VTWEG INTO V_NAME.

Regards,

joy.

10 REPLIES 10
Read only

Former Member
0 Likes
1,233

1st convert the material to 18 char by using FM

CONVERSION_EXIT_MATN1_INPUT.

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

EXPORTING

input = matnr

IMPORTING

OUTPUT = matnr

EXCEPTIONS

LENGTH_ERROR = 1

OTHERS = 2

.

IF sy-subrc <> 0.

ENDIF.

Than use the material for concatenation purpose...

CONCATENATE MATNR VKORG VTWEG INTO V_NAME.

Regards,

joy.

Read only

0 Likes
1,232

it is not OK, maybe the concatenate ignore the spaces....so can anyone tell how should i do to keep the spaces?

Read only

0 Likes
1,232

Ok..try this...

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

EXPORTING

input = matnr

IMPORTING

OUTPUT = matnr

EXCEPTIONS

LENGTH_ERROR = 1

OTHERS = 2

.

IF sy-subrc 0.

ENDIF.

CONSTANTS: c_space TYPE syhex02 VALUE '00a0'. " Value for space

DATA: g_space TYPE string,

l_pos type i,

l_pos1 type i.

    • Get the actual value for a space*

g_space = cl_abap_conv_in_ce=>uccp( c_space ).

L_pos = strlen( matnr ).

l_pos1 = 18 - l_pos.

Do l_pos1 times.

matnr+l_pos(1) = g_space.

L_pos = l_pos + 1.

Enddo.

Than use the material for concatenation purpose...

CONCATENATE MATNR VKORG VTWEG INTO V_NAME.

By this way u can keep the trailing spaces...

Regards,

Joy.

Read only

0 Likes
1,232

oh, it's not OK, it '#' at end of the string.

Read only

0 Likes
1,232

It is OK..here # represents trailing space. Just to confirm that take a download of that concatenated value..u will find that # is replaced by space..pl. check..

Regards,

Joy.

Read only

0 Likes
1,232

oh, i tried, it's not OK, i want to use the V_NAME to read the sales text in FM READ_TEXT.

For example, matnr: R999-100

VKORG : 0001

VTWEG : 01

The v_name must be 'R999-100 000101', it can't be 'R999-100##########000101'

Read only

0 Likes
1,232

Ok. then try this solution..

DATA: g_space TYPE string,

l_pos type i,

l_pos1 type i.

L_pos = strlen( matnr ).

l_pos1 = 18 - l_pos.

Do l_pos1 times.

matnr+l_pos(1) = '#'.

L_pos = l_pos + 1.

Enddo.

Than use the material for concatenation purpose...

CONCATENATE MATNR VKORG VTWEG INTO V_NAME.

Replace ALL OCCURRENCES of '#' in v_name with space in CHARACTER MODE.

Regards,

Joy.

Read only

0 Likes
1,232

Hi,

If u dont want leading zeros then u can directly use concatenate statement.

CONCATENATE material sales org distribution channel INTO v_name.

If u want the trailing blanks the u have to do like this.

MOVE matnr TO v_name.

v_name+18(4) = sales org.

v_name+22(3) = distribution channel.

This will keep the trailing blanks. U can arrange the exact position as per ur req.

Thanks,

Vinod.

Read only

vinod_vemuru2
Active Contributor
0 Likes
1,232

Hi Check below sample code. U can replace sales org and dist channel with ur varaibles.


DATA: l_matnr TYPE mara-matnr VALUE 'AWE465464654',
      l_len TYPE i,
      l_string TYPE string.

CONSTANTS: c_vkorg TYPE vbak-vkorg VALUE '3CR',
           c_vtweg TYPE vbak-vtweg VALUE '01'.
           
WRITE l_matnr.
l_len = 18 - strlen( l_matnr ).

DO l_len TIMES.
  CONCATENATE '0' l_matnr INTO l_matnr.
ENDDO.

CONCATENATE l_matnr c_vkorg c_vtweg INTO l_string.
WRITE l_string.

Thanks,

Vinod.

Read only

0 Likes
1,232

Hi, adding leading zeros is not right, the material number with char. is with the spaces at the end of strings.