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

How to add Traffic Lights to a Report?

Hi,

How do U create a Traffic Light? and how to you change the Light? That's all I need.

Thanks,

Kishan

Add a comment
10|10000 characters needed characters exceeded

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Aug 11, 2005 at 12:29 PM

    Hi,

    Here is some hint to display the traffic lines in a report.

    Write ICON_GREEN_LIGHT AS ICON.

    Write ICON_YELLOW_LIGHT AS ICON.

    Write ICON_RED_LIGHT AS ICON.

    Best Regards,

    Vijay

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 11, 2005 at 12:30 PM

    Hi,

    Check the program BCALV_GRID_04.

    regards

    Aveek

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 11, 2005 at 12:42 PM

    Hi Kishan,

    1)

    Write ICON_GREEN_LIGHT AS ICON. "status 1

    2)

    READ LINE SY-INDEX FIELD VALUE 
       itab-MARK  INTO H_MARK.

    3)

    modify itab-status . "status2

    4)

    refresh your output:
       Write ICON_red_LIGHT AS ICON. "status 2

    regards Andreas

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 11, 2005 at 12:53 PM

    Hi Kishan,

    Before trying Vijaya's code, do not forget to add the following includes.

    <b>INCLUDE <ICON>.</b>

    or <b>INCLUDE <LIST>.</b>

    <b><LIST></b> is a superset of <b><ICON></b>. It contains the Type-Pool defination for <b><SYMBOL>, <ICON>, <LINE>, <COLOR></b>.

    Hope this helps.

    Best Regards,

    Sanyam

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 11, 2005 at 02:43 PM

    I tried your suggestions

    REPORT Z_TEST_ICON .

    Write ICON_GREEN_LIGHT AS ICON.

    Write ICON_YELLOW_LIGHT AS ICON.

    Write ICON_RED_LIGHT AS ICON.

    But this is what I get:

    Field "ICON_GREEN_LIGHT" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Judith Jessie Selvi

      hi dude,

      This is the way u add lights to ur alv report.

      I'm following this method and i'm getting lights. This will work for sure.

      In data declaration along with your alv display structure as a field named lights(any name).

      DATA : BEGIN OF wa_srr,

      vbeln LIKE vbak-vbeln, "Sales Order number

      posnr LIKE vbap-posnr, "Item nunmber

      matnr LIKE makt-matnr, "Material number Desc

      maktx LIKE makt-maktx, "Material Description

      gbstk LIKE vbuk-gbstk, "Completion status

      bukrs LIKE knb1-bukrs, "Company Code

      butxt LIKE t001-butxt, "Company Code description

      vkorg LIKE vbak-vkorg, "Sales organization

      vtext LIKE tvkot-vtext, "Sales Org description

      vtweg LIKE vbak-vtweg, "Distribution Channel

      dtext LIKE tvtwt-vtext, "Dist Channel description

      spart LIKE vbak-spart, "Division

      dvtxt LIKE tspat-vtext, "Division Description

      kunnr LIKE vbak-kunnr, "Customer Number

      name1 LIKE kna1-name1, "Customer Name

      land1 LIKE kna1-land1, "Country

      regio LIKE kna1-regio, "State

      ort01 LIKE kna1-ort01, "City

      erdat LIKE vbak-erdat, "Creation Date

      vdatu LIKE vbak-vdatu, "Due date

      kwmeng LIKE vbap-kwmeng, "Material Quantity

      netpr LIKE vbap-netpr, "unit net price

      netwr LIKE vbap-netwr, "Price

      wavwr LIKE vbap-wavwr, "Cost price

      bzirk LIKE vbkd-bzirk, "Sales District

      bztxt LIKE t171t-bztxt, "Sales District Discription

      lights, "Diplaying Status

      END OF wa_srr.

      While you are building the field cat do as follows

      FORM build_layout CHANGING l_wa_layout TYPE slis_layout_alv.

      l_wa_layout-zebra = cb_zebr. "Set alterante colored line

      l_wa_layout-colwidth_optimize = cb_colop. "Optimize column width

      l_wa_layout-no_vline = cb_novli. "No vertical line

      l_wa_layout-no_colhead = cb_nocol. "no column Header

      l_wa_layout-lights_fieldname = 'LIGHTS'. "Set light field

      (assigning the field u have added in ur structure here as light field in alv report)

      ENDFORM. " BUILD_LAYOUT

      Then as per the logic, u make green, yellow or red light

      Example,

      FORM build_light .

      LOOP AT it_srr INTO wa_srr. "for all entries in the table

      IF wa_srr-gbstk = 'C'. "If status is 'completed',

      wa_srr-lights = '3'. "Show green signal light

      ELSEIF wa_srr-gbstk = 'B'. "If status is 'Partial'

      wa_srr-lights = '2'. "Show yellow signal light

      ELSE. "If status is 'incomplete'

      wa_srr-lights = '1'. "Show red signal light

      ENDIF.

      MODIFY it_srr FROM wa_srr. "Update to table

      ENDLOOP.

      ENDFORM. " build_light

      after building ur layout, Pass it to ur alv function module like this.

      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

      EXPORTING

      i_callback_program = sy-repid

      i_callback_top_of_page = 'TOP_OF_PAGE'

      i_background_id = 'ALV_BACKGROUND'

      i_grid_title = text-011

      pass ur layout structure here********

      is_layout = wa_layout

      ****************************************

      it_fieldcat = it_fcat

      it_sort = it_sort

      i_save = v_save

      is_variant = wa_variant

      is_print = wa_print

      TABLES

      t_outtab = it_srr

      EXCEPTIONS

      program_error = 1

      OTHERS = 2.

      IF sy-subrc <> 0.

      MESSAGE i001. "List cannot be displayed

      ENDIF.

      wat all i did to add light is,

      1) adding an extra field in the main structure.

      2)create internal table with this structure as data table for alv report

      3) add 'field name' field in layout

      4) I have passed values(3, 2, 1) for green, yellow and red light resp, to the field(LIGHTS) in the internal table that is passed to alv function module.(Based on some condition)

      5) pass the layout structure layout to alv function module

      Thats it. If u do all this teps, u r done with it.

      Lemme know u solved it by giving points.

      with regards,

      praveen.

  • author's profile photo Former Member
    Former Member
    Posted on Aug 12, 2005 at 07:20 AM

    Hi,

    C_GREEN(4) TYPE C VALUE '@08@',

    C_RED(4) TYPE C VALUE '@0A@',

    C_YELLOW(4) TYPE C VALUE '@09@',

    write : c_green, c_red, c_yellow.

    Hope this will solve your problem

    Cheers,

    Sasi

    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.