Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  User Dialogs →  Classic Lists →  Create lists 

FORMAT

Short Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


FORMAT [COLOR       {{{color [ON]}|OFF}|{= col}}] 
       [INTENSIFIED [{ON|OFF}|{= flag}]]
      [INVERSE     [ {ON|OFF} | {= flag} ]]
      [HOTSPOT     [ {ON|OFF} | {= flag} ]]
      [INPUT       [{ON|OFF}|{= flag}]]
       [FRAMES      [{ON|OFF}|{= flag}]]
       [RESET].

Extras

1. ... COLOR {{{color [ON]}|OFF}|{= col}}

2. ... INTENSIFIED [{ON|OFF}|{= flag}]

3. ... INVERSE [{ON|OFF}|{= flag}]

4. ... HOTSPOT [{ON|OFF}|{= flag}]

5. ... INPUT [{ON|OFF}|{= flag}]

6. ... FRAMES [{ON|OFF}|{= flag}]

7. ... RESET

Effect

The settings defined using FORMAT apply from the current position of the list cursor for all of the following output statements (WRITE and, with restrictions, ULINE) until they are redefined by a new FORMAT statement. Within a line, the areas between the individual outputs and between the start of the line and the first output are formatted. Blank lines created using SKIP are not formatted, however.

The individual additions change the associated setting only and leave the others unchanged, with the exception of the RESET addition, which can change all settings.

At the start of the program, standard settings are defined for the settings that can be defined using FORMAT. These are set automatically for each reporting event and list event (with the exception of the attribute set by FRAMES). A table of the standard settings is in the description of the RESET addition.

For each individual WRITE output, the settings can be overridden by using the same additions in the WRITE additions. The settings that are defined using FORMAT or the standard settings then apply again.


Note

Alongside FORMAT, obsolete formats also exist that are replaced by FORMAT.

Addition 1

... COLOR {{{color [ON]}|OFF}|{= col}}

Effect

This addition sets the color of the output. If the attribute INVERSE is set to OFF (default setting), this sets the background color of the output. If the attribute INVERSE is set to ON, this sets the foreground color of the output.

You can specify the color either statically using color, or dynamically using col. For color, use the syntax directly from the following table. You do not need to specify ON. col expects a data object of type i, containing one of the values from the following table. If col contains a different value, this is handled like the value 0.

|Syntax of color|Value in col|Color| |----|----|----| |{ COL_BACKGROUND }|0|GUI-dependent| |{ 1 | COL_HEADING }|1|Gray-blue| |{ 2 | COL_NORMAL }|2|Light gray| |{ 3 | COL_TOTAL }|3|Yellow| |{ 4 | COL_KEY }|4|Blue-green| |{ 5 | COL_POSITIVE }|5|Green| |{ 6 | COL_NEGATIVE }|6|Red| |{ 7 | COL_GROUP }|7|Purple|

The addition OFF has the same effect as COL_BACKGROUND or the value 0 in col and is the default setting. In this setting, the color of the background corresponds to a list line of the background color of the GUI window.

The COLOR addition does not affect lines that are made of line elements, or on windows that are ready for input. The latter can be overridden by the other additions.

Addition 2

... INTENSIFIED [{ON|OFF}|{= flag}]

Effect

This addition defines the intensity of the background color. flag expects a data object of type i. If ON is specified or if the content of flag is not equal to 0, an intensive background color is used (default setting). If OFF is specified or if the content of flag is equal to 0, a weak background color is used. An exception to this is the COL_BACKGROUND background color, used by INTENSIFIED OFF to control the foreground color. If neither ON, OFF, nor flag are specified after INTENSIFIED, then the ON addition takes effect.

At the same time, if the INPUT ON attribute is set, the INTENSIFIED OFF addition changes the foreground color of fields that are ready for input. If the INVERSE ON setting is made at the same time, the INTENSIFIED OFF setting has no effect (with the exception of COL_BACKGROUND).

Addition 3

... INVERSE [{ON|OFF}|{= flag}]

Effect

This addition defines whether the COLOR addition sets the background color or the foreground color. flag expects a data object of type i. If ON is specified or the content of flag is not equal to 0, then the foreground (the output) is displayed in the selected color. An exception to this is the COL_BACKGROUND color, used to display the foreground in white. If OFF is specified or if the content of flag is equal to 0, the background is displayed in the selected color (default setting). If ON, OFF nor flag are specified after INVERSE then the ON addition takes effect.

At the same time, if the attribute INPUT ON is set, the addition INVERSE ON changes the background and foreground color of fields that are ready for input.


Example

Demonstration of different combinations of additions COLOR, INTENSIFIED, and INVERSE. The program SHOWCOLO produces a similar result.

DATA col TYPE i VALUE 0. 

DO 8 TIMES. 
  col = sy-index - 1. 
  FORMAT COLOR = col. 
  WRITE: /  col              COLOR OFF, 
           'INTENSIFIED ON'  INTENSIFIED ON, 
           'INTENSIFIED OFF' INTENSIFIED OFF, 
           'INVERSE ON'      INVERSE ON. 
ENDDO. 

Addition 4

... HOTSPOT [{ON|OFF}|{= flag}]

Effect

This addition influences the display of the mouse pointer and the function of the mouse in the list displayed on the screen. flag expects a data object of type i. If ON is specified or if the content of flag is not equal to 0, then, when the mouse pointer is positioned on a list area that is formatted accordingly, it changes its appearance to a hand, and a single click has the same effect as a double-click (that is, selecting the function key F2). If OFF is specified or if the content of flag is equal to 0, the function of the mouse does not change (default setting). If neither ON, OFF, nor flag is specified after HOTSPOT, then the ON addition takes effect.

If the attribute INPUT ON is set, the HOTSPOT ON addition has no effect on line elements.


Example

Demonstration of a Hotspot Clicking once on the output creates a details list.

START-OF-SELECTION. 
  FORMAT HOTSPOT. 
  WRITE 'Click me!' COLOR 5. 
  FORMAT HOTSPOT OFF. 

AT LINE-SELECTION. 
  WRITE 'Yeah!' COLOR 3. 

Addition 5

... INPUT [{ON|OFF}|{= flag}]

Effect

This addition makes list areas ready for input. flag expects a data object of type i. If ON is specified or the content of flag is not equal to 0, the relevant list area is displayed with a different foreground and background color than the rest of the list, and the user can overwrite the output. The screen cursor is positioned in the first field that is ready for input. If OFFis specified or the content of flag is equal to 0, the output is not made ready for input (default setting). If neither ON, OFF, nor flag is specified after INPUT, the ON addition takes effect.

Within an area that is ready for input, icons are displayed empty and symbols are displayed as characters according to the code page. Line elements are not made ready for input. The characters "-" and "|", however, are not transformed into line elements in a ready-for-input list area and are not displayed as being ready for input. In particular, the latter also applies to the ULINE statement.

The width of the list area that is ready for input is defined by the output length. If in Unicode systems the display of contents from the list buffer in a list area that is ready for input results in truncation, the indicator is placed outside the area. The number of characters that can be entered is limited by the output length. The content cannot be moved. In Unicode systems, the number of characters that can be entered depends on the space that the individual characters require.

The entries made by the user are saved in the list buffer and can be evaluated during a list event. If characters were truncated in the list, then they will also be lost in the list buffer.


Note

If a list line contains an input field with only blank characters, it is not displayed if the SET BLANK LINES ON statement was not executed beforehand.


Example

Output of a ready-for-input field and evaluation at the AT LINE-SELECTION event. The evaluation is done only if the user clicks on the hotspot below the line that is ready for input.

DATA: input_field TYPE c LENGTH 100, 
      line_num TYPE i. 

START-OF-SELECTION. 
  WRITE 'Input text:'. 
  SET BLANK LINES ON. 
  FORMAT INPUT. 
  WRITE / input_field. 
  FORMAT INPUT OFF. 
  WRITE / '>>> OK <<<' COLOR 5 HOTSPOT. 

AT LINE-SELECTION. 
  IF sy-lisel = '>>> OK <<<'. 
    line_num = sy-lilli - 1. 
    READ LINE line_num FIELD VALUE input_field. 
    WRITE:   'The input was:', 
           /  input_field. 
  ENDIF. 

Addition 6

... FRAMES [{ON|OFF}|{= flag}]

Effect

This addition defines whether the "-" and "|" characters are converted into line elements. flag expects a data object of type i. If ON is specified or if the content of flag is not equal to 0, the conversion is made in the relevant list area (default setting). If OFF is specified or if the content of flag is not equal to 0, the conversion does not take place. If neither ON, OFF, nor flag are specified after FRAMES, the ON addition takes effect.

In the FRAMES ON setting, the following points apply:

  • If the "-" and "|" characters are displayed directly next to each other or above each other, then they are replaced by line elements, resulting in continuous lines (frames). This applies particularly to the output of lines using ULINE.
  • A solitary "|" character is always replaced by a vertical line.
  • Line elements that are displayed explictly by the AS LINE addition are not replaced by other line elements and they do not influence "-" and "|" characters that are next to each other.

In the FRAMES OFF setting, the "-" and "|" are not converted into line elements. You can display line elements explicitly by using the AS LINE addition.


Note

The FRAMES OFF addition is suitable for preventing unwanted results in print lists. This applies particularly to lists that are intended for archiving.


Example

Output of a Frame While Joining/Not Joining the Characters "-" and "|"

CLASS demo DEFINITION. 
  PUBLIC SECTION. 
    CLASS-METHODS main. 
  PRIVATE SECTION. 
    CLASS-METHODS frame. 
ENDCLASS. 

CLASS demo IMPLEMENTATION. 
  METHOD main. 
    FORMAT FRAMES ON. 
    frame( ). 
    FORMAT FRAMES OFF. 
    frame( ). 
  ENDMETHOD. 
  METHOD frame. 
    SKIP. 
    WRITE: / '----', 
           / '|  |', 
           / '----'. 
  ENDMETHOD. 
ENDCLASS. 

START-OF-SELECTION. 
  demo=>main( ). 

Addition 7

... RESET

Effect

This addition sets all formatting settings for which the corresponding addition is not specified in the same FORMAT statement to the state OFF, apart from the setting of the FRAMES addition, which is set to ON. For settings whose addition is also specified, the RESET addition has no effect,

The following table shows the effect of RESET compared with the default settings (the setting when the program starts and the setting that is made for reporting and list events).

Addition State after RESET State after Program Start State after Reporting Event/List Event
COLOR OFF OFF OFF
INTENSIFIED OFF ON ON
INVERSE OFF OFF OFF
HOTSPOT OFF OFF OFF
INPUT OFF OFF OFF
FRAMES ON ON No change


Example

This FORMAT statement creates the default setting after the program starts.

FORMAT RESET 
       INTENSIFIED ON. 

Continue

Lists, Supported Colors