2009 Jun 18 9:40 AM
My requirement is that when we Execute the report it will save in presentation server as PDF. No selection screen , no send mail....Only the code which I hv written , press F8 -> may be ask for file path. Bt need to save in PDF as my presentation server.Is It possible save the PDF Output
file in Presentation Server for Background Job schuduling .
I tried -> last post of SDN . Bt failed....
1. 'GET_JOB_RUNTIME_INFO'
2.'CONVERT_ABAPSPOOLJOB_2_PDF'
3.GUI_DOWNLOAD'.....
..
Thanks,
Kamruzzaman
2009 Jun 18 9:47 AM
Hi,
If your report prints some internal table values, then you may use this logic:
DATA :textlines LIKE tline OCCURS 100 WITH HEADER LINE.
DATA otf LIKE itcoo OCCURS 1000 WITH HEADER LINE.
DATA it_lines LIKE tline OCCURS 100 WITH HEADER LINE.
DATA options LIKE itcpo.
DATA header LIKE thead.
DATA result LIKE itcpp.
DATA: bin_filesize TYPE i.
DATA: filesize TYPE i,
convcount TYPE i,
cancel(1).
DATA : BEGIN OF itab OCCURS 0,
matnr TYPE mara-matnr,
END OF itab.
SELECT matnr FROM mara UP TO 10 ROWS INTO TABLE itab.
LOOP AT itab.
textlines-tdformat = '*'.
textlines-tdline = itab-matnr.
APPEND textlines.
ENDLOOP.
options-tdgetotf = 'X'.
options-tdnoprev = 'X'.
CALL FUNCTION 'PRINT_TEXT'
EXPORTING
dialog = ' '
header = header
OPTIONS = options
IMPORTING
RESULT = RESULT
tables
lines = textlines
otfdata = otf.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = filesize
TABLES
otf = otf
lines = it_lines
EXCEPTIONS
err_conv_not_possible = 1
err_bad_otf = 2.
DATA : g_file TYPE string.
g_file = pcfile.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = bin_filesize
filename = g_file
filetype = 'BIN'
TABLES
data_tab = it_lines
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6.
But if your program involves creation of spool then you need to folowing logic:
1. Search for the spoool number
2. Call this FM
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = it_tsp01-rqident
dst_device = 'LP01'
TABLES
pdf = it_pdf
3.Call GUI_UPLOAD to download the file.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
filename = l_file
filetype = 'BIN'
TABLES
data_tab = it_pdf
Regards,
Mansi.
Edited by: SAP USER on Jun 18, 2009 10:49 AM
2009 Jun 18 9:49 AM
Hi,
try this FM CONVERT_ABAPSPOOLJOB_2_PDF
hope it'll help.
Regards,
Sneha.
2009 Jun 18 9:53 AM
Hello Kamruzzaman,
Is It possible save the PDF Output file in Presentation Server for Background Job schuduling .
It is not possible. You have to use a workaround like save to application server, better still send PDF as a mail attachment.
You can search in SDN for these details.
BR,
Suhas
2009 Jun 18 10:10 AM
Hi kamaruzzaman,
1. You can not run a program in background when you want to download to Presentation server.
2. If you want to download program output as PDF to the presentation server in foreground only.
Try the following.
<pre>REPORT ztest_print.
TABLES:
tsp01.
"Variables
DATA:
l_lay TYPE pri_params-paart,
l_lines TYPE pri_params-linct,
l_cols TYPE pri_params-linsz,
l_val TYPE c.
*Types
TYPES:
t_pripar TYPE pri_params,
t_arcpar TYPE arc_params.
"Work areas
DATA:
lw_pripar TYPE t_pripar,
lw_arcpar TYPE t_arcpar.
"Variables
DATA:
l_no_of_bytes TYPE i,
l_pdf_spoolid LIKE tsp01-rqident,
l_jobname LIKE tbtcjob-jobname,
l_jobcount LIKE tbtcjob-jobcount,
file_name TYPE string.
"Types
TYPES:
t_attachment TYPE solisti1,
t_pdf TYPE tline.
"Workareas
DATA :
w_attachment TYPE t_attachment,
w_pdf TYPE t_pdf.
"Internal Tables
DATA :
i_attachment TYPE STANDARD TABLE OF t_attachment,
i_pdf TYPE STANDARD TABLE OF t_pdf.
&----
*& Selection-screen
&----
PARAMETERS:
p_file TYPE ibipparms-path.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM f4_for_p_file CHANGING file_name .
INITIALIZATION.
p_file = 'C:\Documents and Settings\Administrator\Desktop\venkat.pdf'.
START-OF-SELECTION.
l_lay = 'X_65_132'.
l_lines = 65.
l_cols = 132.
"Read, determine, change spool print parameters and archive parameters
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
in_archive_parameters = lw_arcpar
in_parameters = lw_pripar
layout = l_lay
line_count = l_lines
line_size = l_cols
no_dialog = 'X'
IMPORTING
out_archive_parameters = lw_arcpar
out_parameters = lw_pripar
valid = l_val
EXCEPTIONS
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 3
OTHERS = 4.
IF l_val <> space AND sy-subrc = 0.
lw_pripar-prrel = space.
lw_pripar-primm = space.
NEW-PAGE PRINT ON
NEW-SECTION
PARAMETERS lw_pripar
ARCHIVE PARAMETERS lw_arcpar
NO DIALOG.
ENDIF.
WRITE 'Test program to generate and download as PDF'.
NEW-PAGE PRINT OFF.
CALL FUNCTION 'ABAP4_COMMIT_WORK'.
tsp01-rqident = sy-spono.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = tsp01-rqident
no_dialog = ' '
IMPORTING
pdf_bytecount = l_no_of_bytes
pdf_spoolid = l_pdf_spoolid
btc_jobname = l_jobname
btc_jobcount = l_jobcount
TABLES
pdf = i_pdf.
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
EXPORTING
line_width_src = 134
line_width_dst = 255
TABLES
content_in = i_pdf
content_out = i_attachment
EXCEPTIONS
err_line_width_src_too_long = 1
err_line_width_dst_too_long = 2
err_conv_failed = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE s000(0k) WITH 'Conversion Failed'.
EXIT.
ENDIF.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = file_name
filetype = 'BIN'
TABLES
data_tab = i_attachment.
&----
*& Form F4_FOR_p_file
&----
FORM f4_for_p_file CHANGING file.
DATA:
l_field_name LIKE dynpread-fieldname VALUE 'P_FILE'.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = l_field_name
IMPORTING
file_name = p_file.
file = p_file.
ENDFORM. " F4_FOR_p_file
</pre>
I hope that it helps u .
Thanks
venkat.O
2009 Jul 08 9:23 AM
Hi Venkat,
I have the same problem that I am facing while converting the ABAP list to PDF. I tried the code that you have specified, but I am getting error as Spool request 0 does not exist. Kindly help.
Regards,
Premal
2009 Jul 08 9:57 AM
Hi,
Refer:
https://wiki.sdn.sap.com/wiki/display/Snippets/SaveReportOutputtoaPDFFile
Hope this helps you.
Regards,
Tarun
2011 Mar 01 1:48 PM