Leading zeros – adding and removing characters

The following SQL functions can be used to pad the start and end of strings with a character template up to a specified length be filled. Most of the time this is either “0” or space.

  • LPAD(<Characterstring>,<length>[,<pattern>])
  • RPAD(<Characterstring>,<length>[,<pattern>])

With the function ABAP_ALPHANUM (<Characterstring>,<Length>) numeric Strings with leading zeros up to a specified length can be filled. As soon as there is a non-numeric character in the string, this function does nothing.

The function TO_ALPHANUM is only available in HANA 2.0 and is not available in the SAP HANA Cloud. Please therefore always use ABAP_ALPHANUM .

And vice versa, you can remove a lot of characters from the beginning or end of a character string with the following functions:

  • LTRIM(<character string>[,<character set>])
  • RTRIM(<character string>[,<character set>])
  • TRIM( [<option>] <character set> FROM <character string>)

Mit dem Laden des Videos akzeptieren Sie die Datenschutzerklärung von Vimeo.
Mehr erfahren

Video laden

Pages 181-182 in the book