Skip to Content
author's profile photo Former Member
Former Member

ALV column with variable number of decimals to be displayed

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Dec 20, 2011 at 01:10 PM

    create an output structure where your field is CHAR type and WRITE the type P field to it.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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.

  • Posted on Dec 20, 2011 at 02:08 PM

    did you try EDIT_MASK ?

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 15, 2015 at 03: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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.