go to post Larry Faraci · Nov 2, 2018 While adding the length check is valid for a pure coding solution, the most practical reason where leading zero's are necessary is for values that are required to be a fixed length such as SSN's.If a value initially exceeded that fixed length, it most likely would have been trapped out as an invalid entry before it reached the length adjustment code.
go to post Larry Faraci · Nov 1, 2018 Try this:ROU>s val="sd123X" ; value to be justifiedROU>s len=9 ; length of the total stringROU>k z ; make sure z is undefinedROU>s $P(z,"0",len)=val ; set z to value with leading zerosROU>s val=$E(z,*-(len-1),*) ; trim value to required lengthROU>w !,val000sd123X