Quantcast
Channel: SCN : All Content - ABAP Development
Viewing all articles
Browse latest Browse all 8332

Pdf as in the body of e-mail.

$
0
0

Hello experts,

 

we are sending a pdf as an attachment of an e-mail.what im trying to do is to send pdf in the body of e-mail.

i have search and couldnt find any help in the documents or discussions.

here is my code:

FORM SEND_MAIL
 DATA: lv_formname TYPE  tdsfname,         lv_fm_name  TYPE  rs38l_fnam,         ls_control_parameters TYPE ssfctrlop,         ls_output_options     TYPE ssfcompop,         lv_user_settings      TYPE tdbool VALUE 'X',         ls_job_output_info    TYPE ssfcrescl,         ls_job_output_options TYPE ssfcresop.   DATA: lt_otfdata TYPE TABLE OF itcoo,         lt_pdfdata TYPE TABLE OF tline WITH HEADER LINE.   DATA: ls_data TYPE zfi_s_satici_mutabakat.   DATA: ls_document_data       LIKE  sodocchgi1,         lv_put_in_outbox       LIKE  sonv-flag,         lv_sender_address      LIKE  soextreci1-receiver,         lv_sender_address_type LIKE  soextreci1-adr_typ,         lv_commit_work         LIKE  sonv-flag VALUE space,         lt_packing_list  TYPE TABLE OF sopcklsti1 WITH HEADER LINE,         lt_object_header TYPE TABLE OF solisti1   WITH HEADER LINE,         lt_contents_bin  TYPE TABLE OF solisti1   WITH HEADER LINE,         lt_contents_txt  TYPE TABLE OF solisti1   WITH HEADER LINE,         lt_contents_hex  TYPE TABLE OF solix      WITH HEADER LINE,         lt_object_para   TYPE TABLE OF soparai1   WITH HEADER LINE,         lt_object_parb   TYPE TABLE OF soparbi1   WITH HEADER LINE,         lt_receivers     TYPE TABLE OF somlreci1  WITH HEADER LINE.   DATA: lv_len TYPE i,         lv_pos TYPE i,         lv_tab_lines TYPE i.   DATA: lt_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE.   CLEAR: lv_formname, lv_fm_name.   lv_formname = 'ZLIMIT_REQUEST_FORM2'.   PERFORM smartform_fm_name USING lv_formname                             CHANGING lv_fm_name .
 *get PDF Data   ls_control_parameters-getotf    = 'X'.   ls_control_parameters-no_dialog = 'X'.   ls_output_options-tdnoprev      = 'X'.   LOOP AT itab WHERE sel eq 'X'.     concatenate sy-datum+6(2)'.'sy-datum+4(2)         '.'sy-datum(4) into datum.     CALL FUNCTION lv_fm_name       EXPORTING         control_parameters = ls_control_parameters         output_options     = ls_output_options         user_settings      = 'X'         datum              = datum         EPAYMENT_T1        = EPAYMENT_T1         EPAYMENT_T2        = EPAYMENT_T2         EPAYMENT_D1        = EPAYMENT_D1         EPAYMENT_D2        = EPAYMENT_D2         NAME1              = name1
 "        itab               = itab[]       IMPORTING         job_output_info    = ls_job_output_info       TABLES         ITAB               = itab         .     FREE: lt_otfdata, lt_pdfdata.     lt_otfdata[] = ls_job_output_info-otfdata[].     PERFORM convert_otf TABLES lt_otfdata lt_pdfdata.     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 = 'Limit Talep Formu'.     ls_document_data-obj_descr = 'Limit Talep Formu'.     ls_document_data-expiry_dat  = sy-datum + 10.     ls_document_data-sensitivty = 'F'.     LOOP AT gt_mail.       CLEAR : lt_receivers.       lt_receivers-receiver = gt_mail-ZZSAHAMUDUREMAIL. " """reciever list       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 = 'Sayın yetkili,'.
     APPEND lt_contents_txt.CLEAR lt_contents_txt.     APPEND lt_contents_txt.     CONCATENATE 'Ekte tarafınıza ait limit formu'
     ' bulunmaktadır.' INTO lt_contents_txt-line
     SEPARATED BY space.     APPEND lt_contents_txt.CLEAR lt_contents_txt.     APPEND lt_contents_txt.     lt_contents_txt-line = 'Saygılarımızla,'.
     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.   ENDLOOP.
 ENDFORM.                    " SEND_MAIL

Viewing all articles
Browse latest Browse all 8332

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>