Skip to Content
0
Mar 03, 2015 at 10:17 AM

document_not_sent exception with fm SO_DOCUMENT_SEND_API1

62 Views

Hello i am trying to send a pdf as an attchment and using SO_DOCUMENT_SEND_API1 for this.

but fm gives sy-subrc = 2 which is document_not_sent exception.

i searched everywhere but couldnt find th mistake.

any help would be appriciated.

here is my source code.

CALL FUNCTION 'CONVERT_OTF'
     EXPORTING
        FORMAT                      = 'PDF'
        MAX_LINEWIDTH               = 132
 *       ARCHIVE_INDEX               = ' '
 *       COPYNUMBER                  = 0
 *       ASCII_BIDI_VIS2LOG          = ' '
 *       PDF_DELETE_OTFTAB           = ' '
 *    IMPORTING
 *       BIN_FILESIZE                = lv_len
 *       BIN_FILE                    = g_binfil
     TABLES
        OTF                         = lt_otfdata
        LINES                       = lt_pdfdata
     EXCEPTIONS
        ERR_MAX_LINEWIDTH           = 1
        ERR_FORMAT                  = 2
        ERR_CONV_NOT_POSSIBLE       = 3
        ERR_BAD_OTF                 = 4
     OTHERS                         = 5.


   IF sy-subrc <> 0.
     MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
   ENDIF.

FREE: lt_receivers, lt_packing_list, lt_contents_bin, lt_contents_txt. * Assigning the Description of the object sent in the mail CLEAR ls_document_data. ls_document_data-obj_name = 'TİTLE'. ls_document_data-obj_descr = 'TITLE'. ls_document_data-expiry_dat = sy-datum + 10. ls_document_data-sensitivty = 'F'. * LOOP AT gt_mail. CLEAR : lt_receivers. lt_receivers-receiver = 'cem.unal@gmail.com'. lt_receivers-rec_type = 'U'. lt_receivers-com_type = 'INT'. APPEND lt_receivers. lt_receivers-COPY = mail_bm. lt_receivers-rec_type = 'U'. lt_receivers-com_type = 'INT'. APPEND lt_receivers. * ENDLOOP. CLEAR: lt_contents_txt. lt_contents_txt-line = 'title1,'. APPEND lt_contents_txt.CLEAR lt_contents_txt. APPEND lt_contents_txt. CONCATENATE 'titl2' ' title3.' INTO lt_contents_txt-line SEPARATED BY space. APPEND lt_contents_txt.CLEAR lt_contents_txt. APPEND lt_contents_txt. lt_contents_txt-line = 'title4'. APPEND lt_contents_txt.CLEAR lt_contents_txt. CLEAR lt_packing_list. lt_packing_list-transf_bin = space. lt_packing_list-head_start = 1. lt_packing_list-head_num = 0. lt_packing_list-body_start = 1. lt_packing_list-body_num = LINES( lt_contents_txt ). lt_packing_list-doc_type = 'RAW'. APPEND lt_packing_list. CLEAR lt_packing_list. ls_document_data-doc_size = LINES( lt_contents_txt ) * 255. CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE' EXPORTING line_width_src = 134 line_width_dst = 255 TABLES content_in = lt_pdfdata content_out = lt_contents_bin EXCEPTIONS err_line_width_src_too_long = 1 err_line_width_dst_too_long = 2 err_conv_failed = 3 OTHERS = 4. *Filling the details in SAPoffice: Description of Imported Object *Components table DESCRIBE TABLE lt_contents_bin LINES lv_tab_lines. CLEAR lt_contents_bin. READ TABLE lt_contents_bin INDEX lv_tab_lines. IF sy-subrc = 0. CLEAR: lt_packing_list. lt_packing_list-transf_bin = 'X'. lt_packing_list-head_start = 1. lt_packing_list-head_num = 1. lt_packing_list-body_start = 1. lt_packing_list-body_num = lv_tab_lines. lt_packing_list-obj_langu = sy-langu. lt_packing_list-doc_type = 'PDF'. lt_packing_list-obj_name = 'ATTACHMENT'. lt_packing_list-obj_descr = 'RISK TALEP FORMU.PDF'. lt_packing_list-doc_size = lv_tab_lines * 255. APPEND lt_packing_list.CLEAR lt_packing_list. ENDIF. lv_put_in_outbox = lv_commit_work = 'X'. CALL FUNCTION 'SO_DOCUMENT_SEND_API1' EXPORTING document_data = ls_document_data put_in_outbox = lv_put_in_outbox * sender_address = lv_sender_address * sender_address_type = lv_sender_address_type commit_work = lv_commit_work TABLES packing_list = lt_packing_list object_header = lt_object_header contents_bin = lt_contents_bin contents_txt = lt_contents_txt * contents_hex = lt_contents_hex object_para = lt_object_para object_parb = lt_object_parb receivers = lt_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.
* gt_data-gonderx = 'X'. * modify gt_data. * MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno * WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF.