07-22-2005 9:17 AM
All
Easy one this surely...
I wish to display a column in the ALV grid formatted to 2 decimal places with no exponent. Therefore, as the doucmentation suggests, I have specified the following in my field catalog definition:
if p_fieldname = 'PERCENT'.
gs_fieldcat-decimals_O = '2'.
gs_fieldcat-exponent = '0'.
endif.
The field percent is defined as type f.
However, both fields are completely ignored and I have resulted in creating another type c column and WRITEing the result into it. The if statement is sound as I debugged it and all is well. I added the gs_fieldcat-exponent-key = 'X' option to test it as well and this was fine. I have also tried the two options on their own but no difference, I still get 1.000000000E01 etc
What am I missing? I am on 46B BTW.
Any clues?
Ian
07-22-2005 10:01 AM
07-22-2005 10:36 AM
Hi Judith
THanks for the reply. I do not have a reference field for the PERCENT field it is directly typed as F.
TYPES: BEGIN OF ty_outtab,
plant type qals-werk,
lot TYPE qals-prueflos,
customer TYPE qals-zz_cust_name,
project TYPE qals-zz_project_name,
year(4) TYPE c,
month(3) TYPE c,
total TYPE i,
passed TYPE i,
failed TYPE i,
-> percent type f,
percentc(12) type c,
END OF ty_outtab,
07-22-2005 10:55 AM
Hello Ian,
looks like ALV is converting your field from type f to Type c.
What happens if you try a field "Data: percentp type p decimals 2" and "percentp = percent" ?
Regards Wolfgang
07-22-2005 11:23 AM
As u r using percent type f,
it will come as <b>exponent</b>
Try to convert this type before passing into the output table.
07-22-2005 2:00 PM
Hi all
As you can see from the original code snippet:
failed TYPE i,
percent type f,
percentc(12) type c,
END OF ty_outtab,
I created another column percentc. I used this to produce the output I wanted. I didn't see as though I should have to do this though when the field catalog has the fields to determine the style of output formatting.