Skip to Content

Decimals in ALV field

Hi all!! How're u today?

I've an alv with a weight column, like this:

2,324

2,456

5,323

3

0

0

2,343

And I need to show the decimals in the integer numbers... How can i do that??

Thank you so much!

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Nov 07, 2008 at 09:21 AM

    Hi,,,,,

    Yes I got it.......

    I think you have declared it as quan in your internal table.....

    please declare it as

    data: quan type p decimals 3.

    thanks

    Saurabh

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi

      this sample works fine:

      DATA: BEGIN OF T_OUTPUT OCCURS 0,
              MATNR  LIKE MARA-MATNR,
              WEIGHT TYPE P DECIMALS 3,
              UNIT   LIKE MARA-MEINS,
            END   OF T_OUTPUT.
      
      
      DATA: LT_REPORT TYPE SY-REPID,
            LT_INCLUDE TYPE SY-REPID.
      
      DATA: GT_FIELDCAT TYPE  SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
      
      START-OF-SELECTION.
      
      * Load file
        T_OUTPUT-MATNR = 'A'.
        T_OUTPUT-WEIGHT = '3.123'.
        T_OUTPUT-UNIT   = 'KG'.
        APPEND T_OUTPUT.
      
        T_OUTPUT-MATNR = 'A'.
        T_OUTPUT-WEIGHT = 4.
        T_OUTPUT-UNIT   = 'KG'.
        APPEND T_OUTPUT.
      
        T_OUTPUT-MATNR = 'A'.
        T_OUTPUT-WEIGHT = 0.
        T_OUTPUT-UNIT   = 'KG'.
        APPEND T_OUTPUT.
      
        T_OUTPUT-MATNR = 'A'.
        T_OUTPUT-WEIGHT = '15.123'.
        T_OUTPUT-UNIT   = 'KG'.
        APPEND T_OUTPUT.
      
      * Load catalog table
      
        LT_REPORT = LT_INCLUDE = SY-REPID.
      
        CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
             EXPORTING
                  I_PROGRAM_NAME         = LT_REPORT
                  I_INTERNAL_TABNAME     = 'T_OUTPUT'
                  I_INCLNAME             = LT_INCLUDE
             CHANGING
                  CT_FIELDCAT            = GT_FIELDCAT[]
             EXCEPTIONS
                  INCONSISTENT_INTERFACE = 1
                  PROGRAM_ERROR          = 2
                  OTHERS                 = 3.
      
        LOOP AT GT_FIELDCAT WHERE FIELDNAME = 'WEIGHT'.
          GT_FIELDCAT-SELTEXT_L = 'KG'.
          GT_FIELDCAT-SELTEXT_M = 'KG'.
          GT_FIELDCAT-SELTEXT_S = 'KG'.
      
      *    GT_FIELDCAT-QFIELDNAME = 'UNIT'.
      *    GT_FIELDCAT-QTABNAME   = 'T_OUTPUT'.
      *
      *    GT_FIELDCAT-edit_mask = '
          MODIFY GT_FIELDCAT.
        ENDLOOP.
      
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
             EXPORTING
                  IT_FIELDCAT = GT_FIELDCAT[]
             TABLES
                  T_OUTTAB    = T_OUTPUT.

      U don't need to indicate the unit fields as control field for the quantity field.

      Max

  • author's profile photo Former Member
    Former Member
    Posted on Nov 07, 2008 at 08:54 AM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 07, 2008 at 08:51 AM

    Hi,,,,

    In your Internal Table where you are declaring the weight field....

    Declare it as-

    data: weight type p decimals 4.
    

    Then in output it will appear as a 2.345.

    Thanks

    Saurabh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 07, 2008 at 08:53 AM

    Hi

    What do you mean?

    U need to split the integer and decimals part into two different colunm or u need to show the weight as integer number?

    In the first case u need to two colunm as integer number:

    DATA WEIGHT TYPE P DECIMALS 4.
    
    DATA: INT TYPE I,
          DEC TYPE I.
    
    INT = TRUNC( WEIGHT ).
    DEC = FRAC( WEIGHT ).

    In the second case u need to move the weight to new field

    DATA: INT TYPE I.
    
    MOVE WEIGHT TO INT.

    Max

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 07, 2008 at 09:03 AM

    Hi,,,,,

    Where you have difined the field catalog, in that there is an option.

    for ex..

    fieldcat-decimals_out = 3.
    

    Thanks

    Saurabh

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Julio Pita de la Vega

      Hi Julio ,

      Try this code (Gross Weight with decimal places). Can you paste your code here.

      TYPES : BEGIN OF TY_MARA,
              MATNR TYPE MARA-MATNR,
              BRGEW TYPE MARA-BRGEW, "Gross Weight
              END OF TY_MARA.
      
      DATA : IT_MARA       TYPE TABLE OF TY_MARA,
             WA_MARA       TYPE TY_MARA,
             IT_MARA_COLL  TYPE TABLE OF TY_MARA.
      
      DATA : GR_TABLE TYPE REF TO CL_SALV_TABLE.
      
      SELECT MATNR
             BRGEW
      FROM MARA
      INTO TABLE IT_MARA UP TO 500 ROWS.
      
      *TRY.
      CALL METHOD CL_SALV_TABLE=>FACTORY
      *  EXPORTING
      *    LIST_DISPLAY   = IF_SALV_C_BOOL_SAP=>FALSE
      *    R_CONTAINER    =
      *    CONTAINER_NAME =
        IMPORTING
          R_SALV_TABLE   = GR_TABLE
        CHANGING
          T_TABLE        = IT_MARA
          .
      * CATCH CX_SALV_MSG .
      *ENDTRY.
      .
      
      CALL METHOD GR_TABLE->DISPLAY
        .

      Regards

  • author's profile photo Former Member
    Former Member
    Posted on Nov 07, 2008 at 09:12 AM

    Hi....

    In your internal Table have you defined your quantity field as decimal,,,, I mean only decimal not quan or type p.....

    if this is not working........

    let me know your req clearly..........

    I think you have a quantity and it's output is coming as

    2,345

    and you want,,,,,

    2.345

    Thanks

    Saurabh

    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.