Hi folks,
Let me try to clarify. We are processing SAP IDocs in XML-format. If you have ever seen some of these: they are really a bunch of segments, which consist of fields. Something like:
12.254-
MBGMCR02
…
20080909120000
…
So now we had the problem that SAP put the minus sign at the end of the decimal, like the KRATE field. We need to truncate some numeric fields to only 2 decimals, and the minus sign wrecked havoc with our solution for this:
set xlateOutVals [list [format “%.2f” $xlateInVals] ]
This works with the minus sign at the front of the decimal, and I believe that the XML-standard requires the minus sign to be at the front.
If we wanted decent output from SAP, then our SAP-guys had to work over every single numerical field with a possible negative outcome. Too much work. So I wanted to do this with one regsub.
John’s first suggestion was a good example for me. I was close, but I guess escaping the decimal sign was where I went wrong: I tried it with ‘ .’ . Only problem with his solution was that negative integers aren’t processed. So I changed it into
regsub -all — {(>)(d*)([.]d*)*([-])(<)} $a {14235} b
which seems to do the trick for me.
Thanks for all your help, guys! Much appreciated.
Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands