Start of Content Area

Colors in Lists  Locate the document in its SAP Library structure

The options COLOR, INTENSIFIED, and INVERSE of the FORMATstatement influence the colors of the output list.

To set colors in the program, use:

Syntax

FORMAT COLOR n [ON] INTENSIFIED [ON|OFF] INVERSE [ON|OFF].

 

To set colors at runtime, use:

Syntax

FORMAT COLOR = c INTENSIFIED = int INVERSE = inv.

 

These formatting options do not apply to horizontal lines created by ULINE. They have the following functions:

·        COLOR sets the color of the line background. For n  you can set either a color number or a color specification. Instead of color number 0, however, you must use OFF. If you set the color numbers at runtime, all values of c that are less than zero or greater than seven, lead to undefined results. The default setting is COLOR OFF.

·        INTENSIFIED  determines the intensity of the background color.

The default setting is INTENSIFIED ON. For COLOR OFF, the system changes the foreground color instead of the background color.

·        INVERSEdetermines whether the background color or the foreground color is set with the COLORaddition.

Note

The following statements have the same effect:

FORMAT INTENSIFIED ON.   and  SUMMARY.

FORMAT INTENSIFIED OFF. and  DETAIL.

SAP recommends always using the FORMAT statement to improve legibility (the statements SUMMARY and DETAIL are thus obsolete).

 

The following examples show the colors possible in lists and how to use them.

For another demonstration of colors in lists, call the executable program SHOWCOLO in any system.

Demonstrating the Colors Available in Lists

The following example shows the different combinations of the color formatting options:

Example

REPORT demo_list_format_color_1.

DATA i TYPE i VALUE 0.
DATA col(15) TYPE c.

WHILE i < 8.

  CASE i.
    WHEN 0. col = 'COL_BACKGROUND '.

    WHEN 1. col = 'COL_HEADING    '.
    WHEN 2. col = 'COL_NORMAL     '.
    WHEN 3. col = 'COL_TOTAL      '.
    WHEN 4. col = 'COL_KEY        '.
    WHEN 5. col = 'COL_POSITIVE   '.
    WHEN 6. col = 'COL_NEGATIVE   '.
    WHEN 7. col = 'COL_GROUP      '.
  ENDCASE.

  FORMAT INTENSIFIED COLOR = i.
  WRITE: /(4) i, AT 7            sy-vline,
            col,                 sy-vline,
            col INTENSIFIED OFF, sy-vline,
            col INVERSE.

  i = i + 1.

ENDWHILE.

In the FORMAT statement, the COLOR option for the subsequent WRITE statements is set at runtime. The other options are set individually for each WRITE statement in the program.

The output appears as shown in the following table:

This graphic is explained in the accompanying text

The standard page header was created as a text element. In the online help, the colors of this list differ slightly from the colors of the SAP system (for technical reasons).

Example of Using Colors in Lists

This example shows how to use colors in lists to highlight output.

Example

The program below is connected to the logical database F1S.

REPORT demo_list_format_color_2 NO STANDARD PAGE HEADING LINE-SIZE 70.

TABLES: 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.

The report creates the following output list:

This graphic is explained in the accompanying text

All headers appear using the background color COL_HEADING. The key fields from table SPFLI use COL_KEY as background color. The list body at the event GET sflight has a different line background color (COL_NORMAL) than the list background (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 the system resets the formatting options for each new event to the default settings (COLOR OFF, INTENSIFIED ON). For this reason, in the above program the line background of the output 'Total Bookings:' is COL_BACKGROUND again in the GET LATE event. INTENSIFIED is set to OFF to get the same foreground color as for the other output.

In the online help, the colors of this list differ slightly from the colors of the SAP system (for technical reasons).

 

 

 

 

End of Content Area