07-19-2007 10:42 AM
Hello
Can i post the PDF directly created using SX_OBJECT_CONVERT_OTE_PDF into my mail directly in SO_DOCUMENT_SEND_API1 is so can u tell me th e proceedure
07-19-2007 11:02 AM
Hi
Check this sample report to send smartform as a pdf file
DATA: x_ctrl_p TYPE ssfctrlop,
x_output_data TYPE ssfcrescl.
DATA: it_docs LIKE docs OCCURS 0 WITH HEADER LINE,
it_lines LIKE tline OCCURS 0 WITH HEADER LINE,
it_packing LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE.
*-----Initialisation
x_ctrl_p-no_dialog = 'X'.
x_ctrl_p-getotf = 'X'.
x_ctrl_p-langu = sy-langu.
*---------------------------------------------------------------------*
* Internal Tables Declaration *
*---------------------------------------------------------------------*
DATA: it_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_pcklist LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
it_mess LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
it_table LIKE solix OCCURS 0 WITH HEADER LINE.
DATA: it_soli LIKE soli OCCURS 0 WITH HEADER LINE.
*-----Work area declaration
DATA: wa_doc_data TYPE sodocchgi1.
*---------------------------------------------------------------------*
* Variable Declaration *
*---------------------------------------------------------------------*
DATA: v_lines_txt TYPE i,
v_lines_bin TYPE i,
v_lines TYPE i,
v_fname TYPE rs38l_fnam,
v_size TYPE i,
v_filename TYPE rlgrap-filename.
*---------------------------------------------------------------------*
* Start of selection event *
*---------------------------------------------------------------------*
START-OF-SELECTION.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'Z_SMTF_TEST_AKS01'
IMPORTING
fm_name = v_fname.
CALL FUNCTION v_fname
EXPORTING
control_parameters = x_ctrl_p
IMPORTING
job_output_info = x_output_data.
*-----Calling fumction module to convert output to pdf.
* CALL FUNCTION 'CONVERT_OTF_2_PDF'
* IMPORTING
* bin_filesize = v_size
* TABLES
* otf = x_output_data-otfdata
* doctab_archive = it_docs
* lines = it_lines.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 134
IMPORTING
bin_filesize = v_size
TABLES
otf = x_output_data-otfdata
lines = it_lines
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
EXPORTING
line_width_dst = 255
TABLES
content_in = it_lines
content_out = it_soli
EXCEPTIONS
err_line_width_src_too_long = 1
err_line_width_dst_too_long = 2
err_conv_failed = 3
OTHERS = 4.
CALL FUNCTION 'ZFUNC_CONVERT_DATA_ODC01'
EXPORTING
iv_byte_mode = 'X'
TABLES
it_data = it_lines
et_data = it_table.
*-----To caluculate total number of lines of internal table
DESCRIBE TABLE it_table LINES v_lines.
*-----Function module to download the output file.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
bin_filesize = v_size
filename = ' '
filetype = 'BIN'
IMPORTING
act_filename = v_filename
TABLES
data_tab = it_lines.
*-----Create Message Body and Title and Description
it_mess =
'i have successfully converted smartform from otf format to pdf' .
" and i have attached that in mail'.
APPEND it_mess.
wa_doc_data-obj_name = 'smartform'.
wa_doc_data-expiry_dat = sy-datum + 10.
wa_doc_data-obj_descr = 'smartform'.
wa_doc_data-sensitivty = 'F'.
wa_doc_data-doc_size = v_lines * 255.
APPEND it_pcklist.
*-----PDF Attachment
it_pcklist-transf_bin = 'X'.
it_pcklist-head_start = 1.
it_pcklist-head_num = 0.
it_pcklist-body_start = 1.
it_pcklist-doc_size = v_lines_bin * 255 .
it_pcklist-body_num = v_lines.
it_pcklist-doc_type = 'PDF'.
it_pcklist-obj_name = 'smartform'.
it_pcklist-obj_descr = 'smart_desc'.
it_pcklist-obj_langu = 'E'.
it_pcklist-doc_size = v_lines * 255.
APPEND it_pcklist.
*-----Giving the receiver email-id
CLEAR it_receivers.
it_receivers-receiver = 'wereqpk@yahoo.com'
it_receivers-rec_type = 'U'.
APPEND it_receivers.
CLEAR it_receivers.
it_receivers-receiver = 'peqek@yahoo.com'.
it_receivers-rec_type = 'U'.
APPEND it_receivers.
CLEAR it_receivers.
it_receivers-receiver = 'pk@yahoo.com'.
it_receivers-rec_type = 'U'.
APPEND it_receivers.
*-----Calling the function module to sending email
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = wa_doc_data
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = it_pcklist
contents_txt = it_mess
contents_hex = it_table
receivers = it_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 = 0.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
WITH rfcgroup = 'iwdf7ytc_YD3_94'
AND RETURN.
REFRESH: it_receivers,
it_mess,
it_pcklist.
ENDIF.
Reward all helpfull answers
Regards
Pavan