Writing money without any decimal worries
Some people read the TCURX to find out the number of decimal places of a CURRENCY when they need to write a money field to an alphanumeric variable.
Are you one of those people? Don’t be.
You can’t, of course, simply assume that all currencies have two decimal places. Look at Japan, which doesn’t have any at all. Or the defunct Escudo, which also had none. So, if you’re like that person described above, you go to TCURX to see if your CURRENCY is there. And if it is, you save the number of decimal places in the CASAS_DECIMAIS variable. If it isn’t, you assume it has two decimal places. Then you do:
WRITE money TO alphanumeric DECIMALS casa_decimais.
And that sees you right.
But it’s not pretty. And it’s laborious.
Why not do something like:
WRITE money TO alphanumeric CURRENCY currency.
It’s prettier, cleaner and always comes out right. Because SAP does the work for you.
Thanks to Pierre Ameye for the tip.
Greetings from Abapinho.