Можно немного упростить этот метод
X++:
#DEFINE.HEXDIGITS('0123456789ABCDEF')
static str 12 int2Hex(int iValue, int digits = 0 )
{
str 12 result = '';
;
if (iValue < 0)
{
digits = 8;
}
while (iValue != 0)
{
result = subStr(#HEXDIGITS, iValue & 0xF + 1, 1) + result;
iValue = iValue >> 4;
if (iValue == -1 && strLen(result) == digits)
{
break;
}
}
result = strRep('0', digits - strLen(result)) + result;
return result;
}