Traffic light how to be given in ALV

Dear Freinds,
                iam able to get the data in the ouput using
REUSE_ALV_GRID_DISPLAY , as per the requiremnt i want to display the first column of the  record  if success Green color light and failed records display in the first column a Red .
Could any one let me know please how i can give the traffic lights in the ALV .
Thanks & regards
Srinivas.

Hi,
To display icons in ALV is as follow...
Define a field in the internal table LIKE ICON-ID, not char(4). For example...
DATA: BEGIN OF ITAB...
icon_field LIKE ICON-ID,
END OF ITAB.
Then fill the field icon, for example...
itab-icon_field = @0A@ "Red light
Preparing the fieldcatalog...
wa_fieldcat-tabname = 'ITAB'.
wa_fieldcat-fieldname = 'ICON_FIELD'.
wa_fieldcat-icon = 'X'.
There is another way to display icons, but is only for lights...
icon_field(1) TYPE C.
itab-icon_field = '1'. "Red
itab-icon_field = '2'. "Yellow
itab-icon_field = '3'. "Green
wa_layout-lights_tabname = 'ITAB'.
wa_layout-lights_fieldname = 'ICON_FIELD'.
regards,
Advait

Similar Messages

  • Traffic Lights in ALV

    Hi experts,
    I am using below code to generate the traffic lights but in column header i am getting one button i want to replace that as Traffic lights. how to do this can any body tell me
    "Includes
    INCLUDE <icon>.
    INCLUDE <symbol>.
    *& Declaration part
    "Types
    TYPES:
         BEGIN OF t_lights,
           matnr  TYPE mard-matnr,
           werks  TYPE mard-werks,
           lgort  TYPE mard-lgort,
           lights TYPE char4,       "Variable is needs to be declared with length 4 char
          END OF t_lights.
    "Work Areas
    DATA:
        w_lights TYPE t_lights.
    "Internal tables
    DATA:
        i_lights TYPE STANDARD TABLE OF t_lights.
    ALV Declarations
    Types Pools
    TYPE-POOLS:
       slis.
    Types
    TYPES:
       t_fieldcat         TYPE slis_fieldcat_alv,
       t_events           TYPE slis_alv_event,
       t_layout           TYPE slis_layout_alv.
    Workareas
    DATA:
       w_fieldcat         TYPE t_fieldcat,
       w_events           TYPE t_events,
       w_layout           TYPE t_layout.
    Internal Tables
    DATA:
       i_fieldcat         TYPE STANDARD TABLE OF t_fieldcat,
       i_events           TYPE STANDARD TABLE OF t_events.
    *&    start of selection
    START-OF-SELECTION.
      PERFORM get_data.
    *&    end-of-selection.
    END-OF-SELECTION.
      PERFORM build_fieldcatlog.
      PERFORM build_layout.
      PERFORM list_display.
    *&      Form  get_data
    FORM get_data .
      SELECT matnr
             werks
             lgort
        FROM mard
        INTO CORRESPONDING FIELDS OF TABLE i_lights
        UP TO 10 ROWS.
      IF i_lights[] IS INITIAL.
        "Dummy data
        DO 10 TIMES.
          w_lights-matnr = sy-index.
          w_lights-werks = sy-index + 1.
          w_lights-lgort = sy-index + 2.
          APPEND w_lights TO i_lights.
          CLEAR  w_lights.
        ENDDO.
      ENDIF.
      "Just pass 1=red or 2=yellow or 3=green to lights fields
      LOOP AT i_lights INTO w_lights .
        IF sy-tabix BETWEEN 1 AND 3.
          w_lights-lights = '1'.
        ELSEIF sy-tabix BETWEEN 4 AND 7.
          w_lights-lights = '2'.
        ELSEIF sy-tabix BETWEEN 8 AND 10.
          w_lights-lights = '3'.
        ENDIF.
        MODIFY i_lights FROM w_lights INDEX sy-tabix TRANSPORTING lights.
      ENDLOOP.
    ENDFORM.                    " get_data
    *&      Form  build_fieldcatlog
    FORM build_fieldcatlog .
      CLEAR:w_fieldcat,i_fieldcat[].
      w_fieldcat-fieldname     = 'MATNR'.
      w_fieldcat-seltext_m     = 'MATNR'.
      APPEND w_fieldcat TO i_fieldcat.
      CLEAR w_fieldcat.
      w_fieldcat-fieldname     = 'WERKS'.
      w_fieldcat-seltext_m     = 'WERKS'.
      APPEND w_fieldcat TO i_fieldcat.
      CLEAR w_fieldcat.
      w_fieldcat-fieldname     = 'LGORT'.
      w_fieldcat-seltext_m     = 'LGORT'.
      APPEND w_fieldcat TO i_fieldcat.
      CLEAR w_fieldcat.
    ENDFORM.                    " build_fieldcatlog
    *&      Form  build_layout
    FORM build_layout .
      w_layout-colwidth_optimize = 'X'.
      w_layout-zebra             = 'X'.
      w_layout-lights_fieldname  = 'LIGHTS'.
      w_layout-lights_tabname    = 'I_LIGHTS'.
    ENDFORM.                    " build_layout
    *&      Form  list_display
    FORM list_display .
      DATA:
            l_program TYPE sy-repid.
      l_program = sy-repid.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program = l_program
          is_layout          = w_layout
          it_fieldcat        = i_fieldcat
        TABLES
          t_outtab           = i_lights
        EXCEPTIONS
          program_error      = 1
          OTHERS             = 2.
      IF sy-subrc  0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " list_display
    Thanks,
    Tharangini

    Hi!
    Try this code.I have removed the previous code where you specify Lights in layout.I specified the lights column in fieldcatalog as Icon and passed the icon value instead of the no.s which you specified earlier.
    "Includes
    INCLUDE <icon>.
    INCLUDE <symbol>.
    *& Declaration part
    "Types
    TYPES:
    BEGIN OF t_lights,
    matnr TYPE mard-matnr,
    werks TYPE mard-werks,
    lgort TYPE mard-lgort,
    lights(4),
    END OF t_lights.
    "Work Areas
    DATA:
    w_lights TYPE t_lights.
    "Internal tables
    DATA:
    i_lights TYPE STANDARD TABLE OF t_lights.
    TYPE-POOLS:
    slis.
    TYPES:
    t_fieldcat TYPE slis_fieldcat_alv,
    t_events TYPE slis_alv_event,
    t_layout TYPE slis_layout_alv.
    DATA:
    w_fieldcat TYPE t_fieldcat,
    w_events TYPE t_events,
    w_layout TYPE t_layout.
    DATA:
    i_fieldcat TYPE STANDARD TABLE OF t_fieldcat,
    i_events TYPE STANDARD TABLE OF t_events.
    *& start of selection
    START-OF-SELECTION.
      PERFORM get_data.
    *& end-of-selection.
    END-OF-SELECTION.
      PERFORM build_fieldcatlog.
      PERFORM build_layout.
      PERFORM list_display.
    *& Form get_data
    FORM get_data .
      SELECT matnr
      werks
      lgort
      FROM mard
      INTO CORRESPONDING FIELDS OF TABLE i_lights
      UP TO 10 ROWS.
      IF i_lights[] IS INITIAL.
        "Dummy data
        DO 10 TIMES.
          w_lights-matnr = sy-index.
          w_lights-werks = sy-index + 1.
          w_lights-lgort = sy-index + 2.
          APPEND w_lights TO i_lights.
          CLEAR w_lights.
        ENDDO.
      ENDIF.
      "Just pass @0A@=red or @09@=yellow or @08@=green to lights fields
      LOOP AT i_lights INTO w_lights .
        IF sy-tabix BETWEEN 1 AND 3.
          w_lights-lights = '@0A@'.
        ELSEIF sy-tabix BETWEEN 4 AND 7.
          w_lights-lights = '@09@'.
        ELSEIF sy-tabix BETWEEN 8 AND 10.
          w_lights-lights = '@08@'.
        ENDIF.
        MODIFY i_lights FROM w_lights INDEX sy-tabix TRANSPORTING lights.
      ENDLOOP.
    ENDFORM. " get_data
    *& Form build_fieldcatlog
    FORM build_fieldcatlog .
      CLEAR:w_fieldcat,i_fieldcat[].
      w_fieldcat-fieldname = 'MATNR'.
      w_fieldcat-seltext_m = 'MATNR'.
      APPEND w_fieldcat TO i_fieldcat.
      CLEAR w_fieldcat.
      w_fieldcat-fieldname = 'WERKS'.
      w_fieldcat-seltext_m = 'WERKS'.
      APPEND w_fieldcat TO i_fieldcat.
      CLEAR w_fieldcat.
      w_fieldcat-fieldname = 'LGORT'.
      w_fieldcat-seltext_m = 'LGORT'.
      APPEND w_fieldcat TO i_fieldcat.
      CLEAR w_fieldcat.
      w_fieldcat-fieldname = 'LIGHTS'.
      w_fieldcat-icon = 'X'.
      w_fieldcat-outputlen = 14.
      w_fieldcat-seltext_l = 'Traffic Lights'.
      w_fieldcat-seltext_s = 'Traffic Lights'.
      w_fieldcat-seltext_m = 'Traffic Lights'.
      APPEND w_fieldcat TO i_fieldcat.
      CLEAR w_fieldcat.
    ENDFORM. " build_fieldcatlog
    *& Form build_layout
    FORM build_layout .
      w_layout-colwidth_optimize = 'X'.
      w_layout-zebra = 'X'.
    ENDFORM. " build_layout
    *& Form list_display
    FORM list_display .
      DATA:
      l_program TYPE sy-repid.
      l_program = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program = l_program
          is_layout          = w_layout
          it_fieldcat        = i_fieldcat
        TABLES
          t_outtab           = i_lights
        EXCEPTIONS
          program_error      = 1
          OTHERS             = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM. " list_display

  • Traffic lights ( ICONs)

    Hi frnds,
    I am printing the Traffic lights ( Red, Yellow, Green) in the ALV report using the ICON symbol.
    The same output i am generating in the layout through smartforms. But I am not able to print the ICONs (Red, Yellow, Green) in the layout. I am getting those as Hexadecimal values. Is there any other way to display without upload those images thru SE78?
    Points will be rewarded for helpful answers.
    Regards,
    Balu

    create a TEXTELEMENT in the smartform   there you will find
    include--> character->SAPICONS
    There  you can select the traffic lights you need.
    if you want to display these lights for certain conditions  write
    th condition in thcondition tab of the same text element.
    Reward if useful.

  • How we can   drill-down, sorting, traffic lights,  in ALV report

    hi gurus ,
    how we can   drill-down, sorting, traffic lights,  in ALV report .
    please any one suggest that...
    regards,
    praveen

    Check the sample code for drill-down, sorting, traffic lights,  in ALV report.
    REPORT YMS_COLOURALV NO STANDARD PAGE HEADING.
    TYPE-POOLS: SLIS, ICON.
    DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
    DATA: BEGIN OF IMARA OCCURS 0,
    LIGHT(4) TYPE C,
    MATNR TYPE MARA-MATNR,
    MTART TYPE MARA-MTART,
    MAKTX TYPE MAKT-MAKTX,
    COLOR_LINE(4) TYPE C,
    TCOLOR TYPE SLIS_T_SPECIALCOL_ALV, "cell
    END OF IMARA.
    DATA: XCOLOR TYPE SLIS_SPECIALCOL_ALV.
    START-OF-SELECTION.
    PERFORM GET_DATA.
    PERFORM WRITE_REPORT.
    FORM GET_DATA.
    WRITE ICON_GREEN_LIGHT AS ICON TO IMARA-LIGHT.
    IMARA-MATNR = 'ABC'.
    IMARA-MTART = 'ZCFG'.
    IMARA-MAKTX = 'This is description for ABC'.
    APPEND IMARA.
    WRITE ICON_YELLOW_LIGHT AS ICON TO IMARA-LIGHT.
    IMARA-MATNR = 'DEF'.
    IMARA-MTART = 'ZCFG'.
    IMARA-MAKTX = 'This is description for DEF'.
    APPEND IMARA.
    WRITE ICON_RED_LIGHT AS ICON TO IMARA-LIGHT.
    IMARA-MATNR = 'GHI'.
    IMARA-MTART = 'ZCFG'.
    IMARA-MAKTX = 'This is description for GHI'.
    APPEND IMARA.
    LOOP AT IMARA.
    IF SY-TABIX = 1.
    IMARA-COLOR_LINE = 'C410'. " color line
    ENDIF.
    IF SY-TABIX = 2. " color CELL
    CLEAR XCOLOR.
    XCOLOR-FIELDNAME = 'MTART'.
    XCOLOR-COLOR-COL = '3'.
    XCOLOR-COLOR-INT = '1'. " Intensified on/off
    XCOLOR-COLOR-INV = '0'.
    APPEND XCOLOR TO IMARA-TCOLOR.
    ENDIF.
    MODIFY IMARA.
    ENDLOOP.
    ENDFORM. "get_data
    FORM WRITE_REPORT.
    DATA: LAYOUT TYPE SLIS_LAYOUT_ALV.
    LAYOUT-COLTAB_FIELDNAME = 'TCOLOR'.
    LAYOUT-INFO_FIELDNAME = 'COLOR_LINE'.
    PERFORM BUILD_FIELD_CATALOG.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    IS_LAYOUT = LAYOUT
    IT_FIELDCAT = FIELDCAT
    TABLES
    T_OUTTAB = IMARA.
    ENDFORM. "write_report
    FORM BUILD_FIELD_CATALOG.
    DATA: FC_TMP TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
    CLEAR: FIELDCAT. REFRESH: FIELDCAT.
    CLEAR: FC_TMP.
    FC_TMP-REPTEXT_DDIC = 'Status'.
    FC_TMP-FIELDNAME = 'LIGHT'.
    FC_TMP-TABNAME = 'IMARA'.
    FC_TMP-OUTPUTLEN = '4'.
    FC_TMP-ICON = 'X'.
    APPEND FC_TMP TO FIELDCAT.
    CLEAR: FC_TMP.
    FC_TMP-REPTEXT_DDIC = 'Material Number'.
    FC_TMP-FIELDNAME = 'MATNR'.
    FC_TMP-TABNAME = 'IMARA'.
    FC_TMP-OUTPUTLEN = '18'.
    APPEND FC_TMP TO FIELDCAT.
    CLEAR: FC_TMP.
    FC_TMP-REPTEXT_DDIC = 'Material Type'.
    FC_TMP-FIELDNAME = 'MTART'.
    FC_TMP-TABNAME = 'IMARA'.
    FC_TMP-OUTPUTLEN = '10'.
    APPEND FC_TMP TO FIELDCAT.
    CLEAR: FC_TMP.
    FC_TMP-REPTEXT_DDIC = 'Material'.
    FC_TMP-FIELDNAME = 'MAKTX'.
    FC_TMP-TABNAME = 'IMARA'.
    FC_TMP-OUTPUTLEN = '40'.
    APPEND FC_TMP TO FIELDCAT.
    ENDFORM. "build_field_catalog

  • How to print traffic lights in ALV reports

    hi how to print traffic lights on selection screen in alv reports

    HI,
    check below code
    TYPE-POOLS : icon.
    types:  BEGIN OF ty_display,
            status     TYPE icon-id,
            bukrs      TYPE bseg-bukrs,
            gjahr      TYPE bseg-gjahr,
            monat      TYPE monat,
            work_order TYPE z_work_order,
            glaccount  TYPE saknr,
            message    TYPE string,
          END OF ty_display.
    data : it_display     TYPE TABLE OF ty_display,
             wa_display TYPE ty_display.
    WRITE icon_led_green AS ICON TO wa_display-status.
            wa_display-gjahr = p_year.
            wa_display-bukrs = p_cc.
            wa_display-monat = p_period.
            wa_display-work_order = v_aufnr.
            wa_display-glaccount = wa_bseg-hkont.
        APPEND wa_display TO it_display.
    WRITE icon_led_red AS ICON TO wa_display-status.
              wa_display-gjahr      = p_year.
              wa_display-bukrs      = p_cc.
              wa_display-monat      = p_period.
              wa_display-work_order = v_aufnr.
              wa_display-glaccount  = wa_bseg-hkont.
              wa_display-message    = text-010.
              APPEND wa_display TO it_display.
    change the icon color based on your requirement and append it to the internal table which you have to display in ALV.
    reward points if it is helpful.
    Regards,
    Srilatha

  • How to use traffic lights concept in alv in webdynpro abap

    Hai ,
              How to use traffic lights concept for alv in webdynpro abap. If possible give me some code.

    Hi Ravi,
    You can create ICON  to get traffic light.
    Go through this step by step.. in this example
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/1190424a-0801-0010-84b5-ef03fd2d33d9?quicklink=index&overridelayout=true
    Please go through this...
    Re: Display ICON in the ALV table column
    Re: Image in ALV
    cheers,
    Kris.

  • How to show traffic lights on push button in ALV Grid?

    Hi Experts,
    I have an requirement where I have to show traffic lights on push button in ALV grid of a container. I am showing access sequence for each condition type in my grid. Now, if the access sequence contains 'PLANT', it should show 'green' on push button or else it should show 'red'. How I can I achieve this?
    Thanks in advance.

    Try This One.
    DATA: gs_fieldcat TYPE slis_fieldcat_alv,
              gt_fieldcat TYPE slis_t_fieldcat_alv,
              gs_layout   TYPE  slis_layout_alv.
    TYPES :BEGIN OF gty_temp,
                col(10) TYPE c,
               END OF gty_temp.
    DATA : gt_temp TYPE STANDARD TABLE OF gty_temp,
                gs_temp TYPE gty_temp.
       gs_temp-col  ='@0A@'. "ERROR RED LIGHT
           APPEND gs_temp TO   gt_temp.
        CLEAR GS_TEMP.
    gs_temp-col  = '@08@'." SUCCESS GREEN LIGHT
    APPEND gs_temp TO   gt_temp.
    CLAER GS_TEMP.
    gs_temp-col  = '@09@'. WARNING YELLOW LIGHT
    APPEND gs_temp TO   gt_temp.
    CLAER GS_TEMP.
    gs_fieldcat-fieldname   = ' COL'.
    gs_fieldcat-tabname   =  'GT_TEMP'.
    gs_fieldcat-seltext_m = 'ERROR'."
    APPEND gs_fieldcat TO gt_fieldcat.
    CLEAR gs_fieldcat.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         i_callback_program = 'ZPROG1' " PROGRAM NAME
         i_grid_title       = 'Details'
    *   is_layout          = gs_layout
         it_fieldcat        = gt_fieldcat
       TABLES
         t_outtab           = gt_temp.
    * EXCEPTIONS
    *   PROGRAM_ERROR                     = 1
    *   OTHERS                            = 2
    IF sy-subrc <> 0.
    * Implement suitable error handling here
    ENDIF.

  • How to change the Traffic light positioning in ALV?

    Hai All,
    I am displaying a traffic light field in my ALV Grid. Now i want to display another field in the first position and move the traffic light to second or any other position. COL_POS seems to be not working, is there any chance of doing this?
    Best regards,
    rama

    >
    newtoAbap wrote:
    > Hai All,
    >
    > I am displaying a traffic light field in my ALV Grid. Now i want to display another field in the first position and move the traffic light to second or any other position. COL_POS seems to be not working, is there any chance of doing this?
    >
    > Best regards,
    > rama
    If you are using EXCP_FNAME in the ALV layout to display your traffic lights, it may not be possible to move your light field to any other position..
    One possiblity is to define your own field (as icon) in the internal table and assign the Traffic light icon to that field... By this approach, you can position that field in any place in your input structure while generating field catalog or defining your structure
    Here is an example with SALV,
    http://wiki.sdn.sap.com/wiki/display/Snippets/displayingiconsinalvusingclasscl_salv_table
    Example with icons in REUSE FM (can be used in ALV OO) and there should be umpteen examples in SDN also
    http://wiki.sdn.sap.com/wiki/display/Snippets/TrafficlightsinALVdisplay

  • How to put up the traffic lights icon in the ALV Grid. OO output

    Hi all,
    I have a requriement that after all the report execution parts are done, i need to display the posted or unposted document using the Traffic light icon in the report output, i am displaying the report in ALV OO form and i already geta  field with a conent X of the document is posted else that field is blank currently.
    Regards

    Sample code here for this.
    *& Report  Z_50657_ALV_EX2                                             *
    *& Program Name: Test Program for ALV                                  *
    *  Developer Name: ADCDEV (Rahul Kavuri )                              *
    *  Description: ALV Report to Display Vendor Details                   *
    *& Date:7th April 2006                                                 *
    REPORT  Z_50657_ALV_EX2
            NO STANDARD PAGE HEADING
            LINE-COUNT 65(3)
            LINE-SIZE 220
            MESSAGE-ID ZZ.
    *                             Type Pools                               *
    TYPE-POOLS: SLIS, ICON.
    *                              Tables                                  *
    TABLES: VBAK. "Sales Document Data
    *                         Internal Tables                              *
    * TABLE TO HOLD DATA OF SALES DOCUMENT
    DATA: BEGIN OF IT_VBAK OCCURS 0,
          VBELN LIKE VBAK-VBELN, "Sales Document
          VBTYP LIKE VBAK-VBTYP, "SD document category
          AUDAT LIKE VBAK-AUDAT, "Document date (date received/sent)
          AUGRU LIKE VBAK-AUGRU, "Order reason (reason for the business)
          AUART LIKE VBAK-AUART, "Sales Document Type
          NETWR LIKE VBAK-NETWR, "Net Sales Order in Doc. Currency
          WAERK LIKE VBAK-WAERK, "SD document currency
          ICON TYPE ICON-ID,     "traffic lights
          END OF IT_VBAK.
    *                             Work Areas                               *
    *WORK AREAS DEFINED FOR ALV'S
    DATA: WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,      "field catalog
          IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,     "field catalog ITAB
          WA_SORT TYPE SLIS_SORTINFO_ALV,           "SORT work area
          IT_SORT TYPE SLIS_T_SORTINFO_ALV,         "SORT ITAB
          LAYOUT TYPE SLIS_LAYOUT_ALV,              "LAYOUT
          WA_FCODE TYPE SLIS_EXTAB,                 "FUN CODE
          I_FCODE_EXTAB TYPE SLIS_T_EXTAB,
          WA_EVENTS TYPE SLIS_ALV_EVENT,
          IT_EVENTS TYPE SLIS_T_EVENT.
    *                       Selection-Screen                               *
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
    SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.
    PARAMETERS: P_VBTYP LIKE VBAK-VBTYP DEFAULT 'C'.
    SELECTION-SCREEN END OF BLOCK B1.
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME.
    PARAMETERS: LIST RADIOBUTTON GROUP G1,
                GRID RADIOBUTTON GROUP G1.
    SELECTION-SCREEN END OF BLOCK B2.
    *                     At  Selection-Screen                             *
    *VALIDATION
    *                       Start of Selection                             *
    START-OF-SELECTION.
    *POPULATION OF DATA INTO INTERNAL TABLE ITAB
      PERFORM GET_DATA.
    *DEFINE USER DEFINED FIELDCATALOG
      PERFORM DEFINE_FIELDCATALOG.
    *SUBTOTALS AND TOTALS DISPLAY USING SORT
      PERFORM SORT_LIST.
    *CHANGE FCODE OF STATUS
      PERFORM CHANGE_FCODE.
    *CHECK RADIOBUTTON OPTION AND ACCORDINGLY FINAL DISPLAY
      PERFORM CHECK_OPTION.
    *&      Form  GET_DATA
    *       text
    FORM GET_DATA.
      SELECT VBELN
             VBTYP
             AUDAT
             AUGRU
             AUART
             NETWR
             WAERK FROM VBAK INTO TABLE IT_VBAK
             WHERE VBELN IN S_VBELN AND VBTYP = P_VBTYP
             AND ERDAT > '01.01.2004' AND NETWR > 0.
      LOOP AT IT_VBAK.
        IF IT_VBAK-NETWR < 10000.
          IT_VBAK-ICON = '@08@'.
        ELSEIF IT_VBAK-NETWR > 100000.
          IT_VBAK-ICON = '@0A@'.
        ELSE.
          IT_VBAK-ICON = '@09@'.
        ENDIF.
        MODIFY IT_VBAK INDEX SY-TABIX.
      ENDLOOP.
    ENDFORM.                    "GET_DATA
    *&      Form  CHECK_OPTION
    *       text
    FORM CHECK_OPTION.
      WA_EVENTS-NAME = 'TOP_OF_PAGE'.
      WA_EVENTS-FORM = 'TOP'.
      APPEND WA_EVENTS TO IT_EVENTS.
      CLEAR WA_EVENTS.
      WA_EVENTS-NAME = 'END_OF_LIST'.
      WA_EVENTS-FORM = 'END_LIST'.
      APPEND WA_EVENTS TO IT_EVENTS.
      CLEAR WA_EVENTS.
      IF LIST = 'X'.
        PERFORM LIST_DISP.
      ENDIF.
      IF GRID = 'X'.
        PERFORM GRID_DISP.
      ENDIF.
    ENDFORM.                    "CHECK_OPTION
    *&      Form  DEFINE_FIELDCATALOG
    *       text
    FORM DEFINE_FIELDCATALOG.
      WA_FIELDCAT-COL_POS = 1.
      WA_FIELDCAT-FIELDNAME = 'ICON'.
      WA_FIELDCAT-SELTEXT_L = 'ICON'.
      WA_FIELDCAT-ICON = 'X'.
      WA_FIELDCAT-OUTPUTLEN = 8.
      WA_FIELDCAT-TABNAME = 'IT_VBAK'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-COL_POS = 2.
      WA_FIELDCAT-FIELDNAME = 'VBELN'.
      WA_FIELDCAT-SELTEXT_L = 'SALES DOC NO.'.
      WA_FIELDCAT-OUTPUTLEN = 10.
      WA_FIELDCAT-TABNAME = 'IT_VBAK'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-COL_POS = 3.
      WA_FIELDCAT-FIELDNAME = 'AUDAT'.
      WA_FIELDCAT-SELTEXT_L = 'CREATED ON'.
      WA_FIELDCAT-OUTPUTLEN = 10.
      WA_FIELDCAT-TABNAME = 'IT_VBAK'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-COL_POS = 4.
      WA_FIELDCAT-FIELDNAME = 'VBTYP'.
      WA_FIELDCAT-SELTEXT_L = 'CATEGORY'.
      WA_FIELDCAT-OUTPUTLEN = 1.
      WA_FIELDCAT-TABNAME = 'IT_VBAK'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-COL_POS = 6.
      WA_FIELDCAT-FIELDNAME = 'AUGRU'.
      WA_FIELDCAT-SELTEXT_L = 'REASON'.
      WA_FIELDCAT-OUTPUTLEN = 3.
      WA_FIELDCAT-TABNAME = 'IT_VBAK'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-COL_POS = 5.
      WA_FIELDCAT-FIELDNAME = 'AUART'.
      WA_FIELDCAT-SELTEXT_L = 'DOC TYPE'.
      WA_FIELDCAT-OUTPUTLEN = 4.
      WA_FIELDCAT-TABNAME = 'IT_VBAK'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-COL_POS = 7.
      WA_FIELDCAT-FIELDNAME = 'NETWR'.
      WA_FIELDCAT-SELTEXT_L = 'NET VALUE'.
      WA_FIELDCAT-OUTPUTLEN = 17.
      WA_FIELDCAT-DECIMALS_OUT = 2.
    *  WA_FIELDCAT-DO_SUM = 'X'.
      WA_FIELDCAT-TABNAME = 'IT_VBAK'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-COL_POS = 8.
      WA_FIELDCAT-FIELDNAME = 'WAERK'.
      WA_FIELDCAT-SELTEXT_L = 'UNIT'.
      WA_FIELDCAT-OUTPUTLEN = 50.
      WA_FIELDCAT-TABNAME = 'IT_VBAK'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
    ENDFORM.                    "DEFINE_FIELDCATALOG
    *&      Form  DEFINE_LAYOUT
    *       text
    FORM DEFINE_LAYOUT.
      LAYOUT-ZEBRA = 'X'.
      LAYOUT-SUBTOTALS_TEXT = 'SUBTOTAL SUM'.
      LAYOUT-WINDOW_TITLEBAR = 'EXERCISE 2'.
      LAYOUT-TOTALS_TEXT  = 'TOTAL'.
    ENDFORM.                    "DEFINE_LAYOUT
    *&      Form  SORT_LIST
    *       text
    FORM SORT_LIST.
      WA_SORT-FIELDNAME = 'VBELN'.
      WA_SORT-TABNAME = 'IT_VBAK'.
      WA_SORT-SPOS = 1.
      WA_SORT-UP = 'X'.
      WA_SORT-SUBTOT = 'X'.
      APPEND WA_SORT TO IT_SORT.
      CLEAR WA_SORT.
      WA_SORT-FIELDNAME = 'NETWR'.
      WA_SORT-TABNAME = 'IT_VBAK'.
      WA_SORT-UP = 'X'.
      WA_SORT-SPOS = 2.
      WA_SORT-SUBTOT = 'X'.
      APPEND WA_SORT TO IT_SORT.
      CLEAR WA_SORT.
    ENDFORM.                    "SORT_LIST
    *&      Form  LIST_DISP
    *       text
    FORM LIST_DISP.
      PERFORM DEFINE_LAYOUT.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
         I_CALLBACK_PROGRAM             = SY-REPID
         IT_FIELDCAT                    = IT_FIELDCAT
         IS_LAYOUT                      = LAYOUT
         IT_SORT                        = IT_SORT
         I_CALLBACK_PF_STATUS_SET       = 'STATUS'
         IT_EXCLUDING                   = I_FCODE_EXTAB
         I_CALLBACK_USER_COMMAND        = 'USER_COMMAND'
         IT_EVENTS                      = IT_EVENTS[]
    *   IMPORTING
    *     E_EXIT_CAUSED_BY_CALLER        =
    *     ES_EXIT_CAUSED_BY_USER         =
        TABLES
         T_OUTTAB                       = IT_VBAK
    *   EXCEPTIONS
    *     PROGRAM_ERROR                  = 1
    *     OTHERS                         = 2
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "LIST_DISP
    *&      Form  GRID_DISP
    *       text
    FORM GRID_DISP.
      PERFORM DEFINE_LAYOUT.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM       = SY-REPID
          IS_LAYOUT                = LAYOUT
          IT_FIELDCAT              = IT_FIELDCAT
          IT_SORT                  = IT_SORT
          I_CALLBACK_PF_STATUS_SET = 'STATUS'
          IT_EXCLUDING             = I_FCODE_EXTAB
          I_CALLBACK_USER_COMMAND  = 'USER_COMMAND'
          IT_EVENTS                = IT_EVENTS[]
        TABLES
          T_OUTTAB                 = IT_VBAK.
    * EXCEPTIONS
    *   PROGRAM_ERROR                     = 1
    *   OTHERS                            = 2
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "GRID_DISP
    *&      Form  STATUS
    *       text
    *      -->P_EXTAB    text
    FORM STATUS USING P_EXTAB TYPE SLIS_T_EXTAB.
      SET PF-STATUS 'STATUS' EXCLUDING P_EXTAB.
    ENDFORM.                    "STATUS
    *&      Form  USER_COMMAND
    *       text
    *      -->R_UCOMM      text
    *      -->RS_SELFIELD  text
    FORM USER_COMMAND USING R_UCOMM     LIKE SY-UCOMM
                                   RS_SELFIELD TYPE SLIS_SELFIELD.
      CASE R_UCOMM.
        WHEN 'BACK' OR 'CANC' OR 'EXIT'.
          LEAVE TO SCREEN 0.
        WHEN '&IC1'.
          SET PARAMETER ID 'AUN' FIELD RS_SELFIELD-VALUE.
          CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
      ENDCASE.
    ENDFORM.                    "USER_COMMAND
    *&      Form  CHANGE_FCODE
    *       text
    FORM CHANGE_FCODE.
      WA_FCODE = 'PRNT'.
      APPEND WA_FCODE TO I_FCODE_EXTAB.
      WA_FCODE = '&OAD'.
      APPEND WA_FCODE TO I_FCODE_EXTAB.
      WA_FCODE = '&AVE'.
      APPEND WA_FCODE TO I_FCODE_EXTAB.
      WA_FCODE = '&EB9'.
      APPEND WA_FCODE TO I_FCODE_EXTAB.
      WA_FCODE = '&SUM'.
      APPEND WA_FCODE TO I_FCODE_EXTAB.
      WA_FCODE = '&UMC'.
      APPEND WA_FCODE TO I_FCODE_EXTAB.
      WA_FCODE = '&XPA'.
      APPEND WA_FCODE TO I_FCODE_EXTAB.
      WA_FCODE = '&OMP'.
      APPEND WA_FCODE TO I_FCODE_EXTAB.
    ENDFORM.                    "CHANGE_FCODE
    *&      Form  TOP
    *       text
    FORM TOP.
      IF LIST = 'X'.
        WRITE:/ SY-ULINE.
        WRITE:/ 'DATE:', SY-DATUM,55 'INTELLIGROUP ASIA PVT LTD'.
        WRITE:/ 'TIME:', SY-UZEIT.
        WRITE:/ 'USER NAME:', SY-UNAME,60 SY-TITLE.
        WRITE:/ 'PAGE', SY-PAGNO.
        WRITE:/ SY-ULINE.
      ENDIF.
      IF GRID = 'X'.
        DATA: LS_LINE TYPE SLIS_LISTHEADER,
              E04_LT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
    *   Listenüberschrift: Typ H
        CLEAR LS_LINE.
        LS_LINE-TYP  = 'H'.
    *   LS_LINE-KEY:  not used for this type
        LS_LINE-INFO = 'Summary'.
        APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.
    *   Kopfinfo: Typ S
        CLEAR LS_LINE.
        LS_LINE-TYP  = 'S'.
        LS_LINE-KEY  = 'Intelligroup'.
        LS_LINE-INFO = ''.
        APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.
        LS_LINE-KEY  = 'ASIA'.
        LS_LINE-INFO = 'PVT LTD'.
        APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.
    *   Aktionsinfo: Typ A
        CLEAR LS_LINE.
        LS_LINE-TYP  = 'A'.
    *   LS_LINE-KEY:  not used for this type
        LS_LINE-INFO = 'truman'.
        APPEND LS_LINE TO  E04_LT_TOP_OF_PAGE.
        CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
          EXPORTING
            IT_LIST_COMMENTARY = E04_LT_TOP_OF_PAGE
            I_LOGO             = 'ENJOY_SAP_LOGO'.
      ENDIF.
    ENDFORM.                    "TOP
    *&      Form  END_LIST
    *       text
    FORM END_LIST.
      IF LIST = 'X'.
        SKIP 2.
        WRITE:/60 'END OF PAGE'.
      ENDIF.
      IF GRID = 'X'.
          DATA: LS_LINE TYPE SLIS_LISTHEADER,
              E04_LT_END_OF_LIST TYPE SLIS_T_LISTHEADER.
    *   Listenüberschrift: Typ H
        CLEAR LS_LINE.
        LS_LINE-TYP  = 'H'.
    *   LS_LINE-KEY:  not used for this type
        LS_LINE-INFO = 'Summary'.
        APPEND LS_LINE TO E04_LT_END_OF_LIST.
    *   Kopfinfo: Typ S
        CLEAR LS_LINE.
        LS_LINE-TYP  = 'S'.
        LS_LINE-KEY  = 'Intelligroup'.
        LS_LINE-INFO = ''.
        APPEND LS_LINE TO E04_LT_END_OF_LIST.
        LS_LINE-KEY  = 'ASIA'.
        LS_LINE-INFO = 'PVT LTD'.
        APPEND LS_LINE TO E04_LT_END_OF_LIST.
    *   Aktionsinfo: Typ A
        CLEAR LS_LINE.
        LS_LINE-TYP  = 'A'.
    *   LS_LINE-KEY:  not used for this type
        LS_LINE-INFO = TEXT-105.
        APPEND LS_LINE TO  E04_LT_END_OF_LIST.
        CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
          EXPORTING
            IT_LIST_COMMENTARY = E04_LT_END_OF_LIST.
      ENDIF.
    ENDFORM.                    "END_LIST

  • Traffic lights in ALV list header

    how do i display traffic lights as icons in ALV list header. for example, in the code below, i want to display a green icon at the end of closed items and a red icon at the end of the open items:
                closed : 4 [green-icon]
                open   : 2  [red-icon]
    CLEAR header_alv_wa-info.
      header_alv_wa-key  = 'closed:'.
      header_alv_wa-info = gv_closed.
      header_alv_wa-typ  = 'S'.
      APPEND header_alv_wa TO headeralv.
      CLEAR header_alv_wa-info.
      header_alv_wa-typ  = 'S'.
      header_alv_wa-key  = 'open:'.
      header_alv_wa-info = gv_open.
      APPEND header_alv_wa TO headeralv.

    Hi,
    http://www.sapfans.com/forums/viewtopic.php?t=79424
    http://www.sapfans.com/forums/viewtopic.php?t=24512
    the above links will give u the code for the same..
    Regards,
    Aparna

  • Traffic light in ALV

    dear Experts,
    i declared an attribute in my node to display traffic lights
    but how to declare in this in coding ?
    for example a checkbox is
    type ref to cl_salv_wd_uie_checkbox.
    Does the same exist for traffic lights ?
    Regards
    René

    Hi Rene,
    Check this Article Cladia explains very clearly how to place icons in the ALV.
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/3133474a-0801-0010-d692-81827814a5a1

  • Traffic light in RF monitor screen (LRF1) - how it is derive from?

    Hi,
    This is a question about WM-RF. My question is how does the system determine the traffic light color in the RF monitor screen (LRF1). I read the SAP help portal and compare it to the screen and it still doesn't make any sense out of it..
    On the SPRO, there is DEFINE QUEUE table, with thefollowing setup:
    WS--QUEUEQName-CapacUsed-CapacUsed----AccessLim
    110--B01_GEN-GenName610--
    2StrictLimitation
    Thus the relation is: 6/10 = 0.6
    Next, I went to LRF1 and saw this record with warehouse 110, and Queue B01GEN, and having the following value_:
    QUEUE -
    TOs--LOADProc.By--
    Propotion
    B01_GEN----150.0002--
    Green
    Thus the relation is: 15/2 = 7.5
    Why is it green? SAP help portal give the following explaination, and I don't know to derive it?
    A- The queue tranffic light is green if the relation is less than the value given in the left relation field.
    B - The queue traffic light is yellow if the relation is greater than or the same as the value specified in the right field.
    C - The queue traffic light is red if the relation is greater than or the same as the value specified in the left relation field.
    Please share if you know.
    Thanks..Tuff

    Hello,
    Does anyone know my question?
    Appreciate some help here.
    Thanks,
    tuff

  • Traffic Light in Dynamic ALV

    Hi All,
    I created dynamic ALV.I wan to show trafic light color RED,Yellow etc..
    If Quantity is less than some 'X' then traffic light should be Red.
    Please advise how to follow.This is possible in classical but in dynamic alv i need to do.
    Thank You,
    Anu.

    Hi,
    But in Dynamic alv we dont know the values.How we can fill up the field catalog for one value.
    Please advise if any coding.
    Thank You,
    Anu

  • How to display LED lights in end of page of ALV(factory method)

    Hello Experts,
    How do I display the LED lights in my end-of-page(red, yellow and green).
    Below is my code:
    METHOD display_end_of_page.
        CREATE OBJECT lcl_grid.
        lv_string = text-t04.
        lcl_label = lcl_grid->create_label(
                      row     = 1
                      column  = 1
                      text    = lv_string
                      tooltip = lv_string ).
        CLEAR lv_string.
        lv_string = ICON_GREEN_LIGHT.
        lcl_label = lcl_grid->create_label(
                      row     = 2
                      column  = 1
                      text    = lv_string
                      tooltip = lv_string ).
        lcl_label = lcl_grid->create_label(
                      row     = 3
                      column  = 1
                      text    = lv_string
                      tooltip = lv_string ).
        lcl_content = lcl_grid.
      ENDMETHOD.                    "display_end_of_page
    Hope you can help me guys.Thank you and take care!

    Hi,
    Use this code for Demo
    *& Report ZMDEMO_ALV_04
    *&Make an Exception field ( = Traffic lights)
    *&There can be defined a column in the grid for display of traffic lights. This field is of type Char 1, and can contain the following values:
    *& 1 Red
    *& 2 Yellow
    *& 3 Green
    *&The name of the traffic light field is supplied inh the gs_layout-excp_fname used by method set_table_for_first_display.
    report zmdemo_alv_04.
    tables: sflight.
    type-pools: icon.
    types: begin of ty_sflight.
    include structure sflight.
    types: traffic_light type c,
    lights LIKE icon_xml_doc,
    lights(4),
    icon type icon-id.
    types: end of ty_sflight.
    G L O B A L I N T E R N A L T A B L E S
    data: t_sflight type standard table of ty_sflight.
    G L O B A L D A T A
    data: ok_code like sy-ucomm,
    wa_sflight type ty_sflight.
    Declare reference variables to the ALV grid and the container
    data:
    go_grid type ref to cl_gui_alv_grid,
    go_custom_container type ref to cl_gui_custom_container.
    data:
    t_fcat type lvc_t_fcat,
    wa_layout type lvc_s_layo.
    S T A R T - O F - S E L E C T I O N.
    start-of-selection.
    perform build_fieldcat.
    perform build_layout.
    set screen '100'.
    *& Module USER_COMMAND_0100 INPUT
    module user_command_0100 input.
    case ok_code.
    when 'EXIT'.
    leave to screen 0.
    endcase.
    endmodule. " USER_COMMAND_0100 INPUT
    *& Module STATUS_0100 OUTPUT
    module status_0100 output.
    Create objects
    if go_custom_container is initial.
    create object go_custom_container
    exporting container_name = 'ALV_CONTAINER'.
    create object go_grid
    exporting
    i_parent = go_custom_container.
    perform load_data_into_grid.
    endif.
    endmodule. " STATUS_0100 OUTPUT
    *& Form load_data_into_grid
    form load_data_into_grid.
    data l_light type c value '1'.
    Read data from table SFLIGHT
    select *
    from sflight
    into table t_sflight.
              o
                    + Condition placing to the traffic_light Field
    LOOP AT t_sflight INTO wa_sflight.
    wa_sflight-traffic_light = l_light.
    MODIFY t_sflight FROM wa_sflight.
    IF l_light = '3'.
    l_light = '1'.
    ELSE.
    l_light = l_light + 1.
    ENDIF.
    ENDLOOP.
              o
                    + Setting the Icon based on the traffic_light field value.
    LOOP AT t_sflight INTO wa_sflight.
    CASE wa_sflight-traffic_light.
    WHEN '1'.
    wa_sflight-lights = icon_red_light.
    WHEN '2'.
    wa_sflight-lights = icon_yellow_light.
    WHEN '3'.
    wa_sflight-lights = icon_green_light.
    ENDCASE.
    MODIFY t_sflight FROM wa_sflight.
    ENDLOOP.
    loop at t_sflight into wa_sflight.
    case l_light.
    when '1'.
    wa_sflight-lights = icon_red_light.
    when '2'.
    wa_sflight-lights = icon_yellow_light.
    when '3'.
    wa_sflight-lights = icon_green_light.
    endcase.
    if l_light = '3'.
    l_light = '1'.
    else.
    l_light = l_light + 1.
    endif.
    modify t_sflight from wa_sflight.
    endloop.
    Load data into the grid and display them
    call method go_grid->set_table_for_first_display
    exporting
    I_BUFFER_ACTIVE =
    I_BYPASSING_BUFFER =
    I_CONSISTENCY_CHECK =
    i_structure_name = 'SFLIGHT'
    IS_VARIANT =
    i_save = 'A'
    I_DEFAULT = 'X'
    is_layout = wa_layout
    IS_PRINT =
    IT_SPECIAL_GROUPS =
    IT_TOOLBAR_EXCLUDING =
    IT_HYPERLINK =
    IT_ALV_GRAPHICS =
    IT_EXCEPT_QINFO =
    IR_SALV_ADAPTER =
    changing
    it_outtab = t_sflight[]
    it_fieldcatalog = t_fcat
    IT_SORT =
    IT_FILTER =
    EXCEPTIONS
    INVALID_PARAMETER_COMBINATION = 1
    PROGRAM_ERROR = 2
    TOO_MANY_LINES = 3
    others = 4
    endform. " load_data_into_grid
    *& Form build_fieldcat
    text
    --> p1 text
    <-- p2 text
    form build_fieldcat .
    data: w_fcat type lvc_s_fcat.
    define macro_fcat.
    w_fcat-fieldname = &1.
    w_fcat-col_pos = &2.
    w_fcat-coltext = &3.
    append w_fcat to t_fcat.
    clear w_fcat.
    end-of-definition.
    macro_fcat 'CARRID' 1 text-c01 .
    macro_fcat 'CONNID' 2 text-c02 .
    macro_fcat 'FLDATE' 3 text-c03 .
    macro_fcat 'PRICE' 4 text-c04 .
    macro_fcat 'SEATSMAX' 5 text-c05 .
    macro_fcat 'SEATSOCC' 6 text-c06 .
    macro_fcat 'LIGHTS' 7 text-c07 .
    endform. " build_fieldcat
    *& Form build_layout
    text
    --> p1 text
    <-- p2 text
    form build_layout .
    wa_layout-cwidth_opt = 'X'.
    wa_layout-excp_fname = 'TRAFFIC_LIGHT'.
    wa_layout-excp_group = '1'.
    endform. " build_layout
    Regards,
    Dhruv Shah

  • ALV Traffic lights for subtotal

    Hi,
    How can I use "traffic lights" that depend on the subtotals of one field in one ALV?
    Thank you

    Hi Nuno Barros,
    Please check the below link... it will guide you to fulfill your requirement..
    http://wiki.sdn.sap.com/wiki/display/Snippets/ALVGRIDCOMPLETEEXAMPLEWITHTOOLBARBUTTONSUSINGCLASS.
    http://www.erpgenie.com/sap/abap/controls/alvgrid.htm
    http://wiki.sdn.sap.com/wiki/display/Snippets/TrafficlightsinALVdisplay
    Or check this code...you may find it easy
    *& Declaration part
    TYPES: BEGIN OF t_lights,
          matnr  TYPE mard-matnr,
          werks  TYPE mard-werks,
          lgort  TYPE mard-lgort,
          lights TYPE char4,       "Variable is needs to be declared with length 4 char
       END OF t_lights.
    DATA: w_lights TYPE t_lights.
    DATA: i_lights TYPE STANDARD TABLE OF t_lights.
    FORM get_data .
    SELECT matnr werks lgort
    FROM mard
    INTO CORRESPONDING FIELDS OF TABLE i_lights UP TO 10 ROWS.
    "Just pass 1=red or 2=yellow or 3=green to lights fields ( HERE YOU CAN CHECK FOR YOUR CONDITION AND ASSIGN LIGHTS ACCORDIGLY)
    LOOP AT i_lights INTO w_lights .
    IF sy-tabix BETWEEN 1 AND 3.
    w_lights-lights = '1'.
    ELSEIF sy-tabix BETWEEN 4 AND 7.
    w_lights-lights = '2'.
    ELSEIF sy-tabix BETWEEN 8 AND 10.
    w_lights-lights = '3'.
    ENDIF.
    MODIFY i_lights FROM w_lights INDEX sy-tabix TRANSPORTING lights.
    ENDLOOP.
    ENDFORM.                    " get_data
    *&      Form  build_layout
    FORM build_layout .
    w_layout-colwidth_optimize = 'X'.
    w_layout-zebra             = 'X'.
    w_layout-lights_fieldname  = 'LIGHTS'.
    w_layout-lights_tabname    = 'I_LIGHTS'.
    w_layout-lights_rollname   = 'Hits'.
    ENDFORM.                    " build_layout
    *&      Form  list_display
    FORM list_display .
    DATA:
    l_program TYPE sy-repid.
    l_program = sy-repid.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    i_callback_program = l_program
    is_layout          = w_layout
    it_fieldcat        = i_fieldcat
    TABLES
    t_outtab           = i_lights
    EXCEPTIONS
    program_error      = 1
    OTHERS             = 2.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    ENDFORM.                    " list_display
    Thanks
    Shankar

Maybe you are looking for