ABAP Keyword Documentation → ABAP − Reference → SAP GUI User Dialogs → Classic Lists → Creating Lists → WRITE → WRITE - ext_format_options
Lists, Using Colors
This example demonstrates how colors can make lists easier to read.
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 += 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
. The key
fields from the table SPFLI are defined using COL_KEY
. At the event GET
sflight
, the list body has a different line background color
(COL_NORMAL
) than the background of the list
(COL_BACKGROUND
). In addition, flights where the number of bookings falls
below a certain minimum number, have a red background. The total number of bookings for each flight has a yellow background.
Note that after each event the system assumes the default setting
(COLOR OFF
, INTENSIFIED ON
). For this reason,
the row background of 'Total Bookings:' at the event GET LATE
becomes
COL_BACKGROUND again in the program above. INTENSIFIED
is set to OFF
here to preserve the same foreground color as for the other values displayed.