Professional Documents
Culture Documents
Week 2 :
Simple Output Statements
B1 - 2
The date today is: 12/30/1996 The current time is: 12:32:06
********************
B1 - 3
Notes
The WRITE statement outputs the contents of a field or constant in a
format consistent with the data type.
Successive WRITE statements output data on the same output line.
When the line is full, output continues on the next line.
The SKIP <n> statement creates <n> blank lines.
Normally, ABAP produces two standard header lines for each page.
The date and page number are displayed on the first header line
along with the program title. The second header line is an underline.
The date does not display until the report is printed.
Many system fields are available in an ABAP program. These system
fields are defined in the ABAP Dictionary structure SYST. To
reference system fields in a program, use SY-<field name>. For
example, SY-DATUM indicates the current date and SY-UZEIT
indicates the current time.
- You can use many methods to view the system ABAP Dictionary
B1 - 4
Notes
ABAP provides many methods for formatting data.
You can specify when to start a new line of output, start columns,
and/or output length with the following statement:
WRITE /<pos(len)> . . .
- The forward slash (/) in the WRITE statement will start the output
on a new line.
- NEW-LINE new line, corresponds to "/" in the WRITE statement.
Notes
The UNDER addition to the WRITE statement allows you to specify a
field to be printed in the same start column (left justified) directly
beneath a field which has already been output.
You must still code an explicit line feed (with a forward slash) to move
to the next line. The UNDER addition does not act as a line feed.
Note :
The values of sy-datum and sy-uzeit are set at the beginning of
program execution and do not change until the program ends. If you
need access to the most current date and time during execution of a
long-running pro-gram, use the statement get time. It updates the
values of sy-datum and sy-uzeit to reflect the current date and time.
B1 - 8
Format Options
B1 - 9
Notes
The sequence for the format specification of the WRITE statement
must be followed precisely if more than one specification is used.
Formatting options include:
- LEFT-JUSTIFIED - Output will start at left margin
Notes
DD/MM/YY Overrides the date formatting rule defined at the User
profile level.
CURRENCY <key> Formats currency fields based on rules defined
in table TCURX.
UNIT <key> determines the number of decimal places for quantities
in the list output. The specified key is used to read the number of
decimal places in table T006.
UNDER <g> The output begins at the column in which field <g> was
output.
B1 - 11
NEW-PAGE Statement
WRITE ‘***** City of Philadelphia *****’.
SKIP.
WRITE: / ‘Ticket Date’, 15 SY-DATUM.
WRITE: / ‘Ticket Time’, 15 SY-UZEIT.
SKIP.
WRITE ‘***** Department of Public Safety *****’.
NEW-PAGE.
WRITE: ‘Comments:’. <program title> 1
--------------------------------------------------------------------------------------
***** City of Philadelphia *****
Ticket Date 01/01/1997
Ticket Time 18:01:00
<program title> 2
---------------------------------------------------------------------------------------
Comments:
B1 - 12
Notes
The NEW-PAGE statement starts a new page.
This statement will not create an empty page.
Exercises
Notes
The values of sy-datum and sy-uzeit are set at the beginning of
program execution and do not change until the program ends. If you
need access to the most current date and time during execution of a
long-running pro-gram, use the statement get time. It updates the
values of sy-datum and sy-uzeit to reflect the current date and time.
B1 - 16
Notes
During generation of a list, the ABAP runtime system fills the following
system fields:
During generation of the list, the system fills the last three system
fields continuously.
B1 - 19
Notes
The default report line width is 83 columns. To override these defaults,
use the additions LINE-SIZE <columns> and LINE-COUNT
<lines_per_page> on the REPORT statement. Note that the values for
lines per page and column width must be numbers and not data object
names.
You can override the default values for each list buffer by using the NEW-
PAGE LINE-SIZE <columns> and/or LINE-COUNT <lines-per-page>. To
return to the default values set <lines> and/or <columns> to zero.
The number of lines per page includes headings, detail, and footer lines.
If the value of <lines_per_page> is less than the actual lines on the page,
the report will terminate.
Thank you