cancel
Showing results for 
Search instead for 
Did you mean: 

DS 4.1 SAP Material - Add leading Zeros - How?

Former Member
0 Kudos
4,297

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?

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member190054
Active Participant

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-example...

Former Member
0 Kudos

Hi,

As mentioned above, use lpad for padding with zeroes. 

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

Thanks,

Jincy

li_jin
Product and Topic Expert
Product and Topic Expert
0 Kudos

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

venkataramana_paidi
Contributor
0 Kudos

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.