cancel
Showing results for 
Search instead for 
Did you mean: 

List to Pdf

Former Member
0 Kudos

Hi,

I have a report using submit zzz TO SAP-SPOOL SPOOL PARAMETERS %_print

ARCHIVE PARAMETERS %_print

WITHOUT SPOOL DYNPRO

AND RETURN.

Need to convert into a pdf file. Could you give me some sample code.

Regards,

Harsha

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

If you can get the spool number submit it again to program RSTXPDFT4 , it will generate PDF.

Regards

Karthik D

Former Member
0 Kudos

Thanks,

But how to get the spool id? Please give some source.

Regards

Former Member
0 Kudos

Hi,

You can refer the sample code in the links below;

http://www.sapdev.co.uk/reporting/rep_spooltopdf.htm

http://www.sapdev.co.uk/reporting/rep_spooltopdf2.htm

Regards

Karthik D

Former Member
0 Kudos

Hi

Mabe you can use this.

I found it with a simple find on PDF in this forum.

Gr. Frank

_____________________________________________________________

Posted: Apr 22, 2009 6:07 PM in response to: jeevitha Reply

Hi,

You can use these function modules write after o call the smartform it self.

First:

"Convert SPOOL to PDF

CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = spool

no_dialog = 'X'

IMPORTING

pdf_bytecount = numbytes

pdf_spoolid = pdfspoolid

btc_jobname = jobname

btc_jobcount = jobcount

TABLES

pdf = it_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.

IF sy-subrc EQ 0.

Second:

"Saves PDF file in local PC

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = filename

filetype = 'BIN'

TABLES

data_tab = it_pdf

EXCEPTIONS

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3

invalid_type = 4

no_authority = 5

unknown_error = 6

header_not_allowed = 7

separator_not_allowed = 8

filesize_not_allowed = 9

header_too_long = 10

dp_error_create = 11

dp_error_send = 12

dp_error_write = 13

unknown_dp_error = 14

access_denied = 15

dp_out_of_memory = 16

disk_full = 17

dp_timeout = 18

file_not_found = 19

dataprovider_exception = 20

control_flush_error = 21

OTHERS = 22.

IF sy-subrc EQ 0.

"Erases spool Order

del_spool = spool.

CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'

EXPORTING

spoolid = del_spool.

_________________________________________________________

Hope it helped.

Former Member
0 Kudos

This source I have, but after submitting the source is not clear and doesnt talk much.

After submitting need to get spool id and pass the same to RSTXPDFT4 or use a function

to create pdf and store in the unix box.

Hope u got my point.

Regards,

Harsha

Former Member
0 Kudos

When I open the sm37 job is saying canceled , but I drop down to spool I can see the output. Below

is my source code. Please help.

SUBMIT zmar_planing_sheet

WITH s_bu IN s_bu

TO SAP-SPOOL SPOOL PARAMETERS %_print

ARCHIVE PARAMETERS %_print

WITHOUT SPOOL DYNPRO

AND RETURN.

IMPORT gd_spool_nr FROM MEMORY ID 'ZMAR_PLANING_SHEET_ON_EMAIL'.

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.

Former Member
0 Kudos

You could use TBTC_SPOOLID table to get the spool number for latest job and then pass the same number to the function module.

Former Member
0 Kudos

Which is function or param to query TBTC_SPOOLID and get the spool number?

Regards,

Harsha

Former Member
0 Kudos

Select Query by Jobname and other Key fields in table.

Former Member
0 Kudos

Could u send a sample source. Not able to get the spool number for the same report.

Regards,

Harsha

Former Member
0 Kudos

Hi,

This is the Report, I have taken from SDN longback... I have Implemented List to PDF by taking that is as the referance..Please check it... It will help you.....

REPORT zrich_0001.

DATA: lv_spool LIKE tsp01-rqident.

DATA: lt_pdf TYPE TABLE OF tline.

DATA: ls_pdf LIKE LINE OF lt_pdf.

DATA: lv_url TYPE char255.

DATA: lv_buffer TYPE string.

DATA: lv_content TYPE xstring.

DATA: lt_data TYPE STANDARD TABLE OF x255.

data: lo_dialog_container type ref to cl_gui_dialogbox_container.

data: lo_docking_container type ref to cl_gui_docking_container.

data: lo_html TYPE REF TO cl_gui_html_viewer.

FIELD-SYMBOLS <fs_x> TYPE x.

parameters: p_check.

at selection-screen output.

  • Run the report program, in this program you need to export the

  • spool id to memory.

SUBMIT zrich_0002 TO SAP-SPOOL

WITHOUT SPOOL DYNPRO

DESTINATION space

COVER TEXT ' Your Report Title'

NEW LIST IDENTIFICATION 'X'

IMMEDIATELY space

AND RETURN.

  • import spool number from memory

IMPORT lv_spool = lv_spool FROM MEMORY ID 'ZRICH_0002_SPONO'.

  • Convert the spool request to PDF format.

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = lv_spool

TABLES

pdf = lt_pdf

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.

  • convert pdf to xstring string

LOOP AT lt_pdf INTO ls_pdf.

ASSIGN ls_pdf TO <fs_x> CASTING.

CONCATENATE lv_content <fs_x> INTO lv_content IN BYTE MODE.

ENDLOOP.

create object lo_docking_container

EXPORTING

repid = sy-repid

dynnr = sy-dynnr

side = lo_docking_container->dock_at_right

extension = 1200.

CREATE OBJECT lo_html

EXPORTING

parent = lo_docking_container.

  • Convert xstring to binary table to pass to the LOAD_DATA method

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

EXPORTING

buffer = lv_content

TABLES

binary_tab = lt_data.

  • Load the HTML

lo_html->load_data(

exporting

type = `application`

subtype = `pdf`

IMPORTING

assigned_url = lv_url

CHANGING

data_table = lt_data

EXCEPTIONS

dp_invalid_parameter = 1

dp_error_general = 2

cntl_error = 3

OTHERS = 4 ).

  • Show it

lo_html->show_url( url = lv_url in_place = 'X' ).

Here is the source for the simple report program ZRICH_0002. The main point here is that after your write the report, just pass the spool number to memory.

REPORT ZRICH_0002

line-count 65

LINE-SIZE 80.

DATA: lv_spool LIKE tsp01-rqident.

data: lv_value type i.

START-OF-SELECTION .

  • Write the report.

DO 20 TIMES.

lv_value = sy-index * 10.

WRITE:/ sy-index, at 20 lv_value.

ENDDO.

  • Export this spool number to memory

lv_spool = sy-spono.

EXPORT lv_spool = lv_spool TO MEMORY ID 'ZRICH_0002_SPONO'.

Former Member
0 Kudos

HI Guru,

I am using the following codes

EXPORT lv_spool TO MEMORY ID 'ZS'.

SUBMIT zmar_planing_sheet

WITH s_bu IN s_bu

TO SAP-SPOOL WITHOUT SPOOL DYNPRO

DESTINATION 'LOCL' COVER TEXT ' ZZZZZZZZZZZZZ'

NEW LIST IDENTIFICATION 'X' IMMEDIATELY space AND RETURN.

IMPORT lv_spool = lv_spool FROM MEMORY ID 'ZS'.

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = lv_spool

TABLES

pdf = lt_pdf.

When I run this report in the background and sm37, the job status says cancelled. Not able to download the file in the unix box. I can

not even debug this code as its running the background. Whats going wrong?

Regards,

Harsha

Former Member
0 Kudos

This report will not support in background...Becaz 'CONVERT_ABAPSPOOLJOB_2_PDF' will not support in background.......

If u want to save the document, you need to run that program in foreground and save it manually..

Regards

Former Member
0 Kudos

Are you sure about it? Then how to run in the background?

Regards,

Harsha

Former Member
0 Kudos

Yes... I am sure.... We are also tried the same in background... Thats is the reason I am sharing with you.

Regards

Former Member
0 Kudos

Is there any function which converts to list to pdf in the background?

Regards,

Harsha