12-02-2008 2:05 PM
Hello gurus,
Has anyone tried emailing a sapscript spool output as a pdf file attachment using the CL_BCS global class?
Thanks
Ed Baker
12-02-2008 2:12 PM
12-02-2008 3:44 PM
Hi Ed,
Yes... but not exactly the same as yours....
I wrote the code in the print program...
I got the OTF return table(otfdata tables parameter) fron the 'CLOSE_FORM' fm into an int table lt_otf.
DATA lt_otf TYPE TABLE OF itcoo.
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT = itcpp
TABLES
otfdata = lt_otf
EXCEPTIONS
OTHERS = 1.
Then converted that OTF data to XSTRING data ( variabl pdf_xstring ) using 'CONVERT_OTF' fm
DATA : pdf_xstring TYPE xstring,
lv_bin_filesize TYPE i,
lt_pdf_table TYPE tlinetab.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = lv_bin_filesize
bin_file = pdf_xstring
TABLES
otf = lt_otf
lines = lt_pdf_table
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
Now for mailing...
DATA: lt_attach_bin TYPE TABLE OF solix,
lt_text TYPE bcsy_text,
send_request TYPE REF TO cl_bcs,
document TYPE REF TO cl_document_bcs,
sender TYPE REF TO cl_cam_address_bcs,
recipient TYPE REF TO cl_cam_address_bcs,
bcs_exception TYPE REF TO cx_bcs,
sent_to_all TYPE os_boolean.
TRY.
send_request = cl_bcs=>create_persistent( ).
lt_attach_bin = cl_document_bcs=>xstring_to_solix( ip_xstring = pdf_xstring ).
APPEND 'Test message' TO lt_text.
document = cl_document_bcs=>create_document( i_type = 'RAW'
i_text = lt_text
i_subject = 'Script as pdf attachment' ).
document->add_attachment( i_attachment_type = 'PDF'
i_attachment_subject = 'script.pdf'
i_att_content_hex = lt_attach_bin ).
send_request->set_document( document ).
sender = cl_cam_address_bcs=>create_internet_address( 'sender at abc.com' ).
recipient = cl_cam_address_bcs=>create_internet_address( 'recepient at abc.com' ).
send_request->set_sender( sender ).
send_request->add_recipient( i_recipient = recipient
i_express = 'X' ).
sent_to_all = send_request->send( i_with_error_screen = 'X' ).
CATCH cx_bcs INTO bcs_exception.
EXIT.
ENDTRY.
Note : Before all the above steps we must also set the itcpo-tdgetotf that we pass to OPTIONS parameter .
MOVE 'X' TO itcpo-tdgetotf.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
form = tnapr-fonam
language = nast-spras
OPTIONS = itcpo
archive_index = toa_dara
archive_params = arc_params
device = xdevice
dialog = ' '
EXCEPTIONS
OTHERS = 1.
If u want it to be done from SPOOL probably u must use some convertspool* Func modules to the get OTF/PDF data ...
Cheers,
Jose.
12-03-2008 1:24 PM
Thanks everyone.
We've found a way to do what I wanted at my company.
I'm going to post a message soon, showing the technique we used.
Thanks again to everyone who responded.
10-20-2009 10:09 PM
Ed,
You were going to say how you did this. You have the time to chuck some detail online?
Ross
10-20-2009 10:09 PM
Ed,
You were going to say how you did this. You have the time to chuck some detail online?
Ross