2010 Aug 06 10:17 AM
Hi Friends,
I've an requirment to print a PDF data through ABAP program and PDF data is in Binary format.
Could you please suggest me any function module realted to this!
I need to re-build the program in CRM box, Currently their is a program to get data from CRM box as per the GUI ID it will fetch all the attachments and we are fittering for PDF.
At the End of program we have final internal table with Binary formate and we are sending PDF through email. But, client is asking us for addtion future to Print PDF through ABAP Program as per the PDF.
Kinldy suggest me how to go about this.!!
Thanks in Advance!
Regards,
Mallik
2010 Aug 06 11:37 AM
Hi
You can use the logic as follows :
Using the abap coding, fill the internal table and print it.. basically create the spool request..
not get this spool request and convert it to the PDF format ...
below code helps u to do it..
Use the below code to get the print parameters..
"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 .
continued...
2010 Aug 06 12:22 PM
continued ...
this will get you the spool request that is been generated.
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.
" Writing to Spool
LOOP AT it_t100.
WRITE:/ it_t100.
ENDLOOP.
2010 Aug 06 12:23 PM
NEW-PAGE PRINT OFF.
CALL FUNCTION 'ABAP4_COMMIT_WORK'.
get the spool number..
spoolno = sy-spono.
"Convert spool to PDF
continued ...
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.
now you have the data in ur internal table.. download the data using below FM.
"Download PDF file C Drive
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\itab_to_pdf.pdf'
filetype = 'BIN'
TABLES
data_tab = it_pdf.