Beruflich Dokumente
Kultur Dokumente
Community WIKI SAP Community Welcome, Guest Login Register Search the Community
This document will help you all to create a Pdf download of classical report by generating a Spool
Request .
Basic Steps .
1) Generate the classical Report output .
2) Create a Spool Request .
3) Search the Spool Request .
4) Submit the Spool Request for Pdf Creation .
5) Download the Pdf Output in Presentation server or Application Server .
Detail Steps
but it will create infinite loop , so use abap memory and export a flag variable with a value to restricted the excution of the above submit only once and all the internal table and other
data which you want in your program . below is the example .
* importing variable value set at first time to restrict the infinite loop .
IMPORT var FROM MEMORY ID 'abc' .
var = var + 1 .
*checking variable to restricted scecond time exction of this block of code
* *IF var = 1 .
v_memid = 1 .
EXPORT var TO MEMORY ID 'abc' . (flag variable to restrict the excution only once )
*EXPORT it_pernr it_pernr_quali v_memid TO MEMORY ID 'bcd' . (internal table and other data)*
* submitting the spool request
SUBMIT (p_repid) TO SAP-SPOOL
SPOOL PARAMETERS mstr_print_parms
WITHOUT SPOOL DYNPRO
AND RETURN.
ENDIF.
https://wiki.scn.sap.com/wiki/display/ABAP/PDF+Download+By+Creating+Spool+Request 1/7
7/5/2018 PDF Download By Creating Spool Request - ABAP Development - SCN Wiki
4) Submit the Spool Request for Pdf Creation .
set the printer configuration
DATA:
mstr_print_parms LIKE pri_params,
mc_valid(1) TYPE c,
mi_bytecount TYPE i,
mi_length TYPE i,
mi_rqident LIKE tsp01-rqident.
*-- INTERNAL TABLES
DATA:
mtab_pdf LIKE tline OCCURS 0 WITH HEADER LINE,
mc_filename LIKE rlgrap-filename.
*-- SELECTION SCREEN
DATA:
p_linsz LIKE sy-linsz VALUE 132, " Line size
p_paart LIKE sy-paart VALUE 'X_65_132'. " Paper Format
https://wiki.scn.sap.com/wiki/display/ABAP/PDF+Download+By+Creating+Spool+Request 2/7
7/5/2018 PDF Download By Creating Spool Request - ABAP Development - SCN Wiki
* *DATA: l_file TYPE string .
l_file = p_file .
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
filename = l_file
filetype = 'BIN'
TABLES
data_tab = it_pdf
* FIELDNAMES =
EXCEPTIONS
file_write_error =1
no_batch =2
gui_refuse_filetransfer =3
invalid_type =4
no_authority =5
unknown_error =6
header_not_allowed =7
separator_not_allowed =8
filesize_not_allowed =9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
or Application Server
*downloading the pdf file in applecation server
OPEN DATASET p_file FOR OUTPUT IN BINARY MODE .
IF sy-subrc = 0 .
LOOP AT it_pdf .
TRANSFER it_pdf TO p_file .
ENDLOOP.
CLOSE DATASET p_file .
ELSE.
WRITE : / 'operating system could not open file' .
ENDIF.
*-- STRUCTURES
DATA:
lc_rq2name LIKE tsp01-rq2name.
https://wiki.scn.sap.com/wiki/display/ABAP/PDF+Download+By+Creating+Spool+Request 3/7
7/5/2018 PDF Download By Creating Spool Request - ABAP Development - SCN Wiki
DATA:
mstr_print_parms LIKE pri_params,
mc_valid(1) TYPE c,
mi_bytecount TYPE i,
mi_length TYPE i,
mi_rqident LIKE tsp01-rqident.
*-- INTERNAL TABLES
DATA:
mtab_pdf LIKE tline OCCURS 0 WITH HEADER LINE,
mc_filename LIKE rlgrap-filename.
*-- SELECTION SCREEN
DATA:
p_linsz LIKE sy-linsz VALUE 132, " Line size
p_paart LIKE sy-paart VALUE 'X_65_132'. " Paper Format
* importing variable value set at first time to restrict the infinite loop .
IMPORT var FROM MEMORY ID 'abc' .
var = var + 1 .
p_uname = sy-uname .
p_repid = sy-repid .
*checking variable to restricted scecond time exction of this block of code
IF var = 1 .
v_memid = 1 .
EXPORT var TO MEMORY ID 'abc' .
EXPORT it_pernr it_pernr_quali v_memid p_file TO MEMORY ID 'bcd' .
* submitting the spool request
SUBMIT (p_repid) TO SAP-SPOOL
SPOOL PARAMETERS mstr_print_parms
WITHOUT SPOOL DYNPRO
AND RETURN.
ENDIF.
https://wiki.scn.sap.com/wiki/display/ABAP/PDF+Download+By+Creating+Spool+Request 4/7
7/5/2018 PDF Download By Creating Spool Request - ABAP Development - SCN Wiki
CONCATENATE p_repid v_temp
p_uname INTO lc_rq2name .
ENDIF.
https://wiki.scn.sap.com/wiki/display/ABAP/PDF+Download+By+Creating+Spool+Request 5/7
7/5/2018 PDF Download By Creating Spool Request - ABAP Development - SCN Wiki
*downloading the pdf file in applecation server
OPEN DATASET p_file FOR OUTPUT IN BINARY MODE .
IF sy-subrc = 0 .
LOOP AT it_pdf .
TRANSFER it_pdf TO p_file .
ENDLOOP.
CLOSE DATASET p_file .
ELSE.
WRITE : / 'operating system could not open file' .
ENDIF.
PDF outupt
3 Comments
Former Member
HI Priyanka,
Thanks for good article. But there is an issue while copy this program in variable declaration.
Regards,
Madhu.
Former Member
Good.There are some good wikis on this topic.Is there any addition things you added.
Regards,
Madhu.
Former Member
Good.There are some good wikis on this topic.Is there any addition things you added.
Regards,
Madhu.
https://wiki.scn.sap.com/wiki/display/ABAP/PDF+Download+By+Creating+Spool+Request 6/7
7/5/2018 PDF Download By Creating Spool Request - ABAP Development - SCN Wiki
https://wiki.scn.sap.com/wiki/display/ABAP/PDF+Download+By+Creating+Spool+Request 7/7