‎2010 Jan 25 4:20 AM
Hi,
I want to know how to conert an internal table into pdf file is there any fm avaliable for this .
regards,
zafar
‎2010 Jan 25 4:45 AM
try this sample code--
tables:tsp01.
TYPE-POOLS : vrm.
DATA : vrm_val TYPE vrm_values,
wa_vrm LIKE LINE OF vrm_val,
g_name LIKE wa_vrm-text.
data: w_pdf like table of tline.
data:
print_parameters like pri_params,
valid_flag(1) type c,
w_spono type tsp01-rqident.
CLEAR wa_vrm.
wa_vrm-key = 'M'.
wa_vrm-text = 'Mango'.
APPEND wa_vrm TO vrm_val.
CLEAR wa_vrm.
wa_vrm-key = 'P'.
wa_vrm-text = 'Pineapple'.
APPEND wa_vrm TO vrm_val.
CLEAR wa_vrm.
wa_vrm-key = 'A'.
wa_vrm-text = 'apple'.
APPEND wa_vrm TO vrm_val.
call function 'GET_PRINT_PARAMETERS'
exporting
no_dialog = 'X'
user = sy-uname
importing
out_parameters = print_parameters
valid = valid_flag
exceptions
invalid_print_params = 2
others = 4.
if valid_flag = 'X' and sy-subrc = 0.
new-page print on parameters print_parameters
no dialog.
LOOP AT vrm_val into wa_vrm. " your internal table
WRITE :wa_vrm-key.
ENDLOOP.
LOOP AT vrm_val into wa_vrm.
WRITE : wa_vrm-text.
ENDLOOP.
new-page print off.
endif.
w_spono = sy-spono.
call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
exporting
src_spoolid = w_spono
tables
pdf = w_pdf[]
.
if sy-subrc EQ 0.
endif.
call function 'GUI_DOWNLOAD'
exporting
filename = 'C:\w_pdf.pdf'
filetype = 'BIN'
tables
data_tab = w_pdf[]
.
if sy-subrc EQ 0.
endif.Sumit
‎2010 Jan 25 4:28 AM
Hi Zafar,
You can follow the following steps :
1) Create a Spool number
2) Then use FM 'CONVERT_ABAPSPOOLJOB_2_PDF' to convert to PDF.
‎2010 Jan 25 4:33 AM
Hi,
You can use submit report to generate spool number.
SUBMIT zricef_test USING SELECTION-SET v_variant
WITH p_online = 'X'
TO SAP-SPOOL
SPOOL PARAMETERS %_print
WITHOUT SPOOL DYNPRO
AND RETURN.
Then use FM 'RSPO_RETURN_ABAP_SPOOLJOB'.
And then to convert this internal table into PDF use FM 'CONVERT_ABAPSPOOLJOB_2_PDF'.
Thansk,
Archana
‎2010 Jan 25 4:45 AM
try this sample code--
tables:tsp01.
TYPE-POOLS : vrm.
DATA : vrm_val TYPE vrm_values,
wa_vrm LIKE LINE OF vrm_val,
g_name LIKE wa_vrm-text.
data: w_pdf like table of tline.
data:
print_parameters like pri_params,
valid_flag(1) type c,
w_spono type tsp01-rqident.
CLEAR wa_vrm.
wa_vrm-key = 'M'.
wa_vrm-text = 'Mango'.
APPEND wa_vrm TO vrm_val.
CLEAR wa_vrm.
wa_vrm-key = 'P'.
wa_vrm-text = 'Pineapple'.
APPEND wa_vrm TO vrm_val.
CLEAR wa_vrm.
wa_vrm-key = 'A'.
wa_vrm-text = 'apple'.
APPEND wa_vrm TO vrm_val.
call function 'GET_PRINT_PARAMETERS'
exporting
no_dialog = 'X'
user = sy-uname
importing
out_parameters = print_parameters
valid = valid_flag
exceptions
invalid_print_params = 2
others = 4.
if valid_flag = 'X' and sy-subrc = 0.
new-page print on parameters print_parameters
no dialog.
LOOP AT vrm_val into wa_vrm. " your internal table
WRITE :wa_vrm-key.
ENDLOOP.
LOOP AT vrm_val into wa_vrm.
WRITE : wa_vrm-text.
ENDLOOP.
new-page print off.
endif.
w_spono = sy-spono.
call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
exporting
src_spoolid = w_spono
tables
pdf = w_pdf[]
.
if sy-subrc EQ 0.
endif.
call function 'GUI_DOWNLOAD'
exporting
filename = 'C:\w_pdf.pdf'
filetype = 'BIN'
tables
data_tab = w_pdf[]
.
if sy-subrc EQ 0.
endif.Sumit
‎2010 Jan 25 5:10 AM
Hi,
Thanks for your reply.
As the code which u have given it required spool no. but I have a normal zreport and output table of that report i want to convert in pdf so how to do it w/o sool number.
regards,
zafar
‎2010 Jan 25 5:15 AM
Hi,
I guess below wiki will solve your problem
http://wiki.sdn.sap.com/wiki/display/Snippets/SaveReportOutputtoaPDFFile
Pooja
‎2010 Jan 25 5:07 AM
Hi,
Please follow te below mentioned wiki to solve your problem:
http://wiki.sdn.sap.com/wiki/display/ABAP/PDFDownlaodByCreatingSpool+Request
Hope this might help you.
Pooja