Purpose
Add leading zeros to a string if it is numeric, e.g. a customer number

For particular key fields SAP uses the "alpha" conversion exit; it adds leading zeros if the value is numeric, leaving the value unchanged if not.

Solution

//sample value
Set
V[kunnr] "A1240"   // or "1240"

if V[kunnr]

  // add leading zeros, length 10
  Set V[x](1-10) "0000000000&V[kunnr]" -alignright

  // use GuiXT calculation to check whether numeric
  Set V[y] &V[kunnr] + 0
  Set V[y](1-10) "0000000000&V[y]" -alignright

  // numeric? then add zeros
  If V[x=&V[y]]
    Set V[kunnr] "&V[x]"
  endif

endif

Components
InputAssistant