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

alvs

hi,

how to use traffic light symbol in alvs,if possible with sample code also...........

regards,

srinu.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 30, 2007 at 10:32 AM

    Hi Srinu,

    check this sample code,

    TYPE-POOLS : SLIS,

    ICON.

    TABLES : ZEMPLOYEEALV,ZEMPLOYEEALV2.

    DATA : BEGIN OF WA_EMP1,

    NAME TYPE ZEMPLOYEEALV-NAME,

    SALARY TYPE ZEMPLOYEEALV-SALARY,

    EXPERIENCE TYPE ZEMPLOYEEALV-EXPERIENCE,

    DESIGNATION TYPE ZEMPLOYEEALV-DESIGNATION,

    EXPAND,

    BOX,

    END OF WA_EMP1.

    DATA: BEGIN OF WA_EMP2,

    NAME TYPE ZEMPLOYEEALV2-NAME,

    CITY TYPE ZEMPLOYEEALV2-CITY,

    ADDRESS TYPE ZEMPLOYEEALV2-ADDRESS,

    INCENTIVE TYPE ZEMPLOYEEALV2-INCENTIVE,

    LIGHT,

    END OF WA_EMP2.

    DATA : IT_EMP1 LIKE TABLE OF WA_EMP1 WITH HEADER LINE, "Header Table

    IT_EMP2 LIKE TABLE OF WA_EMP2 WITH HEADER LINE, "Item Table

    IT_FCAT TYPE SLIS_T_FIELDCAT_ALV, "Fieldcat Table

    WA_FIELDCAT LIKE LINE OF IT_FCAT. "Fieldcat Workarea

    DATA IT_FCAT1 TYPE SLIS_T_FIELDCAT_ALV.

    DATA WA_LAYOUT TYPE SLIS_LAYOUT_ALV.

    DATA WA_KEYINFO TYPE SLIS_KEYINFO_ALV.

    DATA: IT_EVENTS TYPE SLIS_T_EVENT,

    WA_EVENTS LIKE LINE OF IT_EVENTS.

    DATA WA_REPID TYPE SY-REPID.

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

    WA_KEYINFO-HEADER01 = 'NAME'.

    WA_KEYINFO-ITEM01 = 'NAME'.

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

    PERFORM FILL_TABLES.

    PERFORM LAYOUT.

    PERFORM FIELDCAT.

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

    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    • EXPORTING

    • I_LIST_TYPE = 0

    IMPORTING

    ET_EVENTS = IT_EVENTS

    • EXCEPTIONS

    • LIST_TYPE_WRONG = 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.

    BREAK-POINT.

    READ TABLE IT_EVENTS INTO WA_EVENTS WITH KEY NAME = 'USER_COMMAND'.

    IF SY-SUBRC = 0.

    WA_EVENTS-FORM = 'FORM1'.

    MODIFY IT_EVENTS FROM WA_EVENTS INDEX SY-TABIX.

    ENDIF.

    CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    I_CALLBACK_PROGRAM = 'Z0255ALV_HIERARCHIALLIST'

    • I_CALLBACK_PF_STATUS_SET = ' '

    • I_CALLBACK_USER_COMMAND = ' '

    IS_LAYOUT = WA_LAYOUT

    IT_FIELDCAT = IT_FCAT

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    • IT_SORT =

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_SCREEN_START_COLUMN = 0

    • I_SCREEN_START_LINE = 0

    • I_SCREEN_END_COLUMN = 0

    • I_SCREEN_END_LINE = 0

    • I_DEFAULT = 'X'

    • I_SAVE = ' '

    • IS_VARIANT =

    IT_EVENTS = IT_EVENTS

    • IT_EVENT_EXIT =

    i_tabname_header = 'IT_EMP1'

    i_tabname_item = 'IT_EMP2'

    • I_STRUCTURE_NAME_HEADER =

    • I_STRUCTURE_NAME_ITEM =

    is_keyinfo = WA_KEYINFO

    • IS_PRINT =

    • IS_REPREP_ID =

    • I_BYPASSING_BUFFER =

    • I_BUFFER_ACTIVE =

    • IR_SALV_HIERSEQ_ADAPTER =

    • IT_EXCEPT_QINFO =

    • I_SUPPRESS_EMPTY_DATA = ABAP_FALSE

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER =

    • ES_EXIT_CAUSED_BY_USER =

    tables

    t_outtab_header = IT_EMP1

    t_outtab_item = IT_EMP2

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

    &----


    *& Form FILL_TABLES

    &----


    form FILL_TABLES .

    SELECT NAME

    SALARY

    EXPERIENCE

    DESIGNATION

    INTO TABLE IT_EMP1

    FROM ZEMPLOYEEALV

    UP TO 8 ROWS.

    SELECT NAME

    CITY

    ADDRESS

    INCENTIVE

    INTO TABLE IT_EMP2

    FROM ZEMPLOYEEALV2.

    • FOR ALL ENTRIES IN IT_EMP1 WHERE

    • NAME = IT_EMP1-NAME.

    LOOP AT IT_EMP2.

    IF IT_EMP2-INCENTIVE = 221.

    IT_EMP2-LIGHT = '2'.

    ELSEIF IT_EMP2-INCENTIVE = 255.

    IT_EMP2-LIGHT = '1'.

    ELSE.

    IT_EMP2-LIGHT = '3'.

    ENDIF.

    MODIFY IT_EMP2 INDEX SY-TABIX.

    ENDLOOP.

    LOOP AT IT_EMP1.

    IF IT_EMP1-SALARY = '100'.

    IT_EMP1-BOX = 'X'.

    ENDIF.

    MODIFY IT_EMP1 INDEX SY-TABIX.

    ENDLOOP.

    endform. " FILL_TABLES

    &----


    *& Form LAYOUT

    &----


    form LAYOUT .

    WA_LAYOUT-ZEBRA = 'X'.

    WA_LAYOUT-EXPAND_FIELDNAME = 'EXPAND'. "FOR EXPANDING

    WA_LAYOUT-EXPAND_ALL = 'X'.

    WA_LAYOUT-LIGHTS_FIELDNAME = 'LIGHT'. " FOR LIGHT

    WA_LAYOUT-LIGHTS_TABNAME = 'IT_EMP2'.

    WA_LAYOUT-BOX_FIELDNAME = 'BOX'. " FOR CHECKBOX

    WA_LAYOUT-BOX_TABNAME = 'IT_EMP1'.

    endform. " LAYOUT

    &----


    *& Form FIELDCAT

    &----


    form FIELDCAT .

    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

    EXPORTING

    I_PROGRAM_NAME = WA_REPID

    I_INTERNAL_TABNAME = 'IT_EMP1'

    I_STRUCTURE_NAME = 'ZEMPLOYEEALV'

    • I_CLIENT_NEVER_DISPLAY = 'X'

    • I_INCLNAME = WA_REPID

    • I_BYPASSING_BUFFER =

    • I_BUFFER_ACTIVE =

    CHANGING

    CT_FIELDCAT = IT_FCAT

    • EXCEPTIONS

    • INCONSISTENT_INTERFACE = 1

    • PROGRAM_ERROR = 2

    • OTHERS = 3

    .

    IF SY-SUBRC <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    DELETE IT_FCAT WHERE FIELDNAME <> 'NAME' AND

    FIELDNAME <> 'SALARY' AND

    FIELDNAME <> 'EXPERIENCE' AND

    FIELDNAME <> 'DESIGNATION'.

    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

    EXPORTING

    I_PROGRAM_NAME = WA_REPID

    I_INTERNAL_TABNAME = 'IT_EMP2'

    I_STRUCTURE_NAME = 'ZEMPLOYEEALV2'

    • I_CLIENT_NEVER_DISPLAY = 'X'

    • I_INCLNAME =

    • I_BYPASSING_BUFFER =

    • I_BUFFER_ACTIVE =

    CHANGING

    CT_FIELDCAT = IT_FCAT1

    • EXCEPTIONS

    • INCONSISTENT_INTERFACE = 1

    • PROGRAM_ERROR = 2

    • OTHERS = 3

    .

    IF SY-SUBRC <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    DELETE IT_FCAT1 WHERE FIELDNAME <> 'NAME' AND

    FIELDNAME <> 'CITY' AND

    FIELDNAME <> 'ADDRESS' AND

    FIELDNAME <> 'INCENTIVE'.

    APPEND LINES OF IT_FCAT1 TO IT_FCAT.

    " FIELDCAT

    ENDFORM.

    *

    FORM FORM1 USING UCOMM LIKE SY-UCOMM SEL_FIELD TYPE SLIS_SELFIELD.

    BREAK-POINT.

    WRITE: SEL_FIELD-FIELDNAME.

    WRITE: SEL_FIELD-VALUE.

    BREAK-POINT.

    *IF SEL_FIELD-FIELDNAME = 'NAME'.

    *SELECT * FROM ZEMPLO

    ENDFORM.

    Thanks,

    reward If Helpful.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 30, 2007 at 10:29 AM

    <b>Just check some checkboxes keep on doubleclicking.</b>

    REPORT YMS_CHECKBOXALV.

    TYPE-POOLS: slis.

    DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.

    DATA: s_fieldcatalog TYPE slis_fieldcat_alv.

    DATA: s_layout TYPE slis_layout_alv.

    DATA: BEGIN OF itab OCCURS 0,

    icon TYPE icon-id,

    vbeln TYPE vbeln,

    kunnr TYPE kunnr,

    erdat TYPE erdat,

    box TYPE c,

    END OF itab.

    DATA: v_repid TYPE syrepid.

    START-OF-SELECTION.

    • Get the data.

    SELECT vbeln kunnr erdat UP TO 100 ROWS

    FROM vbak

    INTO CORRESPONDING FIELDS OF TABLE itab.

    IF sy-subrc <> 0.

    MESSAGE s208(00) WITH 'No data found'.

    LEAVE LIST-PROCESSING.

    ENDIF.

    • Modify the record with red light.

    itab-icon = '@0A@'.

    MODIFY itab TRANSPORTING icon WHERE NOT vbeln IS initial.

    v_repid = sy-repid.

    • Get the field catalog.

    CLEAR: s_fieldcatalog.

    s_fieldcatalog-col_pos = '1'.

    s_fieldcatalog-fieldname = 'ICON'.

    s_fieldcatalog-tabname = 'ITAB'.

    s_fieldcatalog-seltext_l = 'Status'.

    s_fieldcatalog-icon = 'X'.

    APPEND s_fieldcatalog TO t_fieldcatalog.

    CLEAR: s_fieldcatalog.

    s_fieldcatalog-col_pos = '2'.

    s_fieldcatalog-fieldname = 'VBELN'.

    s_fieldcatalog-tabname = 'ITAB'.

    s_fieldcatalog-rollname = 'VBELN'.

    APPEND s_fieldcatalog TO t_fieldcatalog.

    CLEAR: s_fieldcatalog.

    s_fieldcatalog-col_pos = '3'.

    s_fieldcatalog-fieldname = 'KUNNR'.

    s_fieldcatalog-tabname = 'ITAB'.

    s_fieldcatalog-rollname = 'KUNNR'.

    APPEND s_fieldcatalog TO t_fieldcatalog.

    CLEAR: s_fieldcatalog.

    s_fieldcatalog-col_pos = '4'.

    s_fieldcatalog-fieldname = 'ERDAT'.

    s_fieldcatalog-tabname = 'ITAB'.

    s_fieldcatalog-rollname = 'ERDAT'.

    APPEND s_fieldcatalog TO t_fieldcatalog.

    • Set the layout.

    s_layout-box_fieldname = 'BOX'.

    S_LAYOUT-F2CODE = 'DISP'.

    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

    EXPORTING

    i_callback_program = v_repid

    is_layout = s_layout

    i_callback_pf_status_set = 'SET_PF_STATUS'

    i_callback_user_command = 'USER_COMMAND'

    it_fieldcat = t_fieldcatalog[]

    TABLES

    t_outtab = itab.

    FORM set_pf_status USING extab TYPE slis_t_extab.

    SET PF-STATUS 'TEST1'.

    ENDFORM.

    FORM user_command USING ucomm LIKE sy-ucomm

    selfield TYPE slis_selfield.

    • Check the ucomm.

    IF UCOMM = 'DISP'.

    LOOP AT itab WHERE box = 'X'.

    IF ITAB-ICON = '@0A@'.

    ITAB-ICON = '@08@'.

    ELSEIF ITAB-ICON = '@08@'.

    ITAB-ICON = '@09@'.

    ELSEIF ITAB-ICON = '@09@'.

    ITAB-ICON = '@0A@'.

    ENDIF.

    MODIFY itab TRANSPORTING icon.

    ENDLOOP.

    ENDIF.

    selfield-refresh = 'X'.

    ENDFORM.

    @0A@ - Red

    @09@ - Yellow

    @08@ - Green

    <b><u>Please dont forget to award points if needful</u></b>

    Sudheer

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 30, 2007 at 10:30 AM

    Hi Srinu

    This coding is only for Red light, Modify the code accordingly as per your requirement.

    REPORT YMS_CHECKBOXALV.

    TYPE-POOLS: slis.

    DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.

    DATA: s_fieldcatalog TYPE slis_fieldcat_alv.

    DATA: s_layout TYPE slis_layout_alv.

    DATA: BEGIN OF itab OCCURS 0,

    icon TYPE icon-id,

    vbeln TYPE vbeln,

    kunnr TYPE kunnr,

    erdat TYPE erdat,

    box TYPE c,

    END OF itab.

    DATA: v_repid TYPE syrepid.

    START-OF-SELECTION.

    • Get the data.

    SELECT vbeln kunnr erdat UP TO 100 ROWS

    FROM vbak

    INTO CORRESPONDING FIELDS OF TABLE itab.

    IF sy-subrc <> 0.

    MESSAGE s208(00) WITH 'No data found'.

    LEAVE LIST-PROCESSING.

    ENDIF.

    • Modify the record with red light.

    itab-icon = '@0A@'.

    MODIFY itab TRANSPORTING icon WHERE NOT vbeln IS initial.

    v_repid = sy-repid.

    • Get the field catalog.

    CLEAR: s_fieldcatalog.

    s_fieldcatalog-col_pos = '1'.

    s_fieldcatalog-fieldname = 'ICON'.

    s_fieldcatalog-tabname = 'ITAB'.

    s_fieldcatalog-seltext_l = 'Status'.

    s_fieldcatalog-icon = 'X'.

    APPEND s_fieldcatalog TO t_fieldcatalog.

    CLEAR: s_fieldcatalog.

    s_fieldcatalog-col_pos = '2'.

    s_fieldcatalog-fieldname = 'VBELN'.

    s_fieldcatalog-tabname = 'ITAB'.

    s_fieldcatalog-rollname = 'VBELN'.

    APPEND s_fieldcatalog TO t_fieldcatalog.

    CLEAR: s_fieldcatalog.

    s_fieldcatalog-col_pos = '3'.

    s_fieldcatalog-fieldname = 'KUNNR'.

    s_fieldcatalog-tabname = 'ITAB'.

    s_fieldcatalog-rollname = 'KUNNR'.

    APPEND s_fieldcatalog TO t_fieldcatalog.

    CLEAR: s_fieldcatalog.

    s_fieldcatalog-col_pos = '4'.

    s_fieldcatalog-fieldname = 'ERDAT'.

    s_fieldcatalog-tabname = 'ITAB'.

    s_fieldcatalog-rollname = 'ERDAT'.

    APPEND s_fieldcatalog TO t_fieldcatalog.

    • Set the layout.

    s_layout-box_fieldname = 'BOX'.

    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

    EXPORTING

    i_callback_program = v_repid

    is_layout = s_layout

    i_callback_pf_status_set = 'SET_PF_STATUS'

    i_callback_user_command = 'USER_COMMAND'

    it_fieldcat = t_fieldcatalog[]

    TABLES

    t_outtab = itab.

    ----


    • FORM SET_PF_STATUS *

    ----


    • ........ *

    ----


    • --> EXTAB *

    ----


    FORM set_pf_status USING extab TYPE slis_t_extab.

    SET PF-STATUS 'TEST2'.

    ENDFORM.

    ----


    • FORM user_command *

    ----


    • ........ *

    ----


    • --> UCOMM *

    • --> SELFIELD *

    ----


    FORM user_command USING ucomm LIKE sy-ucomm

    selfield TYPE slis_selfield.

    • Check the ucomm.

    IF ucomm = 'DETAIL'.

    LOOP AT itab WHERE box = 'X'.

    itab-icon = '@08@'.

    MODIFY itab TRANSPORTING icon.

    ENDLOOP.

    ENDIF.

    selfield-refresh = 'X'.

    ENDFORM.

    Hope this resolves your query.

    Reward all the helpful answers.

    Regards,

    Sree

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 30, 2007 at 10:47 AM

    Hi,

    To use traffic light symbols you have to build a LAYOUT within which one field should be used for Lights and then pass this layout in Function Module parameter named layout.

    You can get all idea of how to do it using program: BALVSD01 which can be seen in SE80 : enter Package name: SLIS

    Reward if useful.

    Regards,

    Harsha

    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.