Question:
Hi,
I need to save a numeric value in database containing only numbers. At the same time I need to display the value on a screen with two decimals. For example, the value of "12" should be saved in database as "1200", and it should be displayed on a screen like "12,00" (or "12.00", depending on user decimal settings). Furthermore, when user enters either a value of "12" or "12,00" on the screen and press enter, the program should display the value as "12,00" in both cases.
Therefore, I created a domain and added a conversion routine to it. This routine performs the conversion from display format to internal format and vice versa.
However, after trying with several options with and WRITE input TO output DECIMALS 2 statements and with different data types with different decimals places, I haven't been able to do this conversion.
I am a bit frustrated, since this task is rather simple. Is there a standard function module doing this conversion? What is the best and most efficient way to do this conversion?
I have also find the following standard function modules:
- CONVERSION_EXIT_QUANT_INPUT and CONVERSION_EXIT_QUANT_OUTPUT
- CONVERSION_EXIT_DEC_3_INPUT and CONVERSION_EXIT_DEC_3_OUTPUT
_________________
Regards,
Jarmo
"Experience is a great teacher"
Answer:
Hi Jarmo,
You're saying that the number should be contained in a string ?
I would do this:
Write the number to a character field
Use search with an argument of '...' or ',' dependant on the users decimal setting,
Write the string + sy-fdpos+1 to the string +sy-fdpos and then store that number.
Otherwise I would look at using a packed BCD field.
Regards
R
ps. Sitting in a hotel room is boring....
_________________
Regards
R
Abap KC
SFMDR
Answer:
Hi R,
Thanks for your answer. I found from SAP Help http://help.sap.com/saphelp_470/helpdata/en/cf/21ee19446011d189700000e8322d00/frameset.htm example domain S_DURA where conversion routine is defined. I just followed the same idea in my conversion routine, and now it works.
_________________
Regards,
Jarmo
"Experience is a great teacher"