After your remark I'm not sure how qv will interpret this - normally a concat between two values results in a string but fields will be normally interpreted by the format from the very first loading-value of those field - therefore I will make a test:
Load if(len(KDMAT)=8 and isnum(KDMAT), '0000000000' & KDMAT, KDMAT) as KDMAT inline [
and result is:
Therefore the simple string-concat seems to work, but your solutions ensure that the output is in the wanted format.
I think there are two things to look at in your example:
I don't think that the Format of the KDMAT values have been set before the Input records get into your if() statement, I was more thinking about a resident load, where the same numeric value has been loaded before.
Second, I forgot that QV will not interpret strings with more than 14 Digits as numbers, so this specific format will always result in a string. But what if we just add 4 leading zeros?
So just out of curiosity (because it's not the scenario the OP described), try to run this: