‎2010 Dec 30 9:20 AM
I have a variable which is of type dec. When 0 is entered as a value, the value displays as a blank field whereas I want to display as 0.0 - but only if 0 has been entered as a value. Can this be done?
‎2011 Feb 11 7:38 AM
Hi Kevin,
Can you be more specific - as in where do you want to display this field. Is it in an alv report or module pool screen etc ?
There are a couple of operations for ALV reports that can get this output.
Please specify your requirement.
Titus
‎2011 Feb 11 8:18 AM
It is a module pool screen. I have got round the problem by declaring the type as char (with a range stipulating numeric values only) and writing the dec value or clearing the field as appropriate. It is a rather messy solution though and if there is another way I would like to know what it is.
‎2011 Feb 15 5:04 AM
I have come with an approach but to be honest I think your original is probably better.
I have basically worked with character fields but created them in the dictionary and used
conversion exits.
I created a data element ZNRW_CHAR5 using a domain of the same name.
The domain ZNRW_CHAR5 is type CAHR length 5 but has an output length of 6 and uses a convers routine of ZNRW5.
I created a local function group which contained two function modules which have the same interface:
an untyped importing parameter 'input' and a simlar exporting parameter 'output'.
CONVERSION_EXIT_ZNRW5_INPUT...the only code in this is: output = input.
CONVERSION_EXIT_ZNRW5_OUTPUT...has a bit more code
data l52(3) type p decimals 2.
data l_string(6) type c.
clear output.
if input co ' 1234567890.'
and input is not initial.
write input to l_string.
l52 = l_string.
output = l52.
endif.
I created a test abap:
REPORT ZNRW_TEST_CONV_EXIT.
parameters: p_char type ZNRW_CHAR5.
write:/ '''' no-gap,p_char no-gap,''''.
This works but I think it's messier than your origianl. Maybe it could be cleaned up a bit??