Skip to Content
author's profile photo Former Member
Former Member

Sending Spool of the Job(report run as background) as an E-Mail

My report runs as a background scheduled job and generates Spool.

I need to send this spool as an attachment in the E-Mail.

Currently I am using the FM 'CONVERT_ABAPSPOOLJOB_2_PDF' to send this as a PDF attachment.

But, the issue is the width of the spool is much more than the PDF page size. i.e., the spool could not be completely put into a page (almost the right half of the spool display is going out of the page borders as the width of spool is almost double the size of page in PDF)...

1. is there posibilty to choose PDF with LANDSCAPE or PORTRAIT options ?

2. Or can i decrease the size of spool to accomodate in a page of PDF ?

2. is there a better format other than 'PDF' where i can send the wide spool as an attachment ? Do we have any function module to accomodate spool in HTML format ?

I am highly thankful if someone could plz advice me on any solution for this .......

Thanks a lot,

raj

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Oct 20, 2008 at 06:03 PM

    Plz see the code i am currently using .... and please suggest accordingly

    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.

    DATA: ld_mtitle LIKE sodocchgi1-obj_descr,

    ld_format TYPE so_obj_tp ,

    ld_attdescription TYPE so_obj_nam ,

    ld_attfilename TYPE so_obj_des .

    Initialize local variables

    ld_mtitle = c_email_title.

    ld_format = 'PDF'.

    ld_attdescription = c_email_fdesc.

    ld_attfilename = c_email_fname.

    Fill the document data and get size of attachment

    CLEAR w_doc_data.

    DESCRIBE TABLE it_mess_att LINES v_count.

    v_count = v_count - 1.

    READ TABLE it_mess_att INDEX v_count.

    w_doc_data-doc_size =

    ( v_count ) * 255 + STRLEN( w_attach-line ).

    w_doc_data-obj_langu = sy-langu.

    w_doc_data-obj_name = 'SAPRPT'.

    w_doc_data-obj_descr = ld_mtitle.

    w_doc_data-sensitivty = 'F'.

    CLEAR t_attachment.

    REFRESH t_attachment.

    t_attachment] = it_mess_att[.

    Describe the body of the message

    CLEAR t_packing_list.

    REFRESH t_packing_list.

    w_packing_list-transf_bin = space.

    w_packing_list-head_start = 1.

    w_packing_list-head_num = 0.

    w_packing_list-body_start = 1.

    DESCRIBE TABLE t_message LINES w_packing_list-body_num.

    w_packing_list-doc_type = 'RAW'.

    APPEND w_packing_list TO t_packing_list.

    Create attachment notification

    w_packing_list-transf_bin = 'X'.

    w_packing_list-head_start = 1.

    w_packing_list-head_num = 1.

    w_packing_list-body_start = 1.

    DESCRIBE TABLE t_attachment LINES w_packing_list-body_num.

    w_packing_list-doc_type = ld_format.

    w_packing_list-obj_descr = ld_attdescription.

    w_packing_list-obj_name = ld_attfilename.

    w_packing_list-doc_size = w_packing_list-body_num * 255.

    APPEND w_packing_list TO t_packing_list.

    Add the recipients email address

    CLEAR t_receivers.

    REFRESH t_receivers.

    w_receivers-rec_type = 'U'.

    w_receivers-com_type = 'INT'.

    w_receivers-notif_del = 'X'.

    w_receivers-notif_ndel = 'X'.

    w_receivers-receiver = 'email address'.

    APPEND w_receivers TO t_receivers.

    *FM to send E-Mail

    CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

    EXPORTING

    document_data = w_doc_data

    put_in_outbox = 'X'

    commit_work = 'X'

    IMPORTING

    sent_to_all = v_sent_all

    TABLES

    packing_list = t_packing_list

    contents_bin = t_attachment

    contents_txt = t_message

    receivers = t_receivers

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

    *Instructs mail send program for SAPCONNECT to send email(rsconn01)

    PERFORM initiate_mail_execute_program.

    ELSE.

    MESSAGE i069 WITH sy-subrc. "Mail delivery failed with an exception

    ENDIF.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.