<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: sript pdf mail in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sript-pdf-mail/m-p/3521417#M846964</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The below link explains you how to convert the script to PDF&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="212758"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After you convert the script to PDF, instead of using the old FM's the BCS class to send the mail as an attachment..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the Class BCS offers advanced options to send the mail..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
    EXPORTING
      src_spoolid              = l_spoolno
      no_dialog                = 'X'
    TABLES
      pdf                      = l_ipdf
    EXCEPTIONS
      err_no_abap_spooljob     = 1
      err_no_spooljob          = 2
      err_no_permission        = 3
      err_conv_not_possible    = 4
      err_bad_destdevice       = 5
      user_cancelled           = 6
      err_spoolerror           = 7
      err_temseerror           = 8
      err_btcjob_open_failed   = 9
      err_btcjob_submit_failed = 10
      err_btcjob_close_failed  = 11
      OTHERS                   = 12.
  IF sy-subrc &amp;lt;&amp;gt; 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    EXIT .
  ENDIF.

* prepare to mail PDF document
* Subject of message

* Body of message
  CONCATENATE zmmtctoatsheader-buildid(20)
              '     '
              zmmtctoatsheader-cust_state(2)
              ' '
              zmmtctoatsheader-cust_ewo(10)
              zmmtctoatsheader-cust_street(30)
              INTO wa RESPECTING BLANKS.

  APPEND wa TO text.

  CONCATENATE 'The As Built Report is attached for Build ID'
        s_buildid_i ', Revision' v_buildid_rev '.' INTO wa
        SEPARATED BY space.
  APPEND wa TO text.

*  -------------------------------------------*
*  do the move via an internal table
  DATA: BEGIN OF l_itab OCCURS 0,
          val(1) TYPE c,
        END OF l_itab ,
        l_index LIKE l_len .

  LOOP AT l_ipdf INTO l_pdf_line.
    CLEAR l_pos .
    WHILE l_pos &amp;lt; 134 .
      l_itab-val = l_pdf_line+l_pos(1) .
      APPEND l_itab .
      l_pos = l_pos + 1 .
    ENDWHILE .
  ENDLOOP.
  DESCRIBE TABLE l_itab LINES l_len .
  CLEAR l_pos .
  DO .
    IF l_index = l_len .
      IF l_pos &amp;lt; 255 .
        APPEND l_iobjbin .
        CLEAR: l_iobjbin, l_pos .
      ENDIF .
      EXIT .
    ELSE .
      l_index = l_index + 1 .
      READ TABLE l_itab INDEX l_index .
      IF sy-subrc = 0 .
        IF l_pos &amp;lt; 255 .
          l_iobjbin+l_pos(1) = l_itab-val .
          l_pos = l_pos + 1 .
        ELSEIF l_pos = 255 .
          APPEND l_iobjbin .
          CLEAR: l_iobjbin, l_pos .
          l_iobjbin+l_pos(1) = l_itab-val .
          l_pos = l_pos + 1 .
        ENDIF .
      ENDIF .
    ENDIF .
  ENDDO .
*  -------------------------------------------*
** email recepients list
  IF sy-sysid EQ 'P01'.
    DATA v_vbeln TYPE vbeln.
    DATA v_kunnr TYPE kunnr.
    DATA v_prsnr TYPE ad_persnum.
    DATA v_smtp_addr TYPE ad_smtpadr.
    SELECT SINGLE vbeln FROM zmmtctoatsheader INTO v_vbeln
                              WHERE  aufnr = v_aufnr.
    SELECT SINGLE kunnr FROM vbak INTO v_kunnr
                            WHERE vbeln = v_vbeln.
    SELECT SINGLE prsnr FROM knvk INTO v_prsnr
                             WHERE kunnr = v_kunnr
                             AND   name1 = 'ATS_CABLE'.

    SELECT SINGLE smtp_addr FROM adr6 INTO v_smtp_addr
                             WHERE  persnumber = v_prsnr.
    MOVE v_smtp_addr TO l_ireclist-receiver.
    l_ireclist-rec_type = 'U'.
    APPEND l_ireclist.
  ELSE.
    DATA v_charval1 TYPE zcharval1.
    SELECT SINGLE charval1  FROM zcto INTO v_charval1
                          WHERE ctotable  =  'ATS_CABLE'
                           AND  charkey1  =  'CONTACT_EMAIL'.
    MOVE v_charval1 TO l_ireclist-receiver.
    l_ireclist-rec_type = 'U'.
    APPEND l_ireclist.
  ENDIF.

* set the subject of the e-mail

  IF sy-sysid EQ 'P01'.
    CONCATENATE zmmtctoatsheader-buildid
                zmmtctoatsheader-cust_state
                zmmtctoatsheader-cust_ewo
                zmmtctoatsheader-cust_street
                INTO i_subject RESPECTING BLANKS.

  ELSE.
    CONCATENATE '[' sy-sysid 'TEST]'
                zmmtctoatsheader-buildid
                zmmtctoatsheader-cust_state
                space
                zmmtctoatsheader-cust_ewo
                zmmtctoatsheader-cust_street
                INTO i_subject RESPECTING BLANKS.

  ENDIF.

*  pass this value onto the string of the subject, *subject line more than 50 chars
  t_sub = i_subject.

  TRY.
* -------- create persistent send request ------------------------
      send_request = cl_bcs=&amp;gt;create_persistent( ).
      CLEAR document.

* -------- create and set document with attachment ---------------
* create document from internal table with text
      document = cl_document_bcs=&amp;gt;create_document(
      i_type = 'RAW'
      i_text = text
      i_length = '12'
      i_subject = '' ).

*changing the content of the attachment
      binary_content[] = l_iobjbin[].

*change the name of the PDF attachment
      CONCATENATE 'Build ID' s_buildid_i 'Rev' v_buildid_rev
                          INTO i_att_sub SEPARATED BY space.

* add attachment to document
      CALL METHOD document-&amp;gt;add_attachment
        EXPORTING
          i_attachment_type    = 'PDF'
          i_attachment_subject = i_att_sub
          i_att_content_hex    = binary_content.

*setting the option to send an e-mail more than 50 characters
      CALL METHOD send_request-&amp;gt;set_message_subject
        EXPORTING
          ip_subject = t_sub.

* add document to send request
      CALL METHOD send_request-&amp;gt;set_document
        EXPORTING
          i_document = document.

* --------- set sender -------------------------------------------
* note: this is necessary only if you want to set the sender
* different from actual user (SY-UNAME). Otherwise sender is
* set automatically with actual user.

      sender = cl_sapuser_bcs=&amp;gt;create( 'VATSUPPORT' ).
      CALL METHOD send_request-&amp;gt;set_sender
        EXPORTING
          i_sender = sender.

*Send the list based on receivers list obtained

      LOOP AT l_ireclist.

        ad_smtpadr = l_ireclist-receiver.

* --------- add recipient (e-mail address) -----------------------
* create recipient - please replace e-mail address !!!
        recipient = cl_cam_address_bcs=&amp;gt;create_internet_address( ad_smtpadr ).

* add recipient with its respective attributes to send request
        CALL METHOD send_request-&amp;gt;add_recipient
          EXPORTING
            i_recipient = recipient
            i_express   = 'X'.

      ENDLOOP.

      CALL METHOD send_request-&amp;gt;set_status_attributes
        EXPORTING
          i_requested_status = 'E'
          i_status_mail      = 'E'.

* To send the mail immediately
      CALL METHOD send_request-&amp;gt;set_send_immediately( 'X' ).

* ---------- send document ---------------------------------------
      CALL METHOD send_request-&amp;gt;send( ).

      COMMIT WORK.


* -----------------------------------------------------------
* * exception handling
* -----------------------------------------------------------
* * replace this very rudimentary exception handling
* * with your own one !!!
* -----------------------------------------------------------
    CATCH cx_bcs INTO bcs_exception.

      EXIT.

  ENDTRY.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 11 Mar 2008 14:56:53 GMT</pubDate>
    <dc:creator>rahulkavuri</dc:creator>
    <dc:date>2008-03-11T14:56:53Z</dc:date>
    <item>
      <title>sript pdf mail</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sript-pdf-mail/m-p/3521416#M846963</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How to convert SAP script to pdf format and send mail?  What do we need to do in print program and configuration we need to achive?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Mar 2008 14:52:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sript-pdf-mail/m-p/3521416#M846963</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-11T14:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: sript pdf mail</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sript-pdf-mail/m-p/3521417#M846964</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The below link explains you how to convert the script to PDF&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="212758"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After you convert the script to PDF, instead of using the old FM's the BCS class to send the mail as an attachment..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the Class BCS offers advanced options to send the mail..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
    EXPORTING
      src_spoolid              = l_spoolno
      no_dialog                = 'X'
    TABLES
      pdf                      = l_ipdf
    EXCEPTIONS
      err_no_abap_spooljob     = 1
      err_no_spooljob          = 2
      err_no_permission        = 3
      err_conv_not_possible    = 4
      err_bad_destdevice       = 5
      user_cancelled           = 6
      err_spoolerror           = 7
      err_temseerror           = 8
      err_btcjob_open_failed   = 9
      err_btcjob_submit_failed = 10
      err_btcjob_close_failed  = 11
      OTHERS                   = 12.
  IF sy-subrc &amp;lt;&amp;gt; 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    EXIT .
  ENDIF.

* prepare to mail PDF document
* Subject of message

* Body of message
  CONCATENATE zmmtctoatsheader-buildid(20)
              '     '
              zmmtctoatsheader-cust_state(2)
              ' '
              zmmtctoatsheader-cust_ewo(10)
              zmmtctoatsheader-cust_street(30)
              INTO wa RESPECTING BLANKS.

  APPEND wa TO text.

  CONCATENATE 'The As Built Report is attached for Build ID'
        s_buildid_i ', Revision' v_buildid_rev '.' INTO wa
        SEPARATED BY space.
  APPEND wa TO text.

*  -------------------------------------------*
*  do the move via an internal table
  DATA: BEGIN OF l_itab OCCURS 0,
          val(1) TYPE c,
        END OF l_itab ,
        l_index LIKE l_len .

  LOOP AT l_ipdf INTO l_pdf_line.
    CLEAR l_pos .
    WHILE l_pos &amp;lt; 134 .
      l_itab-val = l_pdf_line+l_pos(1) .
      APPEND l_itab .
      l_pos = l_pos + 1 .
    ENDWHILE .
  ENDLOOP.
  DESCRIBE TABLE l_itab LINES l_len .
  CLEAR l_pos .
  DO .
    IF l_index = l_len .
      IF l_pos &amp;lt; 255 .
        APPEND l_iobjbin .
        CLEAR: l_iobjbin, l_pos .
      ENDIF .
      EXIT .
    ELSE .
      l_index = l_index + 1 .
      READ TABLE l_itab INDEX l_index .
      IF sy-subrc = 0 .
        IF l_pos &amp;lt; 255 .
          l_iobjbin+l_pos(1) = l_itab-val .
          l_pos = l_pos + 1 .
        ELSEIF l_pos = 255 .
          APPEND l_iobjbin .
          CLEAR: l_iobjbin, l_pos .
          l_iobjbin+l_pos(1) = l_itab-val .
          l_pos = l_pos + 1 .
        ENDIF .
      ENDIF .
    ENDIF .
  ENDDO .
*  -------------------------------------------*
** email recepients list
  IF sy-sysid EQ 'P01'.
    DATA v_vbeln TYPE vbeln.
    DATA v_kunnr TYPE kunnr.
    DATA v_prsnr TYPE ad_persnum.
    DATA v_smtp_addr TYPE ad_smtpadr.
    SELECT SINGLE vbeln FROM zmmtctoatsheader INTO v_vbeln
                              WHERE  aufnr = v_aufnr.
    SELECT SINGLE kunnr FROM vbak INTO v_kunnr
                            WHERE vbeln = v_vbeln.
    SELECT SINGLE prsnr FROM knvk INTO v_prsnr
                             WHERE kunnr = v_kunnr
                             AND   name1 = 'ATS_CABLE'.

    SELECT SINGLE smtp_addr FROM adr6 INTO v_smtp_addr
                             WHERE  persnumber = v_prsnr.
    MOVE v_smtp_addr TO l_ireclist-receiver.
    l_ireclist-rec_type = 'U'.
    APPEND l_ireclist.
  ELSE.
    DATA v_charval1 TYPE zcharval1.
    SELECT SINGLE charval1  FROM zcto INTO v_charval1
                          WHERE ctotable  =  'ATS_CABLE'
                           AND  charkey1  =  'CONTACT_EMAIL'.
    MOVE v_charval1 TO l_ireclist-receiver.
    l_ireclist-rec_type = 'U'.
    APPEND l_ireclist.
  ENDIF.

* set the subject of the e-mail

  IF sy-sysid EQ 'P01'.
    CONCATENATE zmmtctoatsheader-buildid
                zmmtctoatsheader-cust_state
                zmmtctoatsheader-cust_ewo
                zmmtctoatsheader-cust_street
                INTO i_subject RESPECTING BLANKS.

  ELSE.
    CONCATENATE '[' sy-sysid 'TEST]'
                zmmtctoatsheader-buildid
                zmmtctoatsheader-cust_state
                space
                zmmtctoatsheader-cust_ewo
                zmmtctoatsheader-cust_street
                INTO i_subject RESPECTING BLANKS.

  ENDIF.

*  pass this value onto the string of the subject, *subject line more than 50 chars
  t_sub = i_subject.

  TRY.
* -------- create persistent send request ------------------------
      send_request = cl_bcs=&amp;gt;create_persistent( ).
      CLEAR document.

* -------- create and set document with attachment ---------------
* create document from internal table with text
      document = cl_document_bcs=&amp;gt;create_document(
      i_type = 'RAW'
      i_text = text
      i_length = '12'
      i_subject = '' ).

*changing the content of the attachment
      binary_content[] = l_iobjbin[].

*change the name of the PDF attachment
      CONCATENATE 'Build ID' s_buildid_i 'Rev' v_buildid_rev
                          INTO i_att_sub SEPARATED BY space.

* add attachment to document
      CALL METHOD document-&amp;gt;add_attachment
        EXPORTING
          i_attachment_type    = 'PDF'
          i_attachment_subject = i_att_sub
          i_att_content_hex    = binary_content.

*setting the option to send an e-mail more than 50 characters
      CALL METHOD send_request-&amp;gt;set_message_subject
        EXPORTING
          ip_subject = t_sub.

* add document to send request
      CALL METHOD send_request-&amp;gt;set_document
        EXPORTING
          i_document = document.

* --------- set sender -------------------------------------------
* note: this is necessary only if you want to set the sender
* different from actual user (SY-UNAME). Otherwise sender is
* set automatically with actual user.

      sender = cl_sapuser_bcs=&amp;gt;create( 'VATSUPPORT' ).
      CALL METHOD send_request-&amp;gt;set_sender
        EXPORTING
          i_sender = sender.

*Send the list based on receivers list obtained

      LOOP AT l_ireclist.

        ad_smtpadr = l_ireclist-receiver.

* --------- add recipient (e-mail address) -----------------------
* create recipient - please replace e-mail address !!!
        recipient = cl_cam_address_bcs=&amp;gt;create_internet_address( ad_smtpadr ).

* add recipient with its respective attributes to send request
        CALL METHOD send_request-&amp;gt;add_recipient
          EXPORTING
            i_recipient = recipient
            i_express   = 'X'.

      ENDLOOP.

      CALL METHOD send_request-&amp;gt;set_status_attributes
        EXPORTING
          i_requested_status = 'E'
          i_status_mail      = 'E'.

* To send the mail immediately
      CALL METHOD send_request-&amp;gt;set_send_immediately( 'X' ).

* ---------- send document ---------------------------------------
      CALL METHOD send_request-&amp;gt;send( ).

      COMMIT WORK.


* -----------------------------------------------------------
* * exception handling
* -----------------------------------------------------------
* * replace this very rudimentary exception handling
* * with your own one !!!
* -----------------------------------------------------------
    CATCH cx_bcs INTO bcs_exception.

      EXIT.

  ENDTRY.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Mar 2008 14:56:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sript-pdf-mail/m-p/3521417#M846964</guid>
      <dc:creator>rahulkavuri</dc:creator>
      <dc:date>2008-03-11T14:56:53Z</dc:date>
    </item>
    <item>
      <title>Re: sript pdf mail</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sript-pdf-mail/m-p/3521418#M846965</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT Z_SCRIPT .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: itcpo LIKE itcpo,&lt;/P&gt;&lt;P&gt;tab_lines LIKE sy-tabix.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Variables for EMAIL functionality &lt;/P&gt;&lt;P&gt;DATA: maildata LIKE sodocchgi1.&lt;/P&gt;&lt;P&gt;DATA: mailpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;DATA: mailhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;DATA: mailbin LIKE solisti1 OCCURS 10 WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;DATA: mailtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;DATA: mailrec LIKE somlrec90 OCCURS 0 WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;DATA: solisti1 LIKE solisti1 OCCURS 0 WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM send_form_via_email.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM SEND_FORM_VIA_EMAIL * &lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;FORM send_form_via_email.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLEAR: maildata, mailtxt, mailbin, mailpack, mailhead, mailrec.&lt;/P&gt;&lt;P&gt;REFRESH: mailtxt, mailbin, mailpack, mailhead, mailrec.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Creation of the document to be sent File Name &lt;/P&gt;&lt;P&gt;maildata-obj_name = 'TEST'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mail Subject &lt;/P&gt;&lt;P&gt;maildata-obj_descr = 'Subject'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mail Contents &lt;/P&gt;&lt;P&gt;mailtxt-line = 'Here is your file'.&lt;/P&gt;&lt;P&gt;APPEND mailtxt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Prepare Packing List &lt;/P&gt;&lt;P&gt;PERFORM prepare_packing_list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set recipient - email address here!!! &lt;/P&gt;&lt;P&gt;mailrec-receiver = 'RAVINDRANATH.K@IN.BOSCH.COM'.&lt;/P&gt;&lt;P&gt;mailrec-rec_type = 'U'.&lt;/P&gt;&lt;P&gt;APPEND mailrec.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sending the document &lt;/P&gt;&lt;P&gt;CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;document_data = maildata&lt;/P&gt;&lt;P&gt;put_in_outbox = ' '&lt;/P&gt;&lt;P&gt;TABLES&lt;/P&gt;&lt;P&gt;packing_list = mailpack&lt;/P&gt;&lt;P&gt;object_header = mailhead&lt;/P&gt;&lt;P&gt;contents_bin = mailbin&lt;/P&gt;&lt;P&gt;contents_txt = mailtxt&lt;/P&gt;&lt;P&gt;receivers = mailrec&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;too_many_receivers = 1&lt;/P&gt;&lt;P&gt;document_not_sent = 2&lt;/P&gt;&lt;P&gt;operation_no_authorization = 4&lt;/P&gt;&lt;P&gt;OTHERS = 99.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Form PREPARE_PACKING_LIST &lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;FORM prepare_packing_list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLEAR: mailpack, mailbin, mailhead.&lt;/P&gt;&lt;P&gt;REFRESH: mailpack, mailbin, mailhead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DESCRIBE TABLE mailtxt LINES tab_lines.&lt;/P&gt;&lt;P&gt;READ TABLE mailtxt INDEX tab_lines.&lt;/P&gt;&lt;P&gt;maildata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( mailtxt ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Creation of the entry for the compressed document &lt;/P&gt;&lt;P&gt;CLEAR mailpack-transf_bin.&lt;/P&gt;&lt;P&gt;mailpack-head_start = 1.&lt;/P&gt;&lt;P&gt;mailpack-head_num = 0.&lt;/P&gt;&lt;P&gt;mailpack-body_start = 1.&lt;/P&gt;&lt;P&gt;mailpack-body_num = tab_lines.&lt;/P&gt;&lt;P&gt;mailpack-doc_type = 'RAW'.&lt;/P&gt;&lt;P&gt;APPEND mailpack.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Creation of the document attachment &lt;/P&gt;&lt;P&gt;This form gets the OTF code from the SAPscript form. &lt;/P&gt;&lt;P&gt;If you already have your OTF code, I believe that you may &lt;/P&gt;&lt;P&gt;be able to skip this form. just do the following code, looping thru &lt;/P&gt;&lt;P&gt;your SOLISTI1 and updating MAILBIN. &lt;/P&gt;&lt;P&gt;PERFORM get_otf_code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT solisti1.&lt;/P&gt;&lt;P&gt;MOVE-CORRESPONDING solisti1 TO mailbin.&lt;/P&gt;&lt;P&gt;APPEND mailbin.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DESCRIBE TABLE mailbin LINES tab_lines.&lt;/P&gt;&lt;P&gt;mailhead = 'TEST.OTF'.&lt;/P&gt;&lt;P&gt;APPEND mailhead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Creation of the entry for the compressed attachment &lt;/P&gt;&lt;P&gt;mailpack-transf_bin = 'X'.&lt;/P&gt;&lt;P&gt;mailpack-head_start = 1.&lt;/P&gt;&lt;P&gt;mailpack-head_num = 1.&lt;/P&gt;&lt;P&gt;mailpack-body_start = 1.&lt;/P&gt;&lt;P&gt;mailpack-body_num = tab_lines.&lt;/P&gt;&lt;P&gt;mailpack-doc_type = 'OTF'.&lt;/P&gt;&lt;P&gt;mailpack-obj_name = 'TEST'.&lt;/P&gt;&lt;P&gt;mailpack-obj_descr = 'Subject'.&lt;/P&gt;&lt;P&gt;mailpack-doc_size = tab_lines * 255.&lt;/P&gt;&lt;P&gt;APPEND mailpack.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Form GET_OTF_CODE &lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;FORM get_otf_code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF otf OCCURS 0.&lt;/P&gt;&lt;P&gt;INCLUDE STRUCTURE itcoo .&lt;/P&gt;&lt;P&gt;DATA: END OF otf.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: itcpo LIKE itcpo.&lt;/P&gt;&lt;P&gt;DATA: itcpp LIKE itcpp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLEAR itcpo.&lt;/P&gt;&lt;P&gt;itcpo-tdgetotf = 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Start writing OTF code &lt;/P&gt;&lt;P&gt;CALL FUNCTION 'OPEN_FORM'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;form = 'Z08V3_COLLI'&lt;/P&gt;&lt;P&gt;language = sy-langu&lt;/P&gt;&lt;P&gt;options = itcpo&lt;/P&gt;&lt;P&gt;dialog = ' '&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;OTHERS = 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'START_FORM'&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;error_message = 01&lt;/P&gt;&lt;P&gt;OTHERS = 02.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'WRITE_FORM'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;window = 'MAIN'&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;error_message = 01&lt;/P&gt;&lt;P&gt;OTHERS = 02.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Close up Form and get OTF code &lt;/P&gt;&lt;P&gt;CALL FUNCTION 'END_FORM'&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;error_message = 01&lt;/P&gt;&lt;P&gt;OTHERS = 02.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MOVE-CORRESPONDING itcpo TO itcpp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'CLOSE_FORM'&lt;/P&gt;&lt;P&gt;IMPORTING&lt;/P&gt;&lt;P&gt;result = itcpp&lt;/P&gt;&lt;P&gt;TABLES&lt;/P&gt;&lt;P&gt;otfdata = otf&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;OTHERS = 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Move OTF code to structure SOLI form email &lt;/P&gt;&lt;P&gt;CLEAR solisti1. REFRESH solisti1.&lt;/P&gt;&lt;P&gt;LOOP AT otf.&lt;/P&gt;&lt;P&gt;solisti1-line = otf.&lt;/P&gt;&lt;P&gt;APPEND solisti1.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Visit this link for SAMple code of SAPSCRIPT to PDF.:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapgenie.com/abap/pdf_creation.htm" target="test_blank"&gt;http://www.sapgenie.com/abap/pdf_creation.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and check the following weblog for code samples.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/people/sap.user72/blog/2004/11/10/bsphowto-generate-pdf-output-from-a-bsp&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;chk this one&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm" target="test_blank"&gt;http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;some function modules useful would be&lt;/P&gt;&lt;P&gt;CONVERT_OTF&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SO_NEW_DOCUMENT_ATT_SEND_API1 to send mails with attachments&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;plzz refer to this link..it will solve ur problem&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="650072"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="975814"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;venkat.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Mar 2008 14:58:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sript-pdf-mail/m-p/3521418#M846965</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-11T14:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: sript pdf mail</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sript-pdf-mail/m-p/3521419#M846966</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Venkat,&lt;/P&gt;&lt;P&gt; I have 4.6c version will it work with it too.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;THanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Mar 2008 15:09:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sript-pdf-mail/m-p/3521419#M846966</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-11T15:09:31Z</dc:date>
    </item>
  </channel>
</rss>

