12-20-2011 11:39 AM
Hi,
I've an ALV where I need to display a numeric column with a variable number of decimal row-by-row, from 0 (no decimals) to 4.
I've declared the numeric field as TYPE P DECIMALS 4.
I've tried with DECMLFIELD in ALV catalog, and this works for 1 to n decimals, but when I leave the field indicated in DECMLFIELD equal to 0, ALV shows the default number of decimals of the field (4 in that case).
Any help will be very appreciated.
Thanks.
Jordi
12-20-2011 1:10 PM
create an output structure where your field is CHAR type and WRITE the type P field to it.
12-20-2011 1:10 PM
create an output structure where your field is CHAR type and WRITE the type P field to it.
12-20-2011 1:17 PM
Hi,
thanks. I've tried this and works for display, but then I lost the abbility to do SUM to that column. Also, I've tried to assign a DEC type in DATATYPE (ALV field catalog), and that solved the problem with the SUM but leaves another problem: Filter does not work (I'm able to enter a filter but value is not recognized correctly).
So, I was going not to use a CHAR type column, but a Numeric one.
Thanks anyway for your quick answer.
12-20-2011 2:08 PM
12-20-2011 3:18 PM
No, I didn't try EDIT_MASK.
How should I use it to format output to display decimals or not depending on the row?
I have 2 kinds of values, all stored in a TYPE P DECIMALS 4: Those that really are an integer (decimals should not be displayed for that ones) and the values that really have 4 decimals (which should be displayed with decimals in ALV).
Example:
13,0000 should be displayed as 13
0,4567 should be displayed as 0,4567
With EDIT_MASK could I do that?
Thank you very much.
12-20-2011 8:44 PM
jordi08028 ,
have you tried the field catalog parameter:
NO_ZERO LVC_NOZERO CHAR 1 0 ALV control: Suppress zeros for output
Bruce
12-21-2011 8:19 AM
Hi Bruce,
NO_ZERO is to avoid display of Initial values (zero, 0), but does not work for what I need.
Anyway, thank you for your answer.
12-16-2015 6:25 AM
Create FM CONVERSION_EXIT_ABCDE_OUTPUT with something like that:
data tmp type string.
tmp = input.
shift tmp right delete trailing '0'.
output = tmp.
Then set column edit mask to ==ABCDE.
12-15-2015 3:31 PM
Hello Jordi
The field that you use to indicate the decimals is the wrong type, you most likely defined it as an integer which would make sense but the ALV grid has a bug in it in the sense that it ignores your decimal field when it is initial (for integer fields this would be zero). As an example:
BEGIN OF mty_s_data,
amount TYPE betrg,
currency TYPE waers,
decimals TYPE int4, "<== This will not work since zero is seen as initial.
END OF mty_s_data,
Anyway define your decimal field to be a char type, e.g. char5, and then use it again. Zero would now be seen as non-initial and the ALV grid will use it to format your data. Example correct usage to work around ALV bug:
BEGIN OF mty_s_data,
amount TYPE betrg,
currency TYPE waers,
decimals TYPE c LENGTH 5,
END OF mty_s_data,
Good luck, Ettienne