Write report straight to printer
The code below demonstrates how send a report created using the write statement straight to the printer, via the print dialog box. Alternative method for doing this would be to use sapscript.
* *Print parameter declarations DATA: val(1) TYPE c, pripar TYPE pri_params, arcpar TYPE arc_params, lay TYPE pri_params-paart, lines TYPE pri_params-linct, rows TYPE pri_params-linsz. lay = 'X_65_255'. lines = 255. rows = 65. CALL FUNCTION 'GET_PRINT_PARAMETERS' EXPORTING in_archive_parameters = arcpar in_parameters = pripar layout = lay * line_count = lines * line_size = rows * no_dialog = 'X' IMPORTING out_archive_parameters = arcpar out_parameters = pripar valid = val EXCEPTIONS archive_info_not_found = 1 invalid_print_params = 2 invalid_archive_params = 3 OTHERS = 4. check val EQ 'X'. NEW-PAGE PRINT ON NEW-SECTION PARAMETERS pripar ARCHIVE PARAMETERS arcpar NO DIALOG. Write:/ 'Hello'. NEW-PAGE PRINT OFF.
*Write to printer DATA: ld_params LIKE pri_params, ld_valid TYPE c, ld_lay TYPE pri_params-paart, * Example of seting default layout ld_lay = 'X_65_255'. CALL FUNCTION 'GET_PRINT_PARAMETERS' EXPORTING * ARCHIVE_ID = C_CHAR_UNKNOWN * ARCHIVE_INFO = C_CHAR_UNKNOWN * ARCHIVE_MODE = C_CHAR_UNKNOWN * ARCHIVE_TEXT = C_CHAR_UNKNOWN * AR_OBJECT = C_CHAR_UNKNOWN * ARCHIVE_REPORT = C_CHAR_UNKNOWN * AUTHORITY = C_CHAR_UNKNOWN * COPIES = C_NUM3_UNKNOWN * COVER_PAGE = C_CHAR_UNKNOWN * DATA_SET = C_CHAR_UNKNOWN * DEPARTMENT = C_CHAR_UNKNOWN * DESTINATION = C_CHAR_UNKNOWN * EXPIRATION = immediately = 'X' * IN_ARCHIVE_PARAMETERS = ' ' * IN_PARAMETERS = ' ' LAYOUT = ld_layout "'X_PAPER' * LINE_COUNT = C_INT_UNKNOWN * LINE_SIZE = C_INT_UNKNOWN LIST_NAME = 'TEST' LIST_TEXT = 'Test page' * MODE = ' ' NEW_LIST_ID = 'X' no_dialog = ' ' * RECEIVER = C_CHAR_UNKNOWN release = 'X' * REPORT = C_CHAR_UNKNOWN * SAP_COVER_PAGE = 'X' * HOST_COVER_PAGE = C_CHAR_UNKNOWN * PRIORITY = C_NUM1_UNKNOWN * SAP_OBJECT = C_CHAR_UNKNOWN * TYPE = C_CHAR_UNKNOWN * USER = SY-UNAME IMPORTING * OUT_ARCHIVE_PARAMETERS = out_parameters = ld_params valid = ld_valid EXCEPTIONS archive_info_not_found = 1 invalid_print_params = 2 invalid_archive_params = 3 OTHERS = 4 . IF sy-subrc EQ 0. IF ld_valid <> space. new-page print on parameters ld_params NO dialog. write: 'This text will be printed on page'. write: 'This text will be printed on page'. * Stop spool report appearing, maybe option to remove this leave to screen 0. ENDIF. ENDIF.
Related Articles
ALV grid reports using the object methods functionality
ALV TREE Example ABAP code and information for creating ALV tree based reports
SAP Dynamic documents in ABAP objects
SAP dynamic document example screens
ABAP report Progress indicator - When added also Stops report timeout
SAP progress indicator bar to count number of records processed within ABAP report and stop timeout
SAP percentage complete progress indicator bar for your ABAP reports
Prevent ABAP report timeout by Reseting the SAP runtime value using TH_REDISPATCH
ABAP Reporting - Example code and information on various areas of ABAP reporting
ABAP Automatic refresh report to retrieve real time live data from SAP database
Automatic Refresh Report - periodically refreshes results
Capture ABAP report using WRITE statement to internal table with SAP
Convert Spool request to PDF and send as e-mail
Convert Spool request to PDF and send as e-mail
Execute ABAP Report using the SUBMIT statement
ABAP report to display all the selection screen fields and any values input by the user