SAP PRINT ON OFF

Get Example source ABAP code based on a different SAP table
  


ARTICLE

Switch Spooling On and Off
As long as spooling is switched off, all list output is written to the list buffer for the current screen list. When spooling is switched on, a spool list is created. You can switch on spooling as follows:
Use statement NEW-PAGE PRINT ON.
Choose function Execute + Print on the standard selection screen of an executable program.
Call an executable program with the addition TO SAP-SPOOL of statement SUBMIT.
Schedule an executable program in a background job using the additions VIA JOB and TO SAP-SPOOL of statement SUBMIT.
When using NEW-PAGE PRINT ON, spooling is explicitly switched on in the program. With the other three options, spooling is switched on from the beginning of executing an executable program. Switching on spooling opens a new spool list level .
Only the spooling switched on with NEW-PAGE PRINT ON can be switched off again using NEW-PAGE PRINT OFF. Spooling that is switched on at the start of a program, cannot be switched off within this same program. In particular, spooling is always switched on when executing a program in background processing.

Examples

Explicitly switching on spooling
DATA: params TYPE pri_params,
valid TYPE c.

CALL FUNCTION 'GET_PRINT_PARAMETERS'
IMPORTING out_parameters = params
valid = valid.

IF valid <(><<)>> space.
NEW-PAGE PRINT ON PARAMETERS params NO DIALOG.

WRITE / ...

NEW-PAGE PRINT OFF.
ENDIF.


Switching optical archiving on explicitly
DATA: pri_params TYPE pri_params,
arc_params TYPE arc_params,
valid TYPE c.

CALL FUNCTION 'GET_PRINT_PARAMETERS'
IMPORTING out_parameters = pri_params
out_archive_parameters = arc_params
valid = valid.

IF valid <(><<)>> space.
NEW-PAGE PRINT ON PARAMETERS pri_params
ARCHIVE PARAMETERS arc_params NO DIALOG.
PRINT-CONTROL •-LINE ' '.

WRITE / ....

NEW-PAGE PRINT OFF.
ENDIF.


Program call
DATA: params TYPE pri_params,
valid TYPE c.

CALL FUNCTION 'GET_PRINT_PARAMETERS'
IMPORTING out_parameters = params
valid = valid.

IF valid <(><<)>> space.
SUBMIT myreport TO SAP-SPOOL WITHOUT SPOOL DYNPRO
SPOOL PARAMETERS params.
ENDIF.


Scheduling a background job
DATA: params TYPE pri_params,
valid TYPE c.

CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING mode = 'BATCH'
report = 'MYREPORT'
IMPORTING out_parameters = params
valid = valid.

IF valid <(><<)>> space.
CALL FUNCTION 'JOB_OPEN' .... EXPORTING jobcount ...
SUBMIT myreport VIA JOB 'MY_JOB' NUMBER jobcount
TO SAP-SPOOL WITHOUT SPOOL DYNPRO
SPOOL PARAMETERS params.
CALL FUNCTION 'JOB_CLOSE' ...
ENDIF.