Hi, im tring to use the SO_DOCUMENT_SEND_API1 FM to send a smartform output by mail. Im able to convert the smartform output to pdf and save it to teh hard drive and works great but when i try to send the pdf doc by mail it comes corrupted... can anyone help me on this... heres a piece of my code
call function 'CONVERT_OTF' EXPORTING format = 'PDF' max_linewidth = 132 IMPORTING bin_filesize = v_len_in TABLES otf = i_otf lines = i_tline EXCEPTIONS err_max_linewidth = 1 err_format = 2 err_conv_not_possible = 3 others = 4. * Fehlerhandling if sy-subrc <> 0. endif. ******* I THINK THE ERROR MAYBE ON THIS PIECE OF CODE ************ loop at i_tline. translate i_tline using ' ~'. concatenate wa_buffer i_tline into wa_buffer. endloop. translate wa_buffer using '~ '. do. i_record = wa_buffer. append i_record. shift wa_buffer left by 255 places. if wa_buffer is initial. exit. endif. enddo. ***************** it message **************************************** refresh it_message. it_message = 'Em anexo vai a tabela interna de utilizadores '. APPEND it_message. it_message = 'Clique no link '. APPEND it_message. ******************************************************************** **************** Assunto do Email ***************** * Fill the document data and get size of attachment CLEAR w_doc_data. DESCRIBE TABLE It_message LINES x. READ TABLE It_message INDEX x. w_doc_data-DOC_SIZE = ( x - 1 ) * 255 + STRLEN( It_message ). w_doc_data-obj_langu = sy-langu. w_doc_data-obj_name = 'SAPRPT'. w_doc_data-obj_descr = 'ASSUNTO EMAIL'. w_doc_data-sensitivty = 'F'. ************************ fim assunto email ********************* data linha type i. data lv_cntl type i. CLEAR t_attachment. REFRESH t_attachment. ************************** Mensagem ****************** * Describe the body of the message CLEAR t_packing_list. REFRESH t_packing_list. clear t_packing_list-transf_bin. t_packing_list-head_start = 1. t_packing_list-head_num = 0. t_packing_list-body_start = 1. describe table it_message lines t_packing_list-body_num. t_packing_list-doc_type = 'RAW'. APPEND t_packing_list. ***************************-Filling the attch table with data ************************* CLEAR : L_TABLE_LINES. * clear wa_objhead. * loop at i_record. t_attachment[] = i_tline[]. * append t_attachment. * endloop. **************************************************************************************** * Create attachment notification t_packing_list-transf_bin = 'X'. t_packing_list-head_start = 1. t_packing_list-head_num = 1. t_packing_list-body_start = 1. DESCRIBE TABLE t_attachment LINES L_TABLE_LINES. t_packing_list-body_num = L_TABLE_LINES. t_packing_list-obj_descr = 'output'. t_packing_list-doc_type = 'BIN'. t_packing_list-doc_size = L_TABLE_LINES * 255. t_packing_list-obj_langu = sy-langu. t_packing_list-obj_name = 'Teste'. APPEND t_packing_list. ********************************************************************************************** *************** Endereços de email dos destinatários ************************* CLEAR receivers. REFRESH receivers. receivers-receiver = 'exjmartins@refer.pt'. receivers-rec_type = 'U'. receivers-com_type = 'INT'. receivers-notif_del = 'X'. receivers-EXPRESS = 'X'. * receivers-notif_ndel = 'X'. APPEND receivers. ************************Fim de email dos Dest. ****************************** CALL FUNCTION 'SO_DOCUMENT_SEND_API1' EXPORTING DOCUMENT_DATA = w_doc_data PUT_IN_OUTBOX = 'X' * SENDER_ADDRESS = ld_sender_address * SENDER_ADDRESS_TYPE = ld_sender_address_type COMMIT_WORK = 'X' IMPORTING SENT_TO_ALL = w_sent_all * NEW_OBJECT_ID = * SENDER_ID = TABLES PACKING_LIST = t_packing_list * OBJECT_HEADER = wa_objhead CONTENTS_BIN = t_attachment CONTENTS_TXT = it_message * CONTENTS_HEX = contents_hex * OBJECT_PARA = * OBJECT_PARB = RECEIVERS = 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. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. wait up to 2 seconds. if sy-subrc eq 0. submit rsconn01 "with mode = 'INT' *with output = 'X' and return. endif.