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

led light in alv grid

Hi Everyone,

This is the sample code where in i display the alv grid in this the green led light is not coming up.

In perfrom get table i have hardcoded, the values for icon name as led green . but in the alv it displays the values @5d,

what could be the problem do i have to change here in the alv display something or what else could be done to get the led in the grid.

MODULE status_0130 OUTPUT.

  • * Create objects

IF go_custom_container IS INITIAL.

CREATE OBJECT go_custom_container

EXPORTING container_name = 'TABLE'.

CREATE OBJECT go_grid

EXPORTING

i_parent = go_custom_container.

PERFORM data

ENDIF.

ENDMODULE.

FORM data

DATA: gs_layout TYPE lvc_s_layo.

PERFORM get table

USING

table_info

CHANGING

itab.

  • Set grid title

gs_layout-grid_title = 'Table Data.

gs_layout-smalltitle = 'X'.

gs_layout-cwidth_opt = 'X'.

CALL METHOD go_grid->set_table_for_first_display

EXPORTING

i_structure_name = 'struct_table'

is_layout = gs_layout

CHANGING

it_outtab = itab.

ENDFORM.

Thanks in advance,

Any help will be of great use to me.

Prabs.

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 Aug 08, 2005 at 08:02 AM

    Hi,

    Check this demo program BALVSD01

    Regards,

    Vijay

    Add a comment
    10|10000 characters needed characters exceeded

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

    Hi prabakar,

    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

    Lemme know whther this solved ur problem by rewardin the points.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      Just do as Praveen and do the following modifications.

      Declare a field light along with the fields of the output.

      eg: begin of it_outtab occurs 0,

      ebeln...

      ebelp...

      .

      .

      <b>light type c</b>,

      end of it_outtab.

      just before using method set_table_for_first_display declare the layout it_layout:

      it_layout-grid_title = 'Output'.

      <b>it_layout-excp_fname = w_light</b>.

      declare the field w_light:

      data : w_light type lvc_cifnm value 'LIGHT'.

      And based on your condition pass '1' or '2' or '3' to it_outtab-light while filling data into table it_outtab.

      just by doing this, the traffic lights will appear along with the records in the output

  • Posted on Aug 05, 2005 at 06:37 PM

    The field needs to be at least 4 characters big. ALso, please make sure that when filling field catalog, to set the ICON field to "X".

    fieldcat-ICON = 'X'.

    Regards,

    Rich Heilman

    Add a comment
    10|10000 characters needed characters exceeded

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

    Hi, try the action like following.

    INCLUDE <ICON>.

    add this into your application.

    define a field in the internal table you need to shown in ALV, like this:

    STATUSICON(5) TYPE C,

    • STATUSICON is just a random name

    don't forget the associated addition on the fieldcategory table setting

    fill the field STATUSICON as following:

    MOVE ICON_RED_LIGHT TO XXXX-STATUSICON.

    you can choose some other icons, like

    ICON_RED_LIGHT

    ICON_GREEN_LIGHT

    ICON_YELLOW_LIGHT

    Hope it will be helpful

    Message was edited by: zhenglin gu

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 08, 2005 at 08:55 AM

    Hi,

    To have an idea about the value of icons,check this.

    http://www.sapdevelopment.co.uk/tips/tips_icons.htm

    ICON_2 ICON_LED_YELLOW '@5D@'." Stop

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 09, 2005 at 03:53 AM

    Hi,

    Try this sample code:

    Take care to use ur strcuture name and the fields accordingly.

    Program Name: zzz_light_alv
    REPORT zzz_light_alv NO STANDARD PAGE HEADING.
    
    * The Data Declarations
    INCLUDE zzz_light_alv_data.
    
    PARAMETERS p_layout LIKE disvariant-variant.
    
    START-OF-SELECTION.
    *Fetching data for the report
      PERFORM f1003_display_data.
    END-OF-SELECTION.
    
      CALL SCREEN 9001.
    TOP-OF-PAGE.
    
    *Data Selection
      INCLUDE zzz_light_alv_forms.
    *PBO & PAI Modules
      INCLUDE zzz_light_alv_screen.
    
    * Create an include : zzz_light_alv_data
    
    TABLES:    mara.                          " General Material Data.
    
    TYPES : BEGIN OF ty_data,
             light TYPE ZLIGHT_STRUC-light,      " Light
             matnr TYPE mara-matnr ,             " Material number
             msgty TYPE ZLIGHT_STRUC-msgty,      " Message type
            END OF ty_data.
    
    DATA: i_exclude TYPE ui_functions,   " Function button table definitions
          i_fieldcat TYPE lvc_t_fcat,    " Field catalogue
          i_output TYPE STANDARD TABLE OF ZLIGHT_STRUC,
          i_groups  TYPE lvc_t_sgrp,
    
    
           w_variant TYPE disvariant,          " Enable variant saving
           <b>w_layout  TYPE lvc_s_layo,          " Define the layout structure</b>
           w_output TYPE <b>ZLIGHT_STRUC</b>.
    
    
    CONSTANTS:  c_a       TYPE c VALUE 'A'.          "All Layouts
    
    DATA : o_alvgrid          TYPE REF TO cl_gui_alv_grid,
           o_dockingcontainer TYPE REF TO cl_gui_docking_container.
    
    
    *Create an include: ZZZ_LIGHT_ALV_FORMS
    
    
    *&---------------------------------------------------------------------*
    *&      Form  f1002_value_request
    *&---------------------------------------------------------------------*
    *       Get the values for the layout.
    *----------------------------------------------------------------------*
    FORM f1002_value_request.
    
      DATA:    lv_exit        TYPE c,
               lw_variant     LIKE w_variant.
    
      w_variant-report   = sy-repid.
    
    * Invoke function to provide drop down entries
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
           EXPORTING
                is_variant    = w_variant
                i_save        = c_a
           IMPORTING
                e_exit        = lv_exit
                es_variant    = lw_variant
           EXCEPTIONS
                not_found     = 1
                program_error = 2
                OTHERS        = 3.
      IF sy-subrc IS INITIAL.
        IF lv_exit IS INITIAL.
          p_layout = lw_variant-variant.
        ENDIF.
      ELSE.
    *    MESSAGE i037.                                    "No layouts found
      ENDIF.
    
    ENDFORM.                    " f1002_value_request
    
    *&---------------------------------------------------------------------*
    *&      Form  f1003_display_data
    *&---------------------------------------------------------------------*
    *       Display Data
    *----------------------------------------------------------------------*
    FORM f1003_display_data.
    
    * You can put your conditions here. Based upon the conditions you can 
    * display the lights as Red, Yellow or Green
    
      w_output-light = '1'.                     “ Red
      w_output-matnr = '000123456'.
      w_output-msgty = '1'.
      APPEND w_output TO i_output.
    
      w_output-light = '2'.                     “ Yellow
      w_output-matnr = '000123457'.
      w_output-msgty = '1'.
      APPEND w_output TO i_output.
    
      w_output-light = '3'.                     “ Green
      w_output-matnr = '000123458'.
      w_output-msgty = '1'.
      APPEND w_output TO i_output.
    
    ENDFORM.                    " f1003_display_data
    
    *&---------------------------------------------------------------------*
    *&      Form  f9000_objects_create
    *&---------------------------------------------------------------------*
    * This form creates the objects that we later reference.
    *----------------------------------------------------------------------*
    FORM f9000_objects_create.
    
    * Check to see if we are runnng on online
      IF cl_gui_alv_grid=>offline( ) IS INITIAL.
    
        CREATE OBJECT o_dockingcontainer
          EXPORTING
            ratio                       = '95'
         EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          create_error                = 3
          lifetime_error              = 4
          lifetime_dynpro_dynpro_link = 5
          others                      = 6.
    
        IF sy-subrc NE 0.
    *      MESSAGE i001 WITH text-e01.
          LEAVE LIST-PROCESSING.
        ENDIF.
    
      ENDIF.
    
      CREATE OBJECT o_alvgrid
        EXPORTING
          i_parent = o_dockingcontainer.
    
    ENDFORM.                    " f9000_objects_create
    
    *&---------------------------------------------------------------------*
    *&      Form  f9100_exclude_functions
    *&---------------------------------------------------------------------*
    * This form exclude buttons  from the toolbar.
    *----------------------------------------------------------------------*
    *      -->P_IEXCLUDE  text
    *      -->P_1150   text
    *----------------------------------------------------------------------*
    FORM f9100_exclude_functions USING   pexclude LIKE i_exclude
                                   value(pfunction).
    
      DATA: l_exclude TYPE ui_func.
    
      l_exclude = pfunction.
      APPEND l_exclude TO pexclude.
    
    ENDFORM.                    " f9100_exclude_functions
    
    *&---------------------------------------------------------------------*
    *&      Form  f9200_build_field_cat
    *&---------------------------------------------------------------------*
    *       Building the field catalogue
    *----------------------------------------------------------------------*
    *      -->P_I_FIELDCAT[] - Internal table having the fields of the ALV
    *                          structure
    *      -->P_structure    - ALV structure to be displayed in the output
    *----------------------------------------------------------------------*
    FORM f9200_build_field_cat TABLES p_fieldcat STRUCTURE lvc_s_fcat
                          USING value(p_structure).
    
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
           EXPORTING
                i_structure_name       = p_structure
           CHANGING
                ct_fieldcat            = p_fieldcat[]
           EXCEPTIONS
                inconsistent_interface = 1
                program_error          = 2
                OTHERS                 = 3.
      IF sy-subrc <> 0.
    *    MESSAGE i277.
        LEAVE LIST-PROCESSING.
      ENDIF.
    
    ENDFORM.                    " f9200_build_field_cat
    
    *&---------------------------------------------------------------------*
    *&      Form  f9400_layout
    *&---------------------------------------------------------------------*
    * This form sets how the grid will look.
    * The title, alternate colouring on lines, if the column widths are
    * optimised for the data contents and the display variant if_used.
    *----------------------------------------------------------------------*
    *      -->P_SY_TITLE - Title bar text
    *      -->P_0015     - Alternating line color (striped)
    *      -->P_0016     - Selection mode
    *      -->P_0017     - Optimize column width
    *      -->P_P_DISVAR - Report name
    *----------------------------------------------------------------------*
    FORM f9400_layout USING    value(ptitle)
                         value(pzebra)
                         value(pmode)
                         value(pwidth)
                         value(pvariant).
    
      w_layout-grid_title = ptitle.
      w_layout-zebra      = pzebra.
      w_layout-sel_mode   = pmode.
      w_layout-cwidth_opt = pwidth.
      w_variant-handle    = pvariant.
      w_variant-report    = sy-repid.
    <b>  w_layout-excp_fname = 'LIGHT'. </b>                     " To display Light
    
    ENDFORM.                    " f9400_layout
    
    *&---------------------------------------------------------------------*
    *&      Form  f9500_display_data
    *&---------------------------------------------------------------------*
    *       Display the output data
    *----------------------------------------------------------------------*
    *      -->P_IOUTPUT  - Output table to be displayed in the ALV
    *      -->P_groups   - Field groups
    *      -->P_exclude  - Excluded toolbar standard functions
    *      -->P_fieldcat - Field catalog
    *      -->P_layout   - Layout
    *----------------------------------------------------------------------*
    FORM f9500_display_data TABLES p_output
                             p_groups
                             p_exclude
                             p_fieldcat
                      USING value(p_layout).
    
      CALL METHOD o_alvgrid->set_table_for_first_display
         EXPORTING
           is_variant                    = w_variant
           i_save                        = c_a
           is_layout                     = p_layout
           it_special_groups             = p_groups[]
           it_toolbar_excluding          = p_exclude[]
        CHANGING
           it_outtab                     = p_output[]
           it_fieldcatalog               = p_fieldcat[]
        EXCEPTIONS
           invalid_parameter_combination = 1
           program_error                 = 2
           too_many_lines                = 3
           OTHERS                        = 4.
    
      IF sy-subrc <> 0.
    *    MESSAGE i278.
        LEAVE LIST-PROCESSING.
      ENDIF.
    
    ENDFORM.                    " f9500_display_data
    
    *&---------------------------------------------------------------------*
    *&      Form  f9600_free_objects
    *&---------------------------------------------------------------------*
    *  This form handles the freeing of the following objects
    *  ALV Docking Container
    *----------------------------------------------------------------------*
    *      -->P_O_ALVGRID - Object to be freed
    *      -->P_0020      - Type of the object
    *      -->P_0021      - Object text
    *----------------------------------------------------------------------*
    FORM f9600_free_objects USING pobject
                        value(ptype)
                        value(ptext).
    
      DATA: l_objectalv TYPE REF TO cl_gui_alv_grid.
    * Need to type the field symbol or it does not work
    
      CASE ptype.
        WHEN 'ALV'.
    
          l_objectalv = pobject.
    
          IF NOT ( l_objectalv IS INITIAL ).
            CALL METHOD l_objectalv->free
              EXCEPTIONS
                cntl_error        = 1
               cntl_system_error = 2
                OTHERS            = 3.
            CLEAR: pobject, l_objectalv.
            PERFORM f9700_error_handle USING ptext.
    
          ENDIF.
        WHEN 'DOCKING'.
          DATA: lobjectdock TYPE REF TO cl_gui_docking_container.
          lobjectdock = pobject.
    
          IF NOT ( lobjectdock IS INITIAL ).
            CALL METHOD lobjectdock->free
              EXCEPTIONS
                cntl_error        = 1
               cntl_system_error = 2
                OTHERS            = 3.
            CLEAR: pobject, lobjectdock.
            PERFORM f9700_error_handle USING ptext.
    
          ENDIF.
        WHEN 'CONTAINER'.
          DATA: lobjectcontainer TYPE REF TO cl_gui_container.
          lobjectcontainer = pobject.
    
          IF NOT ( lobjectcontainer IS INITIAL ).
            CALL METHOD lobjectcontainer->free
              EXCEPTIONS
                cntl_error        = 1
               cntl_system_error = 2
                OTHERS            = 3.
            CLEAR: pobject, lobjectcontainer.
            PERFORM f9700_error_handle USING ptext.
    
          ENDIF.
        WHEN OTHERS.
          sy-subrc = 1.
          PERFORM f9700_error_handle USING
                                    text-e04.
      ENDCASE.
    
    ENDFORM.                    " f9600_free_objects
    
    *&---------------------------------------------------------------------*
    *&      Form  f9700_error_handle
    *&---------------------------------------------------------------------*
    *       This form is used to handle errors
    *----------------------------------------------------------------------*
    *      -->P_PTEXT - Text holding the messsage to be displayed as
    *                   information
    *----------------------------------------------------------------------*
    FORM f9700_error_handle USING    value(ptext).
    
      IF sy-subrc NE 0.
    * Add your handling, for example
        CALL FUNCTION 'POPUP_TO_INFORM'
             EXPORTING
                  titel = text-e03
                  txt2  = sy-subrc
                  txt1  = ptext.
      ENDIF.
    
    ENDFORM.                    " f9700_error_handle
    
    
    * Create a screen: 9001.
    
    * Create an include: ZZZ_LIGHT_ALV_SCREEN
    
    MODULE status_9001 OUTPUT.
    
      IF o_dockingcontainer IS INITIAL.
    
        SET PF-STATUS 'ZSTATUS'.
        SET TITLEBAR 'ZTITLE'.
    
    *Create Objects
        PERFORM f9000_objects_create.
    
    *Build field catalog
        PERFORM f9200_build_field_cat TABLES i_fieldcat
                                 USING 'ZLIGHT_STRUC'.
    
    *Layout
        PERFORM f9400_layout USING sy-title 'X' 'X' 'X' p_layout.
    
    *Display data
        PERFORM f9500_display_data TABLES i_output
                                    i_groups
                                    i_exclude
                                    i_fieldcat
                              USING w_layout.
    
      ENDIF.
    
    ENDMODULE.                 " STATUS_9001  OUTPUT
    *&---------------------------------------------------------------------
    *&      Module  USER_COMMAND_9001  INPUT
    *&---------------------------------------------------------------------
    * This is used for PAI details
    *----------------------------------------------------------------------
    MODULE user_command_9001 INPUT.
    
      CASE sy-ucomm.
    
        WHEN 'EXIT' OR  'CANC'.
          PERFORM f9600_free_objects:
                   USING o_alvgrid 'ALV' text-e02,
                   USING o_dockingcontainer 'DOCKING'
                           text-e01.
          LEAVE PROGRAM.
    
        WHEN 'BACK'.
          PERFORM f9600_free_objects:
                   USING o_alvgrid 'ALV' text-e02,
                   USING o_dockingcontainer 'DOCKING'
                           text-e01.
          SET SCREEN '0'.
          LEAVE SCREEN.
    
        WHEN OTHERS.
    
      ENDCASE.
    
    ENDMODULE.                 " USER_COMMAND_9001  INPUT
    
    
    Create a structure: <b>ZLIGHT_STRUC</b>
    
    Components:
               LIGHT
               MATNR
               MSGTY
    
    

    Regards,

    Anjali

    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.