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

Problem in converting spool to PDF

Former Member
0 Likes
765

Hi Experts,

I am trying to pass an int.table to spool, and from there it should be converted to PDF using FM "CONVERT_ABAPSPOOLJOB_2_PDF" and after converting it to binary it should be send as a mail to user.

Please check the code below.

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = gv_spoolid

  • no_dialog = 'X'

  • dst_device = 'LOCL'

  • PDF_DESTINATION =

IMPORTING

pdf_bytecount = gv_numbytes

pdf_spoolid = gv_pdfspoolid

  • LIST_PAGECOUNT =

btc_jobname = gv_jobname

btc_jobcount = gv_jobcount

TABLES

pdf = gt_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

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

*convert the pdf to binary

CALL FUNCTION 'QCE1_CONVERT'

TABLES

t_source_tab = gt_pdf_output

t_target_tab = gt_objbin

EXCEPTIONS

convert_not_possible = 1

OTHERS = 2.

*describe the line no in binary format

DESCRIBE TABLE gt_objbin LINES gv_tab_lines.

gwa_objhead = 'AR Sales-Insurance.pdf'.

APPEND gwa_objhead TO gt_objhead.

*clear workarea

CLEAR gwa_objpack-transf_bin.

gwa_objpack-head_start = 1.

gwa_objpack-head_num = 0.

gwa_objpack-body_start = 1.

gwa_objpack-body_num = gv_tab_lines.

gwa_objpack-doc_type = gc_raw.

APPEND gwa_objpack TO gt_objpack.

*clear workarea

CLEAR gwa_objpack.

gwa_objpack-transf_bin = gc_transfer.

gwa_objpack-head_start = 1.

gwa_objpack-head_num = 1.

gwa_objpack-body_start = 1.

gwa_objpack-body_num = gv_tab_lines.

gwa_objpack-doc_type = gc_pdf.

gwa_objpack-obj_name = 'AR Sales-Insurance.pdf'.

gv_descr = 'AR Sales-Insurance for &'.

  • REPLACE '&' IN lv_descr WITH pi_lv_kunnr .

gwa_objpack-obj_descr = gv_descr.

gwa_objpack-doc_size = gv_tab_lines * 255.

APPEND gwa_objpack TO gt_objpack.

*clear workarea

CLEAR gwa_objpack.

*moving the reciever details to table

gwa_reclist-receiver = gwa_fields-value. " Email Id of the reciever gwa_fields-value

gwa_reclist-rec_type = gc_rectype.

APPEND gwa_reclist TO gt_reclist.

*clear workarea

CLEAR gwa_reclist.

*moving the details in doc change header

gwa_doc_chng-obj_name = 'AR Sales-Insurance.pdf'(004).

gwa_doc_chng-obj_descr = gv_descr.

gwa_doc_chng-doc_size = gv_tab_lines * 255.

IF gwa_fields-value IS NOT INITIAL.

*send PDF format as email

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = gwa_doc_chng

put_in_outbox = gc_transfer

commit_work = gc_transfer

  • IMPORTING

  • SENT_TO_ALL =

  • NEW_OBJECT_ID =

TABLES

packing_list = gt_objpack

object_header = gt_objhead

contents_bin = gt_objbin

  • CONTENTS_TXT =

  • CONTENTS_HEX =

  • OBJECT_PARA =

  • OBJECT_PARB =

receivers = gt_reclist

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

document_type_not_exist = 3

operation_no_authorization = 4

parameter_error = 5

x_error = 6

enqueue_error = 7

OTHERS = 8

.

IF sy-subrc <> 0.

endif.

when I open the file it shoing error " File cannot be opened"

Can anyone help in this regards,

Thanks in adv.

Regards,

Ponraj.s.

Hi Experts,

I am trying to pass an int.table to spool, and from there it should be converted to PDF using FM "CONVERT_ABAPSPOOLJOB_2_PDF" and after converting it to binary it should be send as a mail to user.

Please check the code below.

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = gv_spoolid

  • no_dialog = 'X'

  • dst_device = 'LOCL'

  • PDF_DESTINATION =

IMPORTING

pdf_bytecount = gv_numbytes

pdf_spoolid = gv_pdfspoolid

  • LIST_PAGECOUNT =

btc_jobname = gv_jobname

btc_jobcount = gv_jobcount

TABLES

pdf = gt_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

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

*convert the pdf to binary

CALL FUNCTION 'QCE1_CONVERT'

TABLES

t_source_tab = gt_pdf_output

t_target_tab = gt_objbin

EXCEPTIONS

convert_not_possible = 1

OTHERS = 2.

*describe the line no in binary format

DESCRIBE TABLE gt_objbin LINES gv_tab_lines.

gwa_objhead = 'AR Sales-Insurance.pdf'.

APPEND gwa_objhead TO gt_objhead.

*clear workarea

CLEAR gwa_objpack-transf_bin.

gwa_objpack-head_start = 1.

gwa_objpack-head_num = 0.

gwa_objpack-body_start = 1.

gwa_objpack-body_num = gv_tab_lines.

gwa_objpack-doc_type = gc_raw.

APPEND gwa_objpack TO gt_objpack.

*clear workarea

CLEAR gwa_objpack.

gwa_objpack-transf_bin = gc_transfer.

gwa_objpack-head_start = 1.

gwa_objpack-head_num = 1.

gwa_objpack-body_start = 1.

gwa_objpack-body_num = gv_tab_lines.

gwa_objpack-doc_type = gc_pdf.

gwa_objpack-obj_name = 'AR Sales-Insurance.pdf'.

gv_descr = 'AR Sales-Insurance for &'.

  • REPLACE '&' IN lv_descr WITH pi_lv_kunnr .

gwa_objpack-obj_descr = gv_descr.

gwa_objpack-doc_size = gv_tab_lines * 255.

APPEND gwa_objpack TO gt_objpack.

*clear workarea

CLEAR gwa_objpack.

*moving the reciever details to table

gwa_reclist-receiver = gwa_fields-value. " Email Id of the reciever gwa_fields-value

gwa_reclist-rec_type = gc_rectype.

APPEND gwa_reclist TO gt_reclist.

*clear workarea

CLEAR gwa_reclist.

*moving the details in doc change header

gwa_doc_chng-obj_name = 'AR Sales-Insurance.pdf'(004).

gwa_doc_chng-obj_descr = gv_descr.

gwa_doc_chng-doc_size = gv_tab_lines * 255.

IF gwa_fields-value IS NOT INITIAL.

*send PDF format as email

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = gwa_doc_chng

put_in_outbox = gc_transfer

commit_work = gc_transfer

  • IMPORTING

  • SENT_TO_ALL =

  • NEW_OBJECT_ID =

TABLES

packing_list = gt_objpack

object_header = gt_objhead

contents_bin = gt_objbin

  • CONTENTS_TXT =

  • CONTENTS_HEX =

  • OBJECT_PARA =

  • OBJECT_PARB =

receivers = gt_reclist

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

document_type_not_exist = 3

operation_no_authorization = 4

parameter_error = 5

x_error = 6

enqueue_error = 7

OTHERS = 8

.

IF sy-subrc <> 0.

endif.

when I open the file it shoing error " File cannot be opened"

Can anyone help in this regards,

Thanks in adv.

Regards,

Ponraj.s.

4 REPLIES 4
Read only

Former Member
0 Likes
695
Read only

Former Member
0 Likes
695

Hi ,

Can you cross verify it in SP02, for your spool request can you open and see the print preview...

Regards,

Kittu

Edited by: Kittu on Nov 9, 2009 1:21 PM

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
695

Hi,

Go to SE38, execute report RSTXPDFT4. Specify the spool request and location for PDF download.

Hope this helps you.

Regards,

Tarun

Read only

Former Member
0 Likes
695

hi,

When I checked in the spool I am able to see the output, but after converting it to PDF it shows me the above error.

i directly checked in the program RSTXPDFT4 for the spool and downloaded, even then it showing the same error.

any inputs?

Regards,

Ponraj.s.