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: 

keyword for Prefixing Materia No with zeros to get standard 18 digit format

Former Member
0 Kudos

Hi all,

I have a requirement where I have to do prefix zeros to material number t o make it standard 18 digit format.

I am getting the value of MAT_NO from an XML file and it is 678. but I need to make it u2018000000000000000678u2019.

If my material no is u20181u2019 I need to make it u2018000000000000000001u2019

If my material no is u20184272323u2019 I need to make it u201800000000004272323u2019.

My material number is not constant and is dynamic and I need to make it to standard 18 digit format by prefixing with zeros.

Do we have a Key word in ABAP to achieve this?

Any help will be highly appreciated.

Regards,

Jessica Sam.

4 REPLIES 4

Former Member
0 Kudos

This fm may help you

CONVERSION_EXIT_ALPHA_INPUT

Former Member
0 Kudos

shift ur_matnr to right deleting trailing spaces.

overlay '000000000000000000'.

or

use FM of alpha_exit_output

or

just move ur_matnr to a numeric field, say numeric_matnr

then again move this numeric_matnr to ur_matnr (assuming ur_matnr is a CHAR field)

like there r many options.

thanq

Former Member
0 Kudos

Hi,

Use: TYPE N

Data: w_matnr(18) type N.

w_matnr = Mat_no.

Write w_matnr.

If Mat_no = 20.

Output:0000000000000000020

Hope this resolves the problem.

Regards,

Gurpreet

Former Member
0 Kudos

Solved..thanks for help ..I used following code and it helped.

Thanks to all people for immediate help


Data: a(18) TYPE n.


a = '56'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  EXPORTING
    input         = a
 IMPORTING
   OUTPUT        = a
          .
WRITE: a.