Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  User Dialogs →  Classic Lists →  Creating Lists →  WRITE →  WRITE - ext_format_options 

Lists, Using Colors

The example shows how colors can make lists better readable.

Other versions: 7.31 | 7.40 | 7.54

Source Code

REPORT demo_list_format_color_2 NO STANDARD PAGE HEADING LINE-SIZE 70.

NODES: spfli, sflight.
DATA sum TYPE i.

TOP-OF-PAGE.

  WRITE 'List of Flights' COLOR COL_HEADING.
  ULINE.

GET spfli.

  FORMAT COLOR COL_HEADING.
  WRITE: 'CARRID', 10 'CONNID', 20 'FROM', 40 'TO'.

  FORMAT COLOR COL_KEY.
  WRITE: / spfli-carrid   UNDER 'CARRID',
           spfli-connid   UNDER 'CONNID',
           spfli-cityfrom UNDER 'FROM',
           spfli-cityto   UNDER 'TO'.
  ULINE.

  FORMAT COLOR COL_HEADING.
  WRITE: 'Date', 20 'Seats Occupied', 50 'Seats Available'.
  ULINE.

  sum = 0.

GET sflight.

  IF sflight-seatsocc LE 10.
    FORMAT COLOR COL_NEGATIVE.
  ELSE.
    FORMAT COLOR COL_NORMAL.
  ENDIF.

  WRITE: sflight-fldate   UNDER 'Date',
         sflight-seatsocc UNDER 'Seats Occupied',
         sflight-seatsmax UNDER 'Seats Available'.

  sum = sum + sflight-seatsocc.

GET spfli LATE.

  ULINE.
  WRITE: 'Total Bookings:  ' INTENSIFIED OFF,
         sum COLOR COL_TOTAL.
  ULINE.
  SKIP.

Description

All headings are displayed with the background color COL_HEADING. Key fields from table SPFLI are defined with COL_KEY. At the event GETsflight, the list body has a different line background color (COL_NORMAL) than the background of the list (COL_BACKGROUND). What is more, flights with an occupancy below the minimum number of bookings are displayed in red. The total bookings for each connection is displayed in yellow.

Note that after each event the system assumes the default setting (COLOR OFF, INTENSIFIED ON). This is the reason why in the above program the line background of 'Total Bookings:' reverts to COL_BACKGROUND at the COL_BACKGROUND event. INTENSIFIED is set to OFF to get the same foreground color as for the other values displayed.

For technical reasons, the colors of this list do not completley match the colors of the SAP system in the online help.