Beruflich Dokumente
Kultur Dokumente
output
2.
3.
4.
a.
use method CL_ABAP_ZIP->ADDto add a file to compress PDF file.This method requires the content in
xstring fromat and not in an internal table. If Our data is in an internal table We will have to convert it into xstring(Step-3).
CL_ABAP_ZIP->ADD method requires file name and Content in xstring format.
b.
5.
CL_ABAP_ZIP->SAVE method gives the zipped file we want. Zipped file is also type xstring.
As CL_ABAP_ZIP->SAVE gives xstring file, we need to convert using SCMS_XSTRING_TO_BINARY to binary
and download using GUI_DOWNLOAD with file type 'BIN'.
REPORT ztest_zip_repoutout.
DATA:g_val
TYPE c,
w_pripar
TYPE pri_params,
w_arcpar
TYPE arc_params,
input_length TYPE i,
content_x
TYPE xstring,
content_s
TYPE string,
spool_no
LIKE tsp01-rqident,
it_pdf
TYPE
wa_pdf
LIKE
file_tab
TYPE
bin_file
TYPE
bytecount
TYPE
zip
TYPE
path_table
TYPE
DATA: BEGIN OF it_t001
bukrs
TYPE
butxt
TYPE
END OF it_t001.
DATA:g_zipper
TYPE
DATA:file_name
TYPE
DATA:file_path
TYPE
START-OF-SELECTION.
PERFORM get_data.
PERFORM print_data CHANGING spool_no.
PERFORM convert_spool_2_pdf.
PERFORM convert_binary_2_xstring.
PERFORM zipping_pdf_file.
PERFORM download_zip_file.
*&---------------------------------------------------------------------*
*&
Form get_data
*&---------------------------------------------------------------------*
FORM get_data .
SELECT * FROM t001
INTO CORRESPONDING FIELDS OF TABLE it_t001 UP TO 10 ROWS.
ENDFORM.
" get_data
*&---------------------------------------------------------------------*
*&
Form print_data
*&---------------------------------------------------------------------*
FORM print_data CHANGING spool_no.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
in_archive_parameters = w_arcpar
in_parameters
= w_pripar
layout
= 'X_65_132'
line_count
= 65
line_size
= 132
no_dialog
= 'X'
IMPORTING
out_archive_parameters = w_arcpar
out_parameters
= w_pripar
valid
= g_val.
IF g_val NE space AND sy-subrc = 0.
w_pripar-prrel = space.
w_pripar-primm = space.
NEW-PAGE PRINT ON NEW-SECTION PARAMETERS w_pripar ARCHIVE PARAMETERS
w_arcpar NO DIALOG.
"Output which is gone to spool
LOOP AT it_t001.
WRITE:/ it_t001.
ENDLOOP.
ENDFORM.
" zipping_pdf_file
*&---------------------------------------------------------------------*
*&
Form download_zip_file
*&---------------------------------------------------------------------*
FORM download_zip_file .
"convert to table
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer
= zip
IMPORTING
output_length = bytecount
TABLES
binary_tab
= file_tab.
"Save the file
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = bytecount
filename
= file_path
filetype
= 'BIN'
TABLES
data_tab
= file_tab.
ENDFORM.
" download_zip_file