REMOVE leading zeros ABAP SAP

Delete leading zeros ABAP in SAP important and easy task. Five examples how to remove leading 0 in ABAP program. There are more then one way how we can delete zeros in ABAP, but all have differences the choice is yours.

Remove leading zeros ABAP with CONVERSION_EXIT_ALPHA_OUTPUT

For deleting leading zeros ABAP we can use function module CONVERSION_EXIT_ALPHA_OUTPUT. Parameters function module CONVERSION_EXIT_ALPHA_OUTPUT ABAP:

Function module CONVERSION_EXIT_ALPHA_OUTPUT ABAP

Example using function module CONVERSION_EXIT_ALPHA_OUTPUT

Using CONVERSION_EXIT_ALPHA_OUTPUT in ABAP program for remove leading zeros in partner number SAP:

ADDITION: If you send to function module not number for example: ‘HR00000001’ (in SAP CRM in this field also there are and numbers with ‘HR’, for example). As result function module back to you the same value without changing and without dumps.

Delete leading zeros ABAP with New ABAP syntax

Remove leading zeros (0) in ABAP with new ABAP syntax. We have good opportunities for using new syntax ABAP constructions in deleting zeros task. Using ALPHA ABAP = OUT more short and useful then FM CONVERSION_EXIT_ALPHA_OUTPUT.

ADDITION: If you send to function module not number for example: ‘HR00000003’ (in SAP CRM in this field also there are and numbers with ‘HR’, for example). As result function module back to you the same value without changing and without dumps.

Remove leading zeros in ABAP with SHIFT

This useful construction you can use in new ABAP and in Old ABAP syntax also. Construction SHIFT LEFT DELETING LEADING ‘0’ is short and good option for deleting leasing zeros in ABAP.

ADDITION: If you send to function module not number for example: ‘HR00000005’ as result function module back to you the same value without changing and without dumps.

Delete leading zeros in ABAP with PACK

Using PACK ABAP is not advisable in my opinion, but you need to know how this construction work for reading ABAP code.

ADDITION: If you try to send not number ( ‘HR00000004’ for example ) to PACK as result you get dump with ‘CX_SY_CONVERSION_NO_NUMBER’. Construction PACK only change 0 to empty in lv_partner, not the same like in others:

Remove leading 0 in ABAP with WRITE

This is an unnecessary and unused option to delete. I just added it because it exists.

How add leading zeros in ABAP you can find on this page:

ADD leading zeros in ABAP SAP

Leave a Reply