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

ALV ICON

how to display icons in ALV ?

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 Oct 17, 2006 at 11:25 AM

    Check this example,it may help u.

    REPORT z_example .

    TYPE-POOLS: slis,icon.

    DATA: x_fieldcat TYPE slis_fieldcat_alv,

    it_fieldcat TYPE slis_t_fieldcat_alv,

    l_layout TYPE slis_layout_alv.

    DATA: BEGIN OF itab OCCURS 0,

    vbeln LIKE vbak-vbeln,

    posnr LIKE vbap-posnr,

    icon(1),

    END OF itab.

    data:program type sy-repid.

    SELECT vbeln

    posnr

    FROM vbap

    UP TO 20 ROWS

    INTO TABLE itab.

    LOOP AT itab.

    IF sy-tabix = 1 OR sy-tabix = 2.

    itab-icon = '1'.

    ELSEIF sy-tabix = 10 OR sy-tabix = 20.

    itab-icon = '2'.

    ELSE.

    itab-icon = '3'.

    ENDIF.

    MODIFY itab INDEX sy-tabix.

    ENDLOOP.

    program = sy-repid.

    x_fieldcat-fieldname = 'VBELN'.

    x_fieldcat-seltext_l = 'VBELN'.

    x_fieldcat-hotspot = 'X'.

    x_fieldcat-tabname = 'ITAB'.

    x_fieldcat-col_pos = 1.

    APPEND x_fieldcat TO it_fieldcat.

    CLEAR x_fieldcat.

    x_fieldcat-fieldname = 'POSNR'.

    x_fieldcat-seltext_l = 'POSNR'.

    x_fieldcat-tabname = 'ITAB'.

    x_fieldcat-col_pos = 2.

    APPEND x_fieldcat TO it_fieldcat.

    CLEAR x_fieldcat.

    l_layout-lights_fieldname = 'ICON'.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    i_callback_program = program

    is_layout = l_layout

    it_fieldcat = it_fieldcat

    TABLES

    t_outtab = itab

    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.

    Regards

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 17, 2006 at 11:18 AM

    Hi

    You need to define the field as type iconname

    and pass the values to them

    e.g

    c_succ TYPE iconname VALUE '@01@',

    c_fail TYPE iconname VALUE '@02@',

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 17, 2006 at 11:22 AM

    Hi,

    Define A variable in the internal table and populate fieldcatalog for the same field with icon.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 17, 2006 at 11:23 AM

    Hi,

    first:

    INCLUDE <ICON>.

    create a filed in your internal table like this:

    KOSTX LIKE ICONS-L2,

    fill this field f. ex. like this:

    ITAB-KOSTX = ICON_LED_GREEN.

    modify the fieldcat like this.

    MOVE 'X' TO WA_FIELDCAT-ICON.

    Hope it helps.

    Regards, Dieter

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 17, 2006 at 11:24 AM

    http://www.sapfans.com/forums/viewtopic.php?t=79424

    http://www.sapfans.com/forums/viewtopic.php?t=24512

    I hope it helps...

    Best Regards,

    Vibha

    *Please mark all the helpful answers

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 17, 2006 at 04:10 PM

    HERE IS THE SAMPLE PROGRAM.JUST GO THROUGH THIS.

    &----


    *& Report ZALV5 *

    *& traffic lights *

    &----


    *& *

    *& *

    &----


    .

    REPORT ZALV5 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.

    • Listenuberschrift: 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.

    • Listenuberschrift: 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

    REGARDS,

    DEEPTHI REDDY

    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.