Is the number you want to convert in a fixed position?
I'd just REDFINES so I can get at the parts of the field, check that commas are commas, decimal-point is ",", parts are numeric, and then put the number together with MOVEs to a receiver without the editing characters.
If you can't be bothered with checking for validity, you can REDEFINES with an editing PICture which represents the data and just MOVE it to your numeric destination field (it's called "de-editing").
If the number is not in a fixed position, you can always arrange that it is so, and proceed as above. Ensure there is always at least one leading blank, UNSTRING to two fields DELIMITED BY ALL SPACE, ignore the first field and define the second as alpha-numeric with JUSTIFIED RIGHT.
I never use NUMVAL or NUMVAL-C. As you notice, they die in an instant with "bad" data, and no way to determine beforehand that the data is bad, without writing code which then means you don't need to use them...
Yes, I think I must have looked at the syntax diagram for NUMVAL twice
If your data is coming from Excel, why don't you get the output without the commas anyway? Or are you working off an existing output which can't be changed, and you can't get your own?
Excel is good news for NUMVAL/NUMVAL-C, because the data is going to be a valid format - except for that occasion when you get the output field filled (you'll see lots of #s). If the output field from Excel is large enough that that can't happen (guaranteed) then fine. But I'd still check for that value, and do something, rather than just let NUMVAL-C crash.
I'd personally still do it differently. How big are your fields? More than 15 significant digits? Watch for that with NUMVAL/NUMVAL-C. The other thing is that you get "a floating-point approximation" out of NUMVAL/NUMVAL-C, You may want to check what happens with values which can't be exactly expressed as a floating-point value.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum