Skip to Content
avatar image
Former Member

How to display the kind of allocation bar with different colors in OO ALV cell?

Business wants to display the clocking allocation (see the below image) bar (with three different colors Red, Green, Yellow) based on the calculated un allocated hours . Is it possible to display the same in the OO ALV one of the cell? Not to display as the separate window like how the charts are displaying in OO ALV.

Add comment
10|10000 characters needed characters exceeded

  • Former Member

    Must the bar chart be displayed inline as a cell in ALV or is it ok to display it in the same screen at top/bottom (no pop-up), if you mark the line in ALV?

    All the 3D effects and colors are gone in modern UI and everything becomes flat and monochrome: Is an ASCII bar chart with a fixed font also ok (maybe resolution is not high enough)?

  • Former Member

    Inline is fine, but need different color for each employee. Will check and update on this.. Resolution will check with client. Thank you..

  • Get RSS Feed

3 Answers

  • Jan 12 at 09:46 PM

    As pointed out in the comment to Rajkumar's answer, there is no such screen element available in SAP GUI.

    In such cases we need to ask the person requesting this what exactly do they want to achieve by adding such visual presentation. There are several suggestions already given on how to achieve something that looks sort of similar to what you asked about. But instead you really should be asking not how to implement this but why.

    Such visual elements are usually added to make it easier for a human to spot some exceptions or trends in a long list, for example. E.g. in this case the business users might want to see easily which employees are above or below certain threshold. There could be alternative ways to provide them with the same information. For example, instead of trying to make up a "color slide" by painstakingly coloring ALV cells, you could just color (or show a "traffic light") the lines that are below/above certain percentage. I like "traffic light" in particular because it's basically what everyone is looking for (despite what they think at first) and it can also be used for filter/sorting.

    Figuratively speaking, instead of offering the users a car with the square wheels you could offer them a sled or a boat. But to do that you'd need to know first where they want to get to.

    As a side note, when users start expecting such visuals, it's time to suggest they invest in adding a modern UI.

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 12 at 10:14 AM

    To color a single cell with different colors is not possible.

    imho, you got 2 options:

    Using N cells with the colors you need and fill them with the percentage:

    • PROS: easy to implement and maintain
    • CONS: you loose the visual impact the business likes

    Turn the cell in a button and, once pressed, display a bar chart ( here some example https://wiki.scn.sap.com/wiki/display/Snippets/Creating+charts+in+Simple+ABAP+Programs ):

    • PROS: more visual impact (but i do not know the scenario)
    • CONS: you still need a click to open it
    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thanks for your option,

      First one, need to check because the N cells may differ for each employee.

      Second one, i plan to propose the same to the client

  • Jan 11 at 08:06 PM
    -2

    Hi Ganesh,

    Yes, it is possible to apply different colors in ALV grid.

    In ALV coloring, three different options are applicable.

    1. Column Color(Single Column) -> Separate color column(Ex: LINE_COLOR(4) TYPE C) is created in structure(TY_FINAL) and once the color values are assigned, the field name is assigned to layout-ctab_fname
    2. Row Color(Complete Row) -> Separate color column(Ex: COL_COLOR TYPE C) is created in structure(TY_FINAL) and once the color values are assigned, the field name is assigned to layout-info_fname
    3. Cell Color(Individual Cell) -> Separate color column(Ex: CELL_COLOR TYPE LVC_T_SCOL) is created in structure(TY_FINAL) and once the color values are assigned, the field name is assigned to layout-ctab_fname

    Since the above requirement is cell color, for that we need to create the color field in final structure as like below.

    "Structure Creation
    TYPES: BEGIN OF TY_FINAL.  
            Field1 type c, 
            Field2 type c, 
            Field3 type c,  
            ....
            .....
            cell_color TYPE lvc_t_scol,     "Color Column in Final Structure
           END OF TY_FINAL.

    "Declaration for Color Internal table and WA

    DATA: wa_color TYPE lvc_s_scol,
          it_color TYPE lvc_t_scol.

    Fill the values in Internal Table

    LOOP AT IT INTO WA. 
    ....
     wa_color-fname = 'FIELD1'.
     wa_color-color-col = 1. 
     APPEND wa_color TO it_color.
    
     wa_color-fname = 'FIELD2'.
     wa_color-color-col = 2.
     APPEND wa_color TO it_color.
    
     wa_color-fname = 'FIELD3'.
     wa_color-color-col = 3.
     APPEND wa_color TO it_color.
    
    "Move the color values to final WA
     WA_FINAL-cell_color = it_color[].
    ....
    ....
     APPEND WA_FINAL TO IT_FINAL. 
     CLEAR WA_FINAL.
    ENDLOOP.
    

    Assign the color in Layout structure and call the ALV grid display

     "Assign the Color field name to ctab_fname
    wa_layot-ctab_fname = 'CELL_COLOR'.
    
    "Call the ALV GRID
    CALL METHOD grid->set_table_for_first_display
     EXPORTING
     is_layout = wa_layot
     CHANGING
     it_outtab = it_final[]
     it_fieldcatalog = it_fcat[]

    Note: We have limited colors from 0 to 7, please refer the program SHOWCOLO for color values

    Regards

    Rajkumar Narasimman

    Add comment
    10|10000 characters needed characters exceeded