Sei sulla pagina 1di 3

SAP NetWeaver AS ABAP Release 731, Copyright 2011 SAP AG. All rights reserved.

ABAP Keyword Documentation ABAP - Reference User Dialogs Classic Lists printing lists Print Control
PRINT-CONTROL
Short Reference
Syntax
PRINT-CONTROL { { formats|{FUNCTION code}
[LINE line] [POSITION col] }
| { INDEX-LINE index_line } }.
AIternatives:
1. ... formats|{FUNCTION code} [LINE line] [POSITION col]
2. ... INDEX-LINE index_line
Effect
This statement formats areas of print lists or creates index entries in print lists to be archived.
The statement PRINT-CONTROL only works for print lists created using NEW-PAGE PRINT ON, SUBMIT TO SAP-SPOOL, and
by selecting Execute and Print on the selection screen. t does not work for a screen list that has been printed from the
display by selecting Print (function code "PR").
AIternative 1
... formats|{FUNCTION code} [LINE line] [POSITION col]
Effect
This variant sets a print format starting from the line specified in line and the position specified in col for all subsequent
output statements of the current page. The value in col refers to the position within the list buffer. f the additions LINE or
POSITION are not specified, the current position of the list cursor (sy-linno, sy-colno) is used. line and col expect data
objects of type i are expected whose values are within the current page width or page length. f line or col contain invalid
values, the statement is ignored.
The possible print formats formats are listed in the table below. The runtime environment converts these entries into printer-
independent codes called print control. When a list is actually printed, the print control codes are translated into printer-specific
control characters.
formats Print ControI Meaning
CPI cpi CIcpi Characters per inch
LPI lpi LIlpi Lines per inch
COLOR BLACK CO001 Color black
COLOR RED CO002 Color red
COLOR BLUE CO003 Color blue
ABAP Keyword Documentation http://help.sap.com/abapdocu731/en/abapprint-control.htm
1 oI 3 26/02/2013 5:31 PM
COLOR GREEN CO004 Color green
COLOR YELLOW CO005 Color yellow
COLOR PINK CO006 Color pink
FONT font FOfont Font
LEFT MARGIN left LMleft Space from the left margin
SIZE siz SIsiz Font size
The conversion to device-specific control characters is made using the database tables TSP03 and T022D. f a particular
option for a particular printer type (according to table TSP03) is not supported in the table T022D (no entry), this option is
ignored in printing. For more information, see the documentation for the tables TSP03 and T022D.
There are more print control codes than print formats formats than can be specified in the statement PRINT-CONTROL. All
print control codes can also be specified directly in code using the addition FUNCTION. code must be a flat character-like data
object that contains a valid print control code. nvalid content is ignored. A list of valid print control codes and their assignment
to printers is available in spool administration (transaction SPAD).
Notes
The statement PRINT-CONTROL should only be used for print formats that cannot also be set using the formatting
options of the statements WRITE and FORMAT, or in the print dialog.
The statement PRINT-CONTROL must be executed for every page to be formatted. f the additions LINE and
POSITION are used, the source code position of the statement PRINT-CONTROL in relation to the output statements
becomes irrelevant.
The print control codes are written to the print list line at the specified position. A line is limited internally to 4092
characters. f an overflow occurs as a result of too many print control codes, surplus output text lines and print control
codes are truncated without warning.
ExampIe
:The generated spool output in hexadecimal form:
"#SBP01123456789 #SBS01"
This statement list can be used to print bar codes.
WRITE: /.
PRINT-CONTROL FUNCTION 'SBP01'.
WRITE: '123456789'.
PRINT-CONTROL FUNCTION 'SBS01'.
AIternative 2
... INDEX-LINE index_line
Effect
This variant inserts the content of the data object index_line into the current print list as an index line. index_line must be
a flat character-like data object. f the list cursor of an output statement has been set in the current list line, the index line is
inserted after the end of the line.
An index line is sent to the spool system as a part of the print list and is displayed there, although not included in the print
output. When archiving the list using ArchiveLink the index lines are stored in a description file.
ABAP Keyword Documentation http://help.sap.com/abapdocu731/en/abapprint-control.htm
2 oI 3 26/02/2013 5:31 PM
n archiving, the spool system divides a list into a data file and a description file. The data file contains the actual print lists, and
the description file contains the index lines. f the content of the index lines is structured according to a convention described
in the ArchiveLink documentation, index lines enable an effective search in archived lists.
ExampIe
nserting index lines in a list of square numbers. After every hundredth line, index lines for archiving are generated (DAN lines)
using the statement PRINT-CONTROL. The structure of the DAN lines is defined at the start of the list in two additional index
lines (DKEY lines). f the user selects Execute and Print on the selection screen and archives the list in the print dialog, the
archived list can be searched for the indexes.
PARAMETERS number TYPE i.
DATA: index TYPE i,
square TYPE decfloat16,
numb TYPE i,
num TYPE c LENGTH 4,
dkey TYPE c LENGTH 100,
dain TYPE c LENGTH 100.
dkey ='DKEYIndex'.
dkey+44 = '0'.
dkey+47 = '3'.
PRINT-CONTROL INDEX-LINE dkey.
CLEAR dkey.
dkey ='DKEYNumber'.
dkey+44 = '3'.
dkey+47 = '4'.
PRINT-CONTROL INDEX-LINE dkey.
index = 0.
DO number TIMES.
index = index + 1.
IF index = 100.
numb = sy-index / 100.
WRITE numb TO num LEFT-JUSTIFIED.
dain = 'DAIN' && 'IDX' && num.
PRINT-CONTROL INDEX-LINE dain.
index = 0.
ENDIF.
square = sy-index ** 2.
WRITE: / sy-index, square STYLE cl_abap_math=>scientific.
ENDDO.
ABAP Keyword Documentation http://help.sap.com/abapdocu731/en/abapprint-control.htm
3 oI 3 26/02/2013 5:31 PM

Potrebbero piacerti anche