Skip to Content
author's profile photo Former Member
Former Member

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

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Feb 24, 2009 at 04:37 PM

    This fm may help you

    CONVERSION_EXIT_ALPHA_INPUT

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 24, 2009 at 04:38 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 24, 2009 at 05:06 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 24, 2009 at 06:19 PM

    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.
    
    

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.