Tuesday, December 21, 2010
When you use ALV list display, use TOP_OF_PAGE event to display traffic lights.

REPORT ztest_alv_traffic_lights .
DATA:
      BEGIN OF it_data OCCURS 0,
        matnr  TYPE mard-matnr,
        werks  TYPE mard-werks,
        lgort  TYPE mard-lgort,
      END OF it_data.
TYPE-POOLS:
    slis.
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.
  SELECT matnr werks  lgort
    FROM mard
    INTO CORRESPONDING FIELDS OF TABLE it_data
    UP TO 10 ROWS.
  w_events-name = 'TOP_OF_PAGE'.
  w_events-form = 'TOP_OF_PAGE'.
  APPEND w_events TO i_events.

  CLEAR:w_fieldcat,i_fieldcat[].
  w_fieldcat-fieldname     = 'MATNR'.
  w_fieldcat-tabname       = 'IT_DATA'.
  w_fieldcat-seltext_m     = 'MATNR'.
  APPEND w_fieldcat TO i_fieldcat.
  CLEAR w_fieldcat.

  w_fieldcat-fieldname     = 'WERKS'.
  w_fieldcat-tabname       = 'IT_DATA'.
  w_fieldcat-seltext_m     = 'WERKS'.
  APPEND w_fieldcat TO i_fieldcat.
  CLEAR w_fieldcat.

  w_fieldcat-fieldname     = 'LGORT'.
  w_fieldcat-tabname       = 'IT_DATA'.
  w_fieldcat-seltext_m     = 'LGORT'.
  APPEND w_fieldcat TO i_fieldcat.
  CLEAR w_fieldcat.

  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
      i_callback_program = sy-repid
      is_layout          = w_layout
      it_fieldcat        = i_fieldcat
      it_events          = i_events
    TABLES
      t_outtab           = it_data.
*&---------------------------------------------------------------------*
*&      Form  top_of_page
*&---------------------------------------------------------------------*
FORM top_of_page.
  WRITE:/ 'top_of_page start'.
  WRITE:/ '@08@',"  Green light; positive
  '@09@',"  Yellow light; neutral
  '@0A@'."  Red light; negative
  WRITE:/ 'top_of_page end'.
ENDFORM.                    "top_of_page

0 comments:

Post a Comment

Your useful comments, suggestions are appreciated.Your comments are moderated.

Followers

Contact Form

Name

Email *

Message *

Web Dynpro ABAP Book

An SAP Consultant

Follow US


Want to Contribute ?

If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

Click on Contribution for more details.