Skip to Content
avatar image
Former Member

DS 4.1 SAP Material - Add leading Zeros - How?

DS 4.1 Add leading Zeros - How?

We have material number without leading Zeros, by example = '445566'

We need 18 chars format with leading zeros = '000000000000445566'

Is there any string function in DS to do this?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Jun 24, 2013 at 07:20 AM

    Hi,

    Use the function to_char

    to_char(445566,'099999999999999999')

    also,

    Lpad(445566,18,'0');

    Please let me know .if it is working.

    and also refer below link.

    http://scn.sap.com/community/data-services/blog/2013/06/12/convertion-functions-in-bods-with-examplespart1

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 23, 2013 at 09:12 AM

    Hi Mikhail,

    If you want add leadingĀ  just use lpad function as MATNR data type is varchar . Please find the below syntax.

    LPAD(MATNR,18,'0')

    Thanks & Regards,

    Ramana.

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 24, 2013 at 01:42 AM

    Hi,

    Is lpad what you want?

    Syntax:

    lpad(input_string, size, pad_string)

    Example:

    lpad(last_name, 25, ' ')

    Result:

    The value in the column last_name, padded with

    spaces to 25 characters on the left or truncated

    to 25 characters.

    You can find more details from reference guide.

    Thanks,

    Li

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 24, 2013 at 05:57 AM

    Hi,

    As mentioned above, use lpad for padding with zeroes. 

    ex. lpad(MATNR,18,'0')

    Thanks,

    Jincy

    Add comment
    10|10000 characters needed characters exceeded