Delete leading ZERO with ABAP

Delete leading ZERO with ABAP


SHIFT lw_char LEFT DELETING LEADING '0'.

Several synthax below to do the same thing :
(Notice that you have to work with a field type CHAR to remove the ZERO, will not work with a NUMC variable)


* ====================================================
  MOVE lw_num TO lw_char.
  " lw_char = '0000000123'

  SHIFT lw_char LEFT DELETING LEADING '0'.
  " lw_char = '123'


* ====================================================
  MOVE lw_num TO lw_char.

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
    EXPORTING
      input  = lw_char
    IMPORTING
      output = lw_char.
  " lw_char = '123'


* ====================================================
  WRITE lw_num TO lw_char NO-ZERO.   " lw_char = '       123'
  CONDENSE lw_char.                  " lw_char = '123'

Search tag : remove, enlever, zéro non-significatifs

About the author

fjourneau administrator

Hi, I'm Florian Journeau, SAP ABAP R3 Freelance, based in Toulouse, France. You want to know more about me, have a look on my CV : cv.fjourneau.net.

1 Comment so far

fjourneauPosted on11:48 am - Feb 25, 2019

Hi Anuhya,
I’m not used to work with Web dynpro, if it works as in R3, the output format should be the one of your data element.
If you work with quantity field Size 12, dec 6 (0.000000), set a quantity field dec 4 in your tab control, move your working field into it and it should display 0.0000.

If not, also check your field output preference.

Hope it will help.

Leave a Reply