Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Printing PDF data through ABAP program.

Former Member
0 Kudos
970

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

3 REPLIES 3

0 Kudos
167

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...

0 Kudos
167

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.

0 Kudos
167

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.