Application Development and Automation 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: 
Read only

DOWN LOAD

Former Member
0 Likes
494

I HAVE DOWN LOAD MY PROGRAM OUTPUT PDF FORMAT ?

EXAMPLE PRORAM NEED?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
467
3 REPLIES 3
Read only

Former Member
0 Likes
468
Read only

Former Member
0 Likes
467

HI

Check this link

http://abap4.tripod.com/Save_Report_Output_to_a_PDF_File.html

As a workaround, a report (RSTXPDFT4) is made available for the missing "direct PDF printing", which can read spool requests, convert to PDF and perform a frontend download.

Read OSS Note 317851 - Printing PDF files in 4.6C/4.6B/4.5B

Note the restrictions specified in Note 323736 with the print output with PDF.

Caution when modifying device type ZPDF1, see Note 437696.

Version < 4.6D

If you are in version less than 4.6D, you can configure an output type to convert the spool automatically into a PDF format into your local harddisk but not do a "direct PDF printing".

When you print to this PDF output type, it will prompt you to enter the file name of your PDF file to be stored into your local harddisk.

First you have to add a printer using

Windows -> Start -> Settings -> Printers -> Generic / Text Only -> Port : Print to File

Next create a new device type e.g. ZPDF -> Select device type ZPDF1

Options for HostSpoolAccMethod -> Host spool access method : F : Printing on Frontend Computer

Host Printer : __DEFAULT or Generic / Text Only

Save your entries.

When you print to the device type ZPDF, choose Generic / Text Only for the Frontend Computer if it is not the default type.

A user prompt Print to File will appear to let you specify the Output File Name.



PARAMETER: p_email1 LIKE somlreci1-receiver
DEFAULT 'abap@sapdev.co.uk',
p_sender LIKE somlreci1-receiver
DEFAULT 'abap@sapdev.co.uk',
p_delspl AS CHECKBOX.

*DATA DECLARATION
DATA: gd_recsize TYPE i.

* Spool IDs
TYPES: BEGIN OF t_tbtcp.
INCLUDE STRUCTURE tbtcp.
TYPES: END OF t_tbtcp.
DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
wa_tbtcp TYPE t_tbtcp.

* Job Runtime Parameters
DATA: gd_eventid LIKE tbtcm-eventid,
gd_eventparm LIKE tbtcm-eventparm,
gd_external_program_active LIKE tbtcm-xpgactive,
gd_jobcount LIKE tbtcm-jobcount,
gd_jobname LIKE tbtcm-jobname,
gd_stepcount LIKE tbtcm-stepcount,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.


DATA: w_recsize TYPE i.

DATA: gd_subject LIKE sodocchgi1-obj_descr,
it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_sender_type LIKE soextreci1-adr_typ,
gd_attachment_desc TYPE so_obj_nam,
gd_attachment_name TYPE so_obj_des.

* Spool to PDF conversions
DATA: gd_spool_nr LIKE tsp01-rqident,
gd_destination LIKE rlgrap-filename,
gd_bytecount LIKE tst01-dsize,
gd_buffer TYPE string.

* Binary store for PDF
DATA: BEGIN OF it_pdf_output OCCURS 0.
INCLUDE STRUCTURE tline.
DATA: END OF it_pdf_output.

CONSTANTS: c_dev LIKE sy-sysid VALUE 'DEV',
c_no(1) TYPE c VALUE ' ',
c_device(4) TYPE c VALUE 'LOCL'.

************************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.

* Write statement to represent report output. Spool request is created
* if write statement is executed in background. This could also be an
* ALV grid which would be converted to PDF without any extra effort
WRITE 'Hello World'.
new-page.
commit work.
new-page print off.

IF sy-batch EQ 'X'.
PERFORM get_job_details.
PERFORM obtain_spool_id.

************************************
*** Alternative way could be to submit another program and store spool
*** id into memory, will be stored in sy-spono.
*submit ZSPOOLTOPDF2
* to sap-spool
* spool parameters %_print
* archive parameters %_print
* without spool dynpro
* and return.
************************************

* Get spool id from program called above
* IMPORT w_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.

PERFORM convert_spool_to_pdf.

if p_delspl EQ 'X'.
PERFORM delete_spool.
endif.

IF sy-sysid = c_dev.
wait up to 5 seconds.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDIF.
ELSE.
SKIP.
WRITE:/ 'Program must be executed in background in-order for spool',
'request to be created.'.
ENDIF.


*---------------------------------------------------------------------*
* FORM obtain_spool_id *
*---------------------------------------------------------------------*
FORM obtain_spool_id.
CHECK NOT ( gd_jobname IS INITIAL ).
CHECK NOT ( gd_jobcount IS INITIAL ).

SELECT * FROM tbtcp
INTO TABLE it_tbtcp
WHERE jobname = gd_jobname
AND jobcount = gd_jobcount
AND stepcount = gd_stepcount
AND listident <> '0000000000'
ORDER BY jobname
jobcount
stepcount.

READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
IF sy-subrc = 0.
message s004(zdd) with gd_spool_nr.
gd_spool_nr = wa_tbtcp-listident.
MESSAGE s004(zdd) WITH gd_spool_nr.
ELSE.
MESSAGE s005(zdd).
ENDIF.
ENDFORM.


*---------------------------------------------------------------------*
* FORM get_job_details *
*---------------------------------------------------------------------*
FORM get_job_details.
* Get current job details
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
EXCEPTIONS
no_runtime_info = 1
OTHERS = 2.
ENDFORM.


*---------------------------------------------------------------------*
* FORM convert_spool_to_pdf *
*---------------------------------------------------------------------*
FORM convert_spool_to_pdf.

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 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.

CHECK sy-subrc = 0.

* Transfer the 132-long strings to 255-long strings
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.

TRANSLATE gd_buffer USING '~ '.

DO.
it_mess_att = gd_buffer.
APPEND it_mess_att.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDFORM.

*---------------------------------------------------------------------*
* FORM delete_spool *
*---------------------------------------------------------------------*
FORM delete_spool.
DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.

ld_spool_nr = gd_spool_nr.

CHECK p_delspl <> c_no.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
spoolid = ld_spool_nr.
ENDFORM.

Check this link. It has an example code for PDF Conversion.

http://www.erpgenie.com/abap/code/abap51.htm

Regards

Pavan

Message was edited by:

Pavan praveen

Read only

Former Member
0 Likes
467

hi

call the function module

call function 'CONVERT_ABAPSPOOLJOB_2_PDF'

reward points if useful.

thanks,

usha