‎2009 Jun 29 6:57 AM
Hi All,
I am trying to convert internal table to pdf fomrat.
I have used RSPO_OPEN_SPOOLREQUEST , RSPO_WRITE_SPOOLREQUEST , RSPO_CLOSE_SPOOLREQUEST and finally CONVERT_ABAPSPOOLJOB_2_PDF. There is a table PDF in CONVERT_ABAPSPOOLJOB_2_PDF .But , when i debug the code,
i see some unknon chinese characters in the table PDF.Was there any problem or is this normal.
Regards
--Pradeep
Edited by: pradeep nellore on Jun 29, 2009 7:57 AM
‎2009 Jun 29 7:48 AM
Hi Pradeep,
Here is the sample program for your requirement.
I hope that it solves your problem.
Thanks
Venkat.OREPORT ztest_notepad.
"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.
DATA:
it_t100 TYPE t100 OCCURS 0 WITH HEADER LINE,
it_pdf TYPE tline OCCURS 0 WITH HEADER LINE.
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.
* Get data
SELECT *
FROM t100
INTO TABLE it_t100
UP TO 100 ROWS
WHERE sprsl = sy-langu.
LOOP AT it_t100.
WRITE:/ it_t100.
ENDLOOP.
NEW-PAGE PRINT OFF.
CALL FUNCTION 'ABAP4_COMMIT_WORK'.
"Variables
DATA:
l_no_of_bytes TYPE i,
l_pdf_spoolid LIKE tsp01-rqident,
l_jobname LIKE tbtcjob-jobname,
l_jobcount LIKE tbtcjob-jobcount.
DATA:
spoolno TYPE tsp01-rqident.
spoolno = sy-spono.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = spoolno
no_dialog = ' '
IMPORTING
pdf_bytecount = l_no_of_bytes
pdf_spoolid = l_pdf_spoolid
btc_jobname = l_jobname
btc_jobcount = l_jobcount
TABLES
pdf = it_pdf.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\itab_to_pdf.pdf'
filetype = 'BIN'
TABLES
data_tab = it_pdf.
‎2009 Jun 29 7:48 AM
Hi Pradeep,
Here is the sample program for your requirement.
I hope that it solves your problem.
Thanks
Venkat.OREPORT ztest_notepad.
"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.
DATA:
it_t100 TYPE t100 OCCURS 0 WITH HEADER LINE,
it_pdf TYPE tline OCCURS 0 WITH HEADER LINE.
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.
* Get data
SELECT *
FROM t100
INTO TABLE it_t100
UP TO 100 ROWS
WHERE sprsl = sy-langu.
LOOP AT it_t100.
WRITE:/ it_t100.
ENDLOOP.
NEW-PAGE PRINT OFF.
CALL FUNCTION 'ABAP4_COMMIT_WORK'.
"Variables
DATA:
l_no_of_bytes TYPE i,
l_pdf_spoolid LIKE tsp01-rqident,
l_jobname LIKE tbtcjob-jobname,
l_jobcount LIKE tbtcjob-jobcount.
DATA:
spoolno TYPE tsp01-rqident.
spoolno = sy-spono.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = spoolno
no_dialog = ' '
IMPORTING
pdf_bytecount = l_no_of_bytes
pdf_spoolid = l_pdf_spoolid
btc_jobname = l_jobname
btc_jobcount = l_jobcount
TABLES
pdf = it_pdf.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\itab_to_pdf.pdf'
filetype = 'BIN'
TABLES
data_tab = it_pdf.
‎2009 Jun 29 11:16 AM
Hello Venkat,
I have zero pages in the pdf file.Also the PDF-BYTECOUNT has very little bytes.what could have been the mistake and how to rectify it.
Regards
--Pradeep
‎2009 Jun 29 1:40 PM
Hi Pradeep,
Check whether internal table has the data or not before it is sent to Spool..
Thanks
Venkat.O
‎2009 Jun 29 7:54 AM
Hi!
Instead of checking the result in debugging, please check the actual output. If that is fine, I don't think that you need to bother about chinese characters!
Cheers.
‎2009 Jun 29 7:57 AM
‎2009 Jun 29 8:12 AM
Hi Pradeep,
Please check the function module again and also its parameters.
U just need to give the spool no...and u'll get the pdf table...even if u dont give the other parameters, its ok...doesnt affect.
DATA: T_PDF LIKE TLINE OCCURS 0 WITH HEADER LINE.
DATA: V_RQIDENT TYPE TSP01-RQIDENT.
DATA: V_RQ2NAME TYPE STRING.
Retrieving Spool ID From TSP01 Table
CONCATENATE V_RQ2NAME SY-UNAME INTO V_RQ2NAME.
SELECT * FROM TSP01
WHERE RQ2NAME EQ V_RQ2NAME ORDER BY RQCRETIME DESCENDING.
V_RQIDENT = TSP01-RQIDENT.
EXIT.
ENDSELECT.
IF SY-SUBRC NE 0.
CLEAR V_RQIDENT.
ENDIF.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = V_SpoolNo
TABLES
PDF = T_PDF
EXCEPTIONS
ERR_NO_OTF_SPOOLJOB = 1
ERR_NO_SPOOLJOB = 2
ERR_NO_PERMISSION = 3
ERR_CONV_NOT_POSSIBLE = 4
ERR_BAD_DSTDEVICE = 5
USER_CANCELLED = 6
ERR_SPOOLERROR = 7
ERR_TEMSEERROR = 8
ERR_BTCJOB_OPEN_FAILED = 9
ERR_BTCJOB_SUBMIT_FAILED = 10
ERR_BTCJOB_CLOSE_FAILED = 11
OTHERS = 12.
Hope that helps u If any problem still persists, then let us know
Regards,
Radhika