The basic ABAP statement for displaying data on the screen is WRITE.
This statement writes field f to the current list in its standard output format. By default, the list is displayed on the screen.
Field f can be
· any data object (see Data Objects)
· a field symbol or formal parameter (see Working with Field Symbols).
· a text symbol (see Maintaining Text Elements)
You can print the current output list directly from the output screen by choosing Print.
If a selection screen is defined for the program (see Selection Screens), you can choose Execute and print on the selection screen. Then, the list is not displayed on the screen, but sent directly to a printer.
WRITE 'Hello, here I am!'.
When you start this program, the system leaves the current screen (this may be the ABAP Editor Initial Screen) and branches to the output screen:
The name of the output screen is identical to the title of the program specified in the program attributes (see Maintaining Program Attributes).
The first line on the screen contains the list header. By default, the list header is identical to the title of the program. However, you can maintain the list header alone outside the actual program without affecting the program title. For more information on this topic, see Maintaining Text Elements. The current page number (1) appears on the right.
A horizontal line is displayed, then the actual list begins. The output is displayed here.
You can choose Search to search for specific patterns.
On the screen, the output is normally left-justified. If you use several WRITE statements, the output fields are displayed one after the other, each separated by one column (that is, one blank). If there is not enough space for an output field in the current line, a new line is started.
WRITE: 'COMPANY: ', spfli-carrid.
Note the use of the colon and the commas. The example contains two WRITEstatements that are combined into a statement chain.
In the above example, two fields, literal 'COMPANY: ' and component CARRID of table work area SPFLI, are displayed on the screen.
The format of the data fields on the output screen depends on their data type (see Predefined Elementary Data Types as well as the keyword documentation).
DATA number TYPE p VALUE '-1234567.89' DECIMALS 2.
WRITE: 'Number', number, 'is packed'.
The output appears as follows:
Number 1,234,567.89- is packed
The number field has a total length of 13, that is, 9 digits including the decimal point, the leading minus sign, and two commas as separators. The output length of the number field is 2*8+1=17 because the field length of a type p field is 8. The remaining characters are filled up with spaces. This means that there are five blanks between the literal 'Number' and the number itself.