Sending reports output to email

Hi ,
I would like to send output of a report to email insted of printer. Are there any setting to be done. We are running on 11i.
Thanks
Kiran

Please see the user manual.
Oracle Alert User's Guide
http://download.oracle.com/docs/cd/B25516_18/current/acrobat/115alrug.pdf
Also, see old threads which discuss the same topic -- http://forums.oracle.com/forums/search.jspa?threadID=&q=Send+AND+E-mail+AND+Alert&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
Thanks,
Hussein

Similar Messages

  • Send report output via email as zipped attachment

    Is it possible for the report output to be zipped before being attached to an email when running on a windows reports_server? On unix we theoretically have the ability to modify the mail.sh shell script that performs the mail operation for reports.

    Hi Richard
    This is a Reports 9i solution.
    You may create a batch file that runs the report, compresses the file and invokes, say, a Java application that mails the given .zip file.
    More "advanced" options would be:
    You may create a pluggable destination that captures report output. Next, your code does the compresses the output file and mails it.
    A simpler solution would be to run two reports. First, that creates the reports output file. In its AFTER_REPORT trigger, call Java method (thru. Java Importer), that picks up the output file and compresses it. Second, that uses XML distribution feature of Reports 9i and mails the .zip file as a file attachment using appropriate construct.
    Regard
    Sripathy

  • Send Report output as Email attachment (PDF)

    Hi Experts,
      i am trying to send the contents of an internal table from my report as email using PDF attachment. I have coded the logic and i get the attachment in the email. When i try to open the attachement, i cannot open it.
    The message i get is "_Adobe reader could not open the attachment "attach.pdf" because it is either not a supported file type or the file has been damaged(for example, it was sent as an email attachment and wasn't correctly decoded )._
    Not sure where i went wrong.
      ld_email   = p_email.
      ld_mtitle = p_mtitle.
      ld_format              = p_format.
      ld_attdescription      = p_attdescription.
      ld_attfilename         = p_filename.
      ld_sender_address      = p_sender_address.
      ld_sender_address_type = p_sender_addres_type.
    Fill the document data.
      w_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name  = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle .
      w_doc_data-sensitivty = 'F'.
    Fill the document data and get size of attachment
    CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.
      w_doc_data-doc_size =
      ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
      w_doc_data-obj_langu  = sy-langu.
      w_doc_data-obj_name   = 'SAPRPT'.
      w_doc_data-obj_descr  = ld_mtitle.
      w_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = it_attach[].
    Describe the body of the message
      CLEAR t_packing_list.
      REFRESH t_packing_list.
      t_packing_list-transf_bin = space.
      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.
    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 t_packing_list-body_num.
      t_packing_list-doc_type   =  ld_format.
      t_packing_list-obj_descr  =  ld_attdescription.
      t_packing_list-obj_name   =  ld_attfilename.
      t_packing_list-doc_size   =  t_packing_list-body_num * 255.
      APPEND t_packing_list.
    Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
      t_receivers-receiver = ld_email.
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
      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
        TABLES
          packing_list               = t_packing_list
          contents_bin               = t_attachment
          contents_txt               = it_message
          receivers                  = t_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.
    Populate zerror return code
      ld_error = sy-subrc.
    Populate zreceiver return code
      LOOP AT t_receivers.
        ld_receiver = t_receivers-retrn_code.
      ENDLOOP.
    ENDFORM.                    "send_file_as_email_attachment

    Hello RnB,
    You can check the mentioned link for the same:
    [Simple Program to generate PDF from ABAP List Output.|http://www.abapmadeeasy.com/2011/02/sap-abap-simple-program-to-generate-pdf.html]
    Regards,
    Uttam Agrawal

  • Report output as email

    Hi All,
    I need to send report output as email text. is anybody has done this sort of work or any function module for this.
    Please help if anyone knows it.
    Cheers,
    Lokesh

    Hi
      Check the code for similar requirement I was faced earlier.
    Type for binary attachment table.
      types: l_ty_tab_objbin type solisti1 occurs 0.
      data: l_objbin type l_ty_tab_objbin.
    Tables to hold PDF data
      data: t_doctab type docs occurs 0,
            t_line  type tline occurs 0.
      tables : soli.             "SAPoffice: line, length 255
      tables : zpsdsalrep.       "ZPSDSALREP
      data: l_email type soli-line.
      data: l_email1 type soli-line.
      data: l_adrnr like kna1-adrnr.
      data: l_objky type nast-objky.
      data: l_zzterrmg type zpsdsalrep-zzterrmg.
      data: l_zsupervisor type zpsdsalrep-zsupervisor.
      data: l_kunnr type kna1-kunnr.
      data: l_kunnr1 type vbak-kunnr.
      data: l_reclist like somlreci1 occurs 0 with header line.
      data: l_objtxt    like solisti1 occurs   0 with header line.
      data: l_objpack   like sopcklsti1 occurs 0 with header line.
      data: l_doc_chng  like sodocchgi1.
      data: l_objhead   like solisti1 occurs   0 with header line.
      data: l_tab_lines like sy-tabix.
      constants: k_true type boolean_flg value 'X'.
      data: l_mail type somlreci1-receiver.
      data: l_mail1 type somlreci1-receiver.
      data:
    l_l_mail2 TYPE somlreci1-receiver.
    l_l_mail type somlreci1-receiver.
      data: l_zzsalesrep type zpsdsalrep-zzsalesrep.
      data: l_recipents type somlreci1-receiver.
      constants: k_x(1) type c value 'X',
                 k_u(1) type c value 'U',
                 k_raw(3) type c value 'RAW'.
      call function 'CONVERT_OTF_2_PDF'
    EXPORTING
      USE_OTF_MC_CMD               = 'X'
      ARCHIVE_INDEX                =
    IMPORTING
      BIN_FILESIZE                 =
        tables
          otf                          = t_otfdata
          doctab_archive               = t_doctab
          lines                        = t_line
          exceptions
         err_conv_not_possible        = 1
         err_otf_mc_noendmarker       = 2
         others                       = 3.
      if sy-subrc <> 0.
        write: / 'error', sy-subrc.
      endif.
    ***/ Convert the PDF format to the table type required for the
    **attachment.
      call function 'QCE1_CONVERT'
        tables
          t_source_tab         = t_line
          t_target_tab         = l_objbin
        exceptions
          convert_not_possible = 1
          others               = 2.
      if sy-subrc <> 0.
        write: / 'error', sy-subrc.
      endif.
      select single kunnr from vbak into l_kunnr1
             where vbeln = nast-objky.
      select single adrnr from kna1 into l_adrnr
             where kunnr = l_kunnr1.
      check sy-subrc is initial.
      select single smtp_addr from adr6 into l_email
             where addrnumber = l_adrnr.
    SELECT SINGLE zzterrmg FROM zpsdsalrep INTO l_zzterrmg
            WHERE zzsalesrep = l_kunnr1.
    SELECT SINGLE zsupervisor FROM zpsdsalrep INTO l_zsupervisor
         WHERE  zzterrmg = l_zzterrmg.
    SELECT SINGLE kunnr FROM kna1 INTO l_kunnr
           WHERE sortl = l_zsupervisor.
    SELECT SINGLE zsupervisor FROM zpsdsalrep INTO l_zsupervisor
           WHERE  zzsalesrep = l_kunnr1.
    SELECT SINGLE zzsalesrep FROM zpsdsalrep INTO l_zzsalesrep
           WHERE zzterrmg = l_zsupervisor.
    SELECT SINGLE adrnr FROM kna1 INTO l_adrnr
              WHERE kunnr = l_zzsalesrep.
    CHECK sy-subrc IS INITIAL.
    SELECT SINGLE smtp_addr FROM adr6 INTO l_email1
            WHERE addrnumber = l_adrnr.
    SELECT SINGLE adrnr FROM kna1 INTO l_adrnr
            WHERE kunnr = l_kunnr.
    CHECK sy-subrc IS INITIAL.
    SELECT SINGLE smtp_addr FROM adr6 INTO l_email1
            WHERE addrnumber = l_adrnr.
      l_mail = l_email.
    l_mail1 = l_email1.
    l_l_mail2 = text-006.
      l_l_mail = text-007.
    Creation of the document to be sent
    File Name
      l_doc_chng-obj_name = 'SENDFILE'.
    Mail Subject
      concatenate text-001 nast-objky into l_doc_chng-obj_descr.
    l_doc_chng-obj_descr = text-001.
    Completing the recipient list
      l_reclist-receiver = l_mail.
      l_reclist-rec_type = k_u.
      append l_reclist.
    l_reclist-receiver = l_mail1.
    l_reclist-rec_type = 'U'.
    APPEND l_reclist.
      l_reclist-receiver = l_l_mail.
      l_reclist-rec_type = k_u.
      append l_reclist.
    l_reclist-receiver = l_l_mail2.
    l_reclist-rec_type = 'U'.
    APPEND l_reclist.
    Mail Contents
      l_objtxt = text-002.
      append l_objtxt.
      clear l_objtxt.     " put in a blank line
      append l_objtxt.
      data: l_subject type solisti1.
      concatenate text-003 '-' nast-objky into l_subject.
      l_objtxt = l_subject.
      append l_objtxt.
      l_objtxt = text-004 .
      append l_objtxt.
    Calculate email size in bytes
      describe table l_objtxt lines l_tab_lines.
      read table l_objtxt index l_tab_lines.
      l_doc_chng-doc_size = ( l_tab_lines - 1 ) * 255 + strlen( l_objtxt ).
    Creation of the entry for the compressed document
    for the email text
      clear l_objpack-transf_bin.
      l_objpack-head_start = 1.
      l_objpack-head_num = 0.
      l_objpack-body_start = 1.
      l_objpack-body_num = l_tab_lines.
      l_objpack-doc_type = k_raw.
      append l_objpack.
    Creation of the document attachment
    (Assume that the data in OBJBIN is in BMP format)
      describe table l_objbin lines l_tab_lines.
      l_objhead = text-001  .
      append l_objhead.
      clear l_objpack.
    **/ Creation of the entry for the compressed/attached document
      l_objpack-transf_bin = k_true.
      l_objpack-head_start = 1.
      l_objpack-head_num = 1.
      l_objpack-body_start = 1.
      l_objpack-body_num = l_tab_lines.
      l_objpack-doc_type = 'PDF'.
      l_objpack-obj_name = text-005.
      l_objpack-obj_descr = text-001.
      l_objpack-doc_size = l_tab_lines * 255.
      append l_objpack. "/ .
      delete  l_reclist where receiver = ''.
    Sending the document
      call function 'SO_NEW_DOCUMENT_ATT_SEND_API1' " IN UPDATE TASK "/ .
        exporting
          document_data              = l_doc_chng
          put_in_outbox              = k_x
        tables
          packing_list               = l_objpack
          object_header              = l_objhead
          contents_bin               = l_objbin
          contents_txt               = l_objtxt
          receivers                  = l_reclist
        exceptions
          too_many_receivers         = 1
          document_not_sent          = 2
          operation_no_authorization = 4
          others                     = 99.
      if sy-subrc <> 0.
        write: / 'unsuccessful', sy-subrc.
      else.
        concatenate l_mail ',' l_mail1 ',' l_l_mail into l_recipents.
        syst-msgid = '8I'.
        syst-msgno = '000'.
        syst-msgty = 'S'.
        syst-msgv1 = text-008.
        skip.
        syst-msgv2 = text-009.
        syst-msgv3 = l_recipents.
        clear:  syst-msgv4. "syst-msgv2, syst-msgv3,
        perform protocol_update.
        write:  / 'successful'.
      endif.
    **/Take_note it is a requirement to do a commit work for the
    email to go into transaction SOST.
    COMMIT WORK.   "/Take_note .
    if sy-subrc eq 0.
    endif.
    Regards,
    Sreeram

  • Reg : Sending Script output to email

    Hi,
    I need to send script output to email.I have written the code for this functionality.
    Functional guy has created output type ,but that output type is red in clor and when I click process log " it says Parameter DEVICE= is invalid "
    Is there anything to be done from abap point for this error.
    Actually I used these 2 fun.modules
    DATA: LVF_DEVICE LIKE ITCPP-TDDEVICE.
    DATA: LVS_ITCPO TYPE ITCPO,
    LVF_DIALOG(1) TYPE C VALUE ' ',
    LVS_RECIPIENT LIKE SWOTOBJID,
    LVS_SENDER LIKE SWOTOBJID,
    LVS_SNAST TYPE SNAST,
    LVF_PROGRAM LIKE SY-REPID,
    LVS_COMM_TYPE TYPE AD_COMM,
    LVS_COMM_VALUES TYPE SZADR_COMM_VALUES.
    DATA:
    W_DEPT LIKE KNVK-ABTNR, "Department
    W_PRSNR LIKE KNVK-PRSNR. "Person number
    reset return code
    RETCODE = 0.
    IF NOT NAST-TCODE IS INITIAL AND NAST-NACHA EQ '5'.
    SELECT SINGLE * FROM USR21 WHERE BNAME = SY-UNAME.
    CALL FUNCTION 'ADDR_GET_NEXT_COMM_TYPE'
    EXPORTING
    strategy = nast-tcode
    address_number = Kna1-adrnr
    IMPORTING
    comm_type = lvs_comm_type
    comm_values = lvs_comm_values
    TABLES
    STRATEGY_TABLE =
    EXCEPTIONS
    address_not_exist = 1
    person_not_exist = 2
    no_comm_type_found = 3
    internal_error = 4
    parameter_error = 5
    OTHERS = 6.
    convert communication data
    Always INT
    LVS_COMM_TYPE = 'INT'.
    clear LVS_COMM_VALUES-ADSMTP-SMTP_ADDR.
    Get Contact persons number from KNVK
    SELECT SINGLE * FROM KNVK WHERE KUNNR EQ NAST-PARNR
    AND ABTNR EQ W_DEPT.
    Get it from ADR6 table always
    Select single * from adr6 where addrnumber = kna1-adrnr
    AND PERSNUMBER = KNVK-PRSNR.
    IF SY-SUBRC EQ 0 AND adr6-Smtp_addr NE ' '.
    LVS_COMM_VALUES-ADSMTP-SMTP_ADDR = adr6-Smtp_addr.
    ENDIF.
    ENDIF.
    MOVE-CORRESPONDING nast TO LVS_SNAST .
    MOVE sy-repid TO LVF_PROGRAM.
    CALL FUNCTION 'CONVERT_COMM_TYPE_DATA'
    EXPORTING
    pi_comm_type = lvs_comm_type
    pi_comm_values = lvs_comm_values
    pi_country = kna1-land1
    pi_repid = LVF_PROGRAM
    pi_snast = LVS_SNAST
    IMPORTING
    pe_itcpo = lvs_itcpo
    pe_device = lvf_device
    pe_mail_recipient = lvs_recipient
    pe_mail_sender = lvs_sender
    EXCEPTIONS
    comm_type_not_supported = 1
    recipient_creation_failed = 2
    sender_creation_failed = 3
    OTHERS = 4.
    fill structure itcpo
    ITCPO = LVS_ITCPO.
    CALL FUNCTION 'OPEN_FORM'
    EXPORTING
    APPLICATION = 'TX'
    ARCHIVE_INDEX = TOA_DARA
    ARCHIVE_PARAMS = ARC_PARAMS
    DEVICE = LVF_DEVICE
    DIALOG = ' '
    FORM = TNAPR-FONAM
    LANGUAGE = NAST-SPRAS
    OPTIONS = LVS_ITCPO
    MAIL_SENDER = LVS_SENDER
    MAIL_RECIPIENT = LVS_RECIPIENT
    MAIL_APPL_OBJECT = ' '
    RAW_DATA_INTERFACE = '*'
    IMPORTING
    LANGUAGE =
    NEW_ARCHIVE_PARAMS =
    RESULT =
    EXCEPTIONS
    CANCELED = 1
    DEVICE = 2
    FORM = 3
    OPTIONS = 4
    UNCLOSED = 5
    MAIL_OPTIONS = 6
    ARCHIVE_ERROR = 7
    OTHERS = 8.
    IF SY-SUBRC NE 0.
    CASE SY-SUBRC.
    WHEN 7.
    RETCODE = SY-SUBRC.
    SYST-MSGID = 'VN'.
    SYST-MSGNO = '096'.
    SYST-MSGTY = 'E'.
    SYST-MSGV1 = NAST-KSCHL.
    SYST-MSGV2 = NAST-KAPPL.
    PERFORM PROTOCOL_UPDATE.
    WHEN OTHERS.
    RETCODE = SY-SUBRC.
    PERFORM PROTOCOL_UPDATE.
    ENDCASE.
    ENDIF.
    and one more query is :
    I want to know weather
    "Are there any settings need to be done by BASIS people."
    If Anyone has any idea plz reply.

    Hi
    Use the below peace of code,I was used to send sales order confirmation script output as email.
    Change History
    Programmer   Date     Change Request Description
    FKHURRAM     9/16/02  DU1K920151     Upgrade changes.
                                         Use ADRC for Address Data
                 Print of an order confirmation by SAPscript
    REPORT rvador01 LINE-COUNT 100 MESSAGE-ID vn.
    TABLES: komk,                          "Communicationarea for conditions
            komp,                          "Communicationarea for conditions
            komvd,                         "Communicationarea for conditions
            vbco3,                         "Communicationarea for view
            vbdka,                         "Headerview
            vbdpa,                         "Itemview
            vbdpau,                        "Subitemnumbers
            conf_out,                      "Configuration data
            sadr,                          "Addresses
            tvag,                          "Reason for rejection
            vedka,                         "Servicecontract head data
            vedpa,                         "Servicecontract position data
            vedkn,                         "Servicecontract head notice data
            vedpn,                         "Servicecontract pos. notice data
            vbpa,                          "Sales Document: Partner
            kna1,                          "General Data in Customer Master
            riserls,                       "Serialnumbers
            komser,                        "Serialnumbers for print
            tvbur,                         "Sales office
            tvko,                          "Sales organisation
            adrs,                          "Communicationarea for Address
            fpltdr.                        "billing schedules
    INCLUDE yzrvadtabl.
    *INCLUDE RVADTABL.
    INCLUDE yzrvdirekt.
    *INCLUDE RVDIREKT.
    INCLUDE yzvedadata.
    *INCLUDE VEDADATA.
    DATA: retcode   LIKE sy-subrc.         "Returncode
    DATA: repeat(1) TYPE c.
    DATA: xscreen(1) TYPE c.               "Output on printer or screen
    DATA: BEGIN OF steu,                   "Controldata for output
            vdkex(1) TYPE c,
            vdpex(1) TYPE c,
            kbkex(1) TYPE c,
            kbpex(1) TYPE c,
          END OF steu.
    DATA: BEGIN OF tvbdpa OCCURS 0.        "Internal table for items
            INCLUDE STRUCTURE vbdpa.
    DATA: END OF tvbdpa.
    DATA: BEGIN OF tkomv OCCURS 50.
            INCLUDE STRUCTURE komv.
    DATA: END OF tkomv.
    DATA: BEGIN OF tkomvd OCCURS 50.
            INCLUDE STRUCTURE komvd.
    DATA: END OF tkomvd.
    DATA: BEGIN OF tvbdpau OCCURS 5.
            INCLUDE STRUCTURE vbdpau.
    DATA: END   OF tvbdpau.
    DATA: BEGIN OF tkomcon OCCURS 50.
            INCLUDE STRUCTURE conf_out.
    DATA: END   OF tkomcon.
    DATA: BEGIN OF tkomservh OCCURS 1.
            INCLUDE STRUCTURE vedka.
    DATA: END   OF tkomservh.
    DATA: BEGIN OF tkomservp OCCURS 5.
            INCLUDE STRUCTURE vedpa.
    DATA: END   OF tkomservp.
    DATA: BEGIN OF tkomservhn OCCURS 5.
            INCLUDE STRUCTURE vedkn.
    DATA: END   OF tkomservhn.
    DATA: BEGIN OF tkomservpn OCCURS 5.
            INCLUDE STRUCTURE vedpn.
    DATA: END   OF tkomservpn.
    DATA: BEGIN OF tkomser OCCURS 5.
            INCLUDE STRUCTURE riserls.
    DATA: END   OF tkomser.
    DATA: BEGIN OF tkomser_print OCCURS 5.
            INCLUDE STRUCTURE komser.
    DATA: END   OF tkomser_print.
    DATA: BEGIN OF tfpltdr OCCURS 5.
            INCLUDE STRUCTURE fpltdr.
    DATA: END   OF tfpltdr.
    DATA: pr_kappl(01)   TYPE c VALUE 'V'. "Application for pricing
    DATA: BEGIN OF char_val OCCURS 0,
            atnam LIKE cabn-atnam,
            atwrt LIKE ausp-atwrt,
          END OF char_val.
    FORM entry USING return_code us_screen.
      CLEAR retcode.
      xscreen = us_screen.
      PERFORM processing.
      IF retcode NE 0.
        return_code = 1.
      ELSE.
        return_code = 0.
      ENDIF.
    ENDFORM.                    "ENTRY
          FORM PROCESSING                                               *
    FORM processing.
      PERFORM get_data.
      CHECK retcode = 0.
      PERFORM form_open USING xscreen vbdka-land1.
      CHECK retcode = 0.
      PERFORM logo_selection.
      PERFORM form_title_print.
      CHECK retcode = 0.
      PERFORM write_header_info.
      PERFORM validity_print.
      CHECK retcode = 0.
      PERFORM header_data_print.
      CHECK retcode = 0.
      PERFORM header_serv_print.
      CHECK retcode = 0.
      PERFORM header_notice_print.
      CHECK retcode = 0.
      PERFORM header_inter_print.
      CHECK retcode = 0.
      PERFORM header_text_print.
      CHECK retcode = 0.
      PERFORM item_print.
      CHECK retcode = 0.
      PERFORM end_print.
      CHECK retcode = 0.
      PERFORM form_close.
      CHECK retcode = 0.
    *********************changes on 12/04/2007****************
      TABLES: tsp01.
      TYPES: BEGIN OF t_spool,
             rqident TYPE tsp01-rqident,
            END OF t_spool.
      DATA: i_spool TYPE STANDARD TABLE OF t_spool,
            wa_spool TYPE t_spool.
      SELECT  rqident FROM tsp01
      INTO TABLE i_spool
    WHERE rqowner = sy-uname.
      SORT i_spool DESCENDING BY rqident.
      LOOP AT i_spool INTO wa_spool.
      ENDLOOP.
    data: l_rqident type tsp01-rqident.
    SELECT SINGLE rqident FROM tsp01 INTO l_rqident
    WHERE rqowner = sy-uname.
    DATA: l_spoolno LIKE tsp01-rqident VALUE '0000024884'.
      TYPES: l_ty_tab_pdf TYPE tline OCCURS 0.
      DATA: l_pdf TYPE l_ty_tab_pdf,
            l_spool TYPE tsp01-rqident.
    Type for binary attachment table.
      TYPES: l_ty_tab_objbin TYPE solisti1 OCCURS 0.
      DATA: l_objbin TYPE l_ty_tab_objbin.
    l_spool = l_spoolno.
      l_spool = l_rqident.
      l_spool = wa_spool-rqident.
    **/ Call the standard function
      CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'             "#EC ARGCHECKED
          EXPORTING
            src_spoolid                    = l_spool
            no_dialog                      = ' '
          DST_DEVICE                     =
          PDF_DESTINATION                =
         IMPORTING
           pdf_bytecount                  = numbytes
           pdf_spoolid                    = pdfspoolid
          LIST_PAGECOUNT                 =
           btc_jobname                    = jobname
           btc_jobcount                   = jobcount
          TABLES
            pdf                            = l_pdf
          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 <> 0.
        WRITE: / 'error', sy-subrc.
      ENDIF.
    **/ Convert the PDF format to the table type required for the
    *attachment.
      CALL FUNCTION 'QCE1_CONVERT'
        TABLES
          t_source_tab         = l_pdf
          t_target_tab         = l_objbin
        EXCEPTIONS
          convert_not_possible = 1
          OTHERS               = 2.
      IF sy-subrc <> 0.
        WRITE: / 'error', sy-subrc.
      ENDIF.
      TABLES : soli.
      TABLES : zpsdsalrep.
      DATA: v_email TYPE soli-line.
      DATA: v_email1 TYPE soli-line.
      DATA: l_adrnr LIKE kna1-adrnr.
      DATA: l_objky TYPE nast-objky.
      DATA: l_zzterrmg TYPE zpsdsalrep-zzterrmg.
      DATA: l_zsupervisor TYPE zpsdsalrep-zsupervisor.
      DATA: l_kunnr TYPE kna1-kunnr.
      DATA: l_kunnr1 TYPE vbak-kunnr.
      SELECT SINGLE kunnr FROM vbak INTO l_kunnr1
             WHERE vbeln = nast-objky.
      SELECT SINGLE adrnr FROM kna1 INTO l_adrnr
             WHERE kunnr = l_kunnr1.
      CHECK sy-subrc IS INITIAL.
      SELECT SINGLE smtp_addr FROM adr6 INTO v_email
             WHERE addrnumber = l_adrnr.
      SELECT SINGLE zzterrmg FROM zpsdsalrep INTO l_zzterrmg
             WHERE zzsalesrep = l_kunnr1.
      SELECT SINGLE zsupervisor FROM zpsdsalrep INTO l_zsupervisor
          WHERE  zzterrmg = l_zzterrmg.
      SELECT SINGLE kunnr FROM kna1 INTO l_kunnr
            WHERE sortl = l_zsupervisor.
      SELECT SINGLE adrnr FROM kna1 INTO l_adrnr
             WHERE kunnr = l_kunnr.
      CHECK sy-subrc IS INITIAL.
      SELECT SINGLE smtp_addr FROM adr6 INTO v_email1
             WHERE addrnumber = l_adrnr.
      DATA: l_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE.
      DATA: l_objtxt    LIKE solisti1 OCCURS   0 WITH HEADER LINE.
      DATA: l_objpack   LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE.
      DATA: l_doc_chng  LIKE sodocchgi1.
      DATA: l_objhead   LIKE solisti1 OCCURS   0 WITH HEADER LINE.
      DATA: l_tab_lines LIKE sy-tabix.
      CONSTANTS: k_true TYPE boolean_flg VALUE 'X'.
      DATA: l_mail TYPE somlreci1-receiver.
      DATA: l_mail1 TYPE somlreci1-receiver.
      DATA: k_mail2 TYPE somlreci1-receiver.
      DATA: k_mail TYPE somlreci1-receiver.
      l_mail = v_email.
      l_mail1 = v_email1.
      k_mail2 = text-006.
      k_mail = text-007.
    Creation of the document to be sent
    File Name
      l_doc_chng-obj_name = 'SENDFILE'.
    Mail Subject
      l_doc_chng-obj_descr = text-001.
    Completing the recipient list
      l_reclist-receiver = l_mail.
      l_reclist-rec_type = 'U'.
      APPEND l_reclist.
      l_reclist-receiver = l_mail1.
      l_reclist-rec_type = 'U'.
      APPEND l_reclist.
      l_reclist-receiver = k_mail.
      l_reclist-rec_type = 'U'.
      APPEND l_reclist.
      l_reclist-receiver = k_mail2.
      l_reclist-rec_type = 'U'.
      APPEND l_reclist.
    Mail Contents
      l_objtxt = text-002.
      APPEND l_objtxt.
      CLEAR l_objtxt.     " put in a blank line
      APPEND l_objtxt.
      l_objtxt = text-003.
      APPEND l_objtxt.
      l_objtxt = text-004 .
      APPEND l_objtxt.
    Calculate email size in bytes
      DESCRIBE TABLE l_objtxt LINES l_tab_lines.
      READ TABLE l_objtxt INDEX l_tab_lines.
      l_doc_chng-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( l_objtxt ).
    Creation of the entry for the compressed document
    for the email text
      CLEAR l_objpack-transf_bin.
      l_objpack-head_start = 1.
      l_objpack-head_num = 0.
      l_objpack-body_start = 1.
      l_objpack-body_num = l_tab_lines.
      l_objpack-doc_type = 'RAW'.
      APPEND l_objpack.
    Creation of the document attachment
    (Assume that the data in OBJBIN is in BMP format)
      DESCRIBE TABLE l_objbin LINES l_tab_lines.
      l_objhead = text-001  .
      APPEND l_objhead.
      CLEAR l_objpack.
    **/ Creation of the entry for the compressed/attached document
      l_objpack-transf_bin = k_true.
      l_objpack-head_start = 1.
      l_objpack-head_num = 1.
      l_objpack-body_start = 1.
      l_objpack-body_num = l_tab_lines.
      l_objpack-doc_type = 'PDF'.
      l_objpack-obj_name = text-005.
      l_objpack-obj_descr = text-001.
      l_objpack-doc_size = l_tab_lines * 255.
      APPEND l_objpack. "/ .
    Sending the document
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1' "/ .
        EXPORTING
          document_data              = l_doc_chng
          put_in_outbox              = 'X'
        TABLES
          packing_list               = l_objpack
          object_header              = l_objhead
          contents_bin               = l_objbin
          contents_txt               = l_objtxt
          receivers                  = l_reclist
        EXCEPTIONS
          too_many_receivers         = 1
          document_not_sent          = 2
          operation_no_authorization = 4
          OTHERS                     = 99.
      IF sy-subrc <> 0.
        WRITE: / 'unsuccessful', sy-subrc.
      ELSE.
        WRITE:  / 'successful'.
      ENDIF.
    **/Take_note it is a requirement to do a commit work for the
    email to go into transaction SOST.
      COMMIT WORK.   "/Take_note .
    ENDFORM.                    "PROCESSING
          S U B R O U T I N E S                                         *
          FORM ALTERNATIVE_ITEM                                         *
          A text is printed, if the item is an alternative item.        *
    FORM alternative_item.
      CHECK vbdpa-grpos CN '0'.
      CALL FUNCTION 'WRITE_FORM'
        EXPORTING
          element = 'ALTERNATIVE_ITEM'
        EXCEPTIONS
          element = 1
          window  = 2.
      IF sy-subrc NE 0.
        PERFORM protocol_update.
      ENDIF.
    ENDFORM.                    "ALTERNATIVE_ITEM
          FORM CHECK_REPEAT                                             *
          A text is printed, if it is a repeat print for the document.  *
    FORM check_repeat.
      CLEAR repeat.
      SELECT * INTO *nast FROM nast WHERE kappl = nast-kappl
                                    AND   objky = nast-objky
                                    AND   kschl = nast-kschl
                                    AND   spras = nast-spras
                                    AND   parnr = nast-parnr
                                    AND   parvw = nast-parvw
                                    AND   nacha BETWEEN '1' AND '4'.
        CHECK *nast-vstat = '1'.
        repeat = 'X'.
        EXIT.
      ENDSELECT.
    ENDFORM.                    "CHECK_REPEAT
          FORM DELIVERY_DATE                                            *
          If the delivery date in the item is different to the header   *
          date and there are no scheduled quantities, the delivery date *
          is printed in the item block.                                 *
    FORM delivery_date.
      IF vbdka-lfdat =  space AND
         vbdpa-lfdat NE space AND
         vbdpa-etenr_da = space.
        CALL FUNCTION 'WRITE_FORM'
          EXPORTING
            element = 'ITEM_DELIVERY_DATE'
          EXCEPTIONS
            element = 1
            window  = 2.
        IF sy-subrc NE 0.
          PERFORM protocol_update.
        ENDIF.
      ENDIF.
    ENDFORM.                    "DELIVERY_DATE
          FORM DIFFERENT_CONSIGNEE                                      *
          If the consignee in the item is different to the header con-  *
          signee, it is printed by this routine.                        *
    FORM different_consignee.
      CHECK vbdka-name1_we NE vbdpa-name1_we
        OR  vbdka-name2_we NE vbdpa-name2_we
        OR  vbdka-name3_we NE vbdpa-name3_we
        OR  vbdka-name4_we NE vbdpa-name4_we.
      CHECK vbdpa-name1_we NE space
        OR  vbdpa-name2_we NE space
        OR  vbdpa-name3_we NE space
        OR  vbdpa-name4_we NE space.
      CALL FUNCTION 'WRITE_FORM'
        EXPORTING
          element = 'ITEM_CONSIGNEE'
        EXCEPTIONS
          element = 1
          window  = 2.
      IF sy-subrc NE 0.
        PERFORM protocol_update.
      ENDIF.
    ENDFORM.                    "DIFFERENT_CONSIGNEE
          FORM DIFFERENT_REFERENCE_NO                                   *
          If the reference number in the item is different to the header*
          reference number, it is printed by this routine.              *
    FORM different_reference_no.
      CHECK vbdpa-vbeln_vang NE vbdka-vbeln_vang
        OR  vbdpa-vbtyp_vang NE vbdka-vbtyp_vang.
      CALL FUNCTION 'WRITE_FORM'
        EXPORTING
          element = 'ITEM_REFERENCE_NO'
        EXCEPTIONS
          element = 1
          window  = 2.
      IF sy-subrc NE 0.
        PERFORM protocol_update.
      ENDIF.
    ENDFORM.                    "DIFFERENT_REFERENCE_NO
          FORM DIFFERENT_TERMS                                          *
          If the terms in the item are different to the header terms,   *
          they are printed by this routine.                             *
    FORM different_terms.
      DATA: us_vposn   LIKE vedpa-vposn.
      DATA: us_text(1) TYPE c.             "Flag for Noticetext was printed
      IF vbdpa-zterm NE vbdka-zterm AND
         vbdpa-zterm NE space.
        CALL FUNCTION 'WRITE_FORM'
          EXPORTING
            element = 'ITEM_TERMS_OF_PAYMENT'
          EXCEPTIONS
            element = 1
            window  = 2.
        IF sy-subrc NE 0.
          PERFORM protocol_update.
        ENDIF.
      ENDIF.
      IF vbdpa-inco1 NE space.
        IF vbdpa-inco1 NE vbdka-inco1 OR
           vbdpa-inco2 NE vbdka-inco2.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              element = 'ITEM_TERMS_OF_DELIVERY'
            EXCEPTIONS
              element = 1
              window  = 2.
          IF sy-subrc NE 0.
            PERFORM protocol_update.
          ENDIF.
        ENDIF.
      ENDIF.
    Print different validity-data for the position
      READ TABLE tkomservp WITH KEY vbdpa-posnr.
      IF sy-subrc EQ 0.
        vedpa = tkomservp.
        IF vedpa-vbegdat NE space       AND
           vedpa-venddat NE space       AND
           NOT vedpa-vbegdat IS INITIAL AND
           NOT vedpa-venddat IS INITIAL.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              element = 'ITEM_TERMS_OF_SERV1'
            EXCEPTIONS
              element = 1
              window  = 2.
          IF sy-subrc NE 0.
            PERFORM protocol_update.
          ENDIF.
        ELSEIF vedpa-vbegdat NE space AND
               NOT vedpa-vbegdat IS INITIAL.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              element = 'ITEM_TERMS_OF_SERV2'
            EXCEPTIONS
              element = 1
              window  = 2.
          IF sy-subrc NE 0.
            PERFORM protocol_update.
          ENDIF.
        ELSE.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              element = 'ITEM_TERMS_OF_SERV3'
            EXCEPTIONS
              element = 1
              window  = 2.
          IF sy-subrc NE 0.
            PERFORM protocol_update.
          ENDIF.
        ENDIF.
      ENDIF.
    Notice-rules for the positions.
      MOVE vbdpa-posnr TO us_vposn.
      CLEAR us_text.
      LOOP AT tkomservpn WHERE vposn = us_vposn.
        vedpn = tkomservpn.
        IF us_text IS INITIAL.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              element = 'ITEM_TERMS_OF_NOTTXT'
            EXCEPTIONS
              element = 1
              window  = 2.
          IF sy-subrc NE 0.
            PERFORM protocol_update.
          ENDIF.
          us_text = charx.
        ENDIF.
        CALL FUNCTION 'WRITE_FORM'
          EXPORTING
            element = 'ITEM_TERMS_OF_NOTICE'
          EXCEPTIONS
            element = 1
            window  = 2.
        IF sy-subrc NE 0.
          PERFORM protocol_update.
        ENDIF.
      ENDLOOP.
      IF NOT us_text IS INITIAL.
        CALL FUNCTION 'WRITE_FORM'
          EXPORTING
            element = 'EMPTY_LINE'
          EXCEPTIONS
            element = 1
            window  = 2.
        IF sy-subrc NE 0.
          PERFORM protocol_update.
        ENDIF.
      ENDIF.
    ENDFORM.                    "DIFFERENT_TERMS
          FORM END_PRINT                                                *
    FORM end_print.
      PERFORM get_header_prices.
      CALL FUNCTION 'CONTROL_FORM'
        EXPORTING
          command = 'PROTECT'.
      PERFORM header_price_print.
      CALL FUNCTION 'WRITE_FORM'
        EXPORTING
          element = 'END_VALUES'.
      CALL FUNCTION 'CONTROL_FORM'
        EXPORTING
          command = 'ENDPROTECT'.
      CALL FUNCTION 'WRITE_FORM'
        EXPORTING
          element = 'SUPPLEMENT_TEXT'
        EXCEPTIONS
          element = 1
          window  = 2.
      IF sy-subrc NE 0.
        PERFORM protocol_update.
      ENDIF.
    ENDFORM.                    "END_PRINT
          FORM FORM_CLOSE                                               *
          End of printing the form                                      *
    FORM form_close.
      CALL FUNCTION 'CLOSE_FORM'
        EXCEPTIONS
          OTHERS = 1.
      IF sy-subrc NE 0.
        PERFORM protocol_update.
        retcode = 1.
      ENDIF.
      SET COUNTRY space.
    ENDFORM.                    "FORM_CLOSE
          FORM FORM_OPEN                                                *
          Start of printing the form                                    *
    -->  US_SCREEN  Output on screen                                   *
                     ' ' = printer                                      *
                     'X' = screen                                       *
    -->  US_COUNTRY County for telecommunication and SET COUNTRY       *
    FORM form_open USING us_screen us_country.
      INCLUDE yzrvadopfo.
    INCLUDE RVADOPFO.
    ENDFORM.                    "FORM_OPEN
          FORM FORM_TITLE_PRINT                                         *
          Printing of the form title depending of the field VBTYP       *
    FORM form_title_print.
      CASE vbdka-vbtyp.
        WHEN 'A'.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              element = 'TITLE_A'
              window  = 'TITLE'
            EXCEPTIONS
              element = 1
              window  = 2.
          IF sy-subrc NE 0.
            PERFORM protocol_update.
          ENDIF.
        WHEN 'B'.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              element = 'TITLE_B'
              window  = 'TITLE'
            EXCEPTIONS
              element = 1
              window  = 2.
          IF sy-subrc NE 0.
            PERFORM protocol_update.
          ENDIF.
        WHEN 'C'.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              element = 'TITLE_C'
              window  = 'TITLE'
            EXCEPTIONS
              element = 1
              window  = 2.
          IF sy-subrc NE 0.
            PERFORM protocol_update.
          ENDIF.
        WHEN 'E'.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              element = 'TITLE_E'
              window  = 'TITLE'
            EXCEPTIONS
              element = 1
              window  = 2.
          IF sy-subrc NE 0.
            PERFORM protocol_update.
          ENDIF.
        WHEN 'F'.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              element = 'TITLE_F'
              window  = 'TITLE'
            EXCEPTIONS
              element = 1
              window  = 2.
          IF sy-subrc NE 0.
            PERFORM protocol_update.
          ENDIF.
        WHEN 'G'.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              element = 'TITLE_F'
              window  = 'TITLE'
            EXCEPTIONS
              element = 1
              window  = 2.
          IF sy-subrc NE 0.
            PERFORM protocol_update.
          ENDIF.
        WHEN 'H'.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              element = 'TITLE_H'
              window  = 'TITLE'
            EXCEPTIONS
              element = 1
              window  = 2.
          IF sy-subrc NE 0.
            PERFORM protocol_update.
          ENDIF.
        WHEN 'K'.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              element = 'TITLE_K'
              window  = 'TITLE'
            EXCEPTIONS
              element = 1
              window  = 2.
          IF sy-subrc NE 0.
            PERFORM protocol_update.
          ENDIF.
        WHEN 'L'.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              element = 'TITLE_L'
              window  = 'TITLE'
            EXCEPTIONS
              element = 1
              window  = 2.
          IF sy-subrc NE 0.
            PERFORM protocol_update.
          ENDIF.
        WHEN OTHERS.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              element = 'TITLE_OTHERS'
              window  = 'TITLE'
            EXCEPTIONS
              element = 1
              window  = 2.
          IF sy-subrc NE 0.
            PERFORM protocol_update.
          ENDIF.
      ENDCASE.
      IF repeat NE space.
        CALL FUNCTION 'WRITE_FORM'
          EXPORTING
            element = 'REPEAT'
            window  = 'REPEAT'
          EXCEPTIONS
            element = 1
            window  = 2.
        IF sy-subrc NE 0.
          PERFORM protocol_update.
        ENDIF.
      ENDIF.
    ENDFORM.                    "FORM_TITLE_PRINT
          FORM GET_DATA                                                 *
          General provision of data for the form                        *
    FORM get_data.
      DATA: us_veda_vbeln     LIKE veda-vbeln.
      DATA: us_veda_posnr_low LIKE veda-vposn.
      CALL FUNCTION 'RV_PRICE_PRINT_REFRESH'
        TABLES
          tkomv = tkomv.
      CLEAR komk.
      CLEAR komp.
      vbco3-mandt = sy-mandt.
      vbco3-spras = nast-spras.
      vbco3-vbeln = nast-objky.
      vbco3-kunde = nast-parnr.
      vbco3-parvw = nast-parvw.
      CALL FUNCTION 'RV_DOCUMENT_PRINT_VIEW'
        EXPORTING
          comwa = vbco3
        IMPORTING
          kopf  = vbdka
        TABLES
          pos   = tvbdpa.
    Fetch servicecontract-data and notice-data for head and position.
      us_veda_vbeln     = vbdka-vbeln.
      us_veda_posnr_low = posnr_low.
      CALL FUNCTION 'SD_VEDA_GET_PRINT_DATA'
        EXPORTING
          i_document_number = us_veda_vbeln
          i_language        = sy-langu
          i_posnr_low       = us_veda_posnr_low
        TABLES
          print_data_pos    = tkomservp
          print_data_head   = tkomservh
          print_notice_pos  = tkomservpn
          print_notice_head = tkomservhn.
      PERFORM get_controll_data.
      PERFORM sender.
      PERFORM check_repeat.
      PERFORM tvbdpau_create.
    ENDFORM.                    "GET_DATA
          FORM GET_ITEM_BILLING_SCHEDULES                               *
          In this routine the billing schedules are fetched from the    *
          database.                                                     *
    FORM get_item_billing_schedules.
      REFRESH tfpltdr.
      CHECK NOT vbdpa-fplnr IS INITIAL.
      CALL FUNCTION 'BILLING_SCHED_PRINTVIEW_READ'
        EXPORTING
          i_fplnr    = vbdpa-fplnr
          i_language = nast-spras
        TABLES
          zfpltdr    = tfpltdr.
    ENDFORM.                    "GET_ITEM_BILLING_SCHEDULES
    *&      Form  ITEM_BILLING_SCHEDULES_PRINT
          This routine prints the billing shedules of a salesdocument    *
          position.                                                      *
    FORM  item_billing_schedules_print.
      DATA: first_line(1) TYPE c.
      first_line = charx.
      LOOP AT tfpltdr.
        fpltdr = tfpltdr.
      Output of the following printlines
        IF NOT fpltdr-perio IS INITIAL.
        periodische Fakturen
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              element = 'ITEM_BILLING_SCHEDULE_PERIODIC'
            EXCEPTIONS
              element = 1
              window  = 2.
          IF sy-subrc NE 0.
            PERFORM protocol_update.
          ENDIF.
        bei periodischen nur eine Zeile
          EXIT.
        ELSEIF fpltdr-fareg CA '14'.
        prozentuale Teilfakturierung
          IF NOT first_line IS INITIAL.
            CLEAR first_line.
            CALL FUNCTION 'WRITE_FORM'
              EXPORTING
                element = 'ITEM_BILLING_SCHEDULE_PERCENT_HEADER'
              EXCEPTIONS
                element = 1
                window  = 2.
            IF sy-subrc NE 0.
              PERFORM protocol_update.
            ENDIF.
          ELSE.
            CALL FUNCTION 'WRITE_FORM'
              EXPORTING
                element = 'ITEM_BILLING_SCHEDULE_PERCENT'
              EXCEPTIONS
                element = 1
                window  = 2.
            IF sy-subrc NE 0.
              PERFORM protocol_update.
            ENDIF.
          ENDIF.
        ELSEIF fpltdr-fareg CA '235'.
        wertmäßige  Teilfakturierung
          IF NOT first_line IS INITIAL.
            CLEAR first_line.
            CALL FUNCTION 'WRITE_FORM'
              EXPORTING
                element = 'ITEM_BILLING_SCHEDULE_VALUE_HEADER'
              EXCEPTIONS
                element = 1
                window  = 2.
            IF sy-subrc NE 0.
              PERFORM protocol_update.
            ENDIF.
          ELSE.
            CALL FUNCTION 'WRITE_FORM'
              EXPORTING
                element = 'ITEM_BILLING_SCHEDULE_VALUE'
              EXCEPTIONS
                element = 1
                window  = 2.
            IF sy-subrc NE 0.
              PERFORM protocol_update.
            ENDIF.
          ENDIF.
        ELSEIF fpltdr-fareg CA '3'.
        Schlußrechnung
        ENDIF.
      ENDLOOP.
    ENDFORM.                    "ITEM_BILLING_SCHEDULES_PRINT
    *eject
          FORM GET_ITEM_CHARACTERISTICS                                 *
          In this routine the configuration data item is fetched from   *
          the database.                                                 *
    FORM get_item_characteristics.
      REFRESH tkomcon.
      CHECK NOT vbdpa-cuobj IS INITIAL.
      CALL FUNCTION 'CUD0_GET_CONFIGURATION'                    "#EC EXISTS
        EXPORTING
          instance      = vbdpa-cuobj
          language      = nast-spras
        TABLES
          configuration = tkomcon
        EXCEPTIONS
          OTHERS        = 4.
    ENDFORM.                    "GET_ITEM_CHARACTERISTICS
          FORM GET_ITEM_PRICES                                          *
          In this routine the price data for the item is fetched from   *
          the database.                                                 *
    FORM get_item_prices.
      CLEAR: komp,
             tkomv.
      IF komk-knumv NE vbdka-knumv.
        CLEAR komk.
        komk-mandt = sy-mandt.
        komk-kalsm = vbdka-kalsm.
        komk-kappl = pr_kappl.
        komk-waerk = vbdka-waerk.
        komk-knumv = vbdka-knumv.
        komk-vbtyp = vbdka-vbtyp.
      ENDIF.
      komp-kposn = vbdpa-posnr.
      CALL FUNCTION 'RV_PRICE_PRINT_ITEM'
        EXPORTING
          comm_head_i = komk
          comm_item_i = komp
          language    = nast-spras
        IMPORTING
          comm_head_e = komk
          comm_item_e = komp
        TABLES
          tkomv       = tkomv
          tkomvd      = tkomvd.
    ENDFORM.                    "GET_ITEM_PRICES
          FORM GET_HEADER_PRICES                                        *
          In this routine the price data for the header is fetched from *
          the database.                                                 *
    FORM get_header_prices.
      CALL FUNCTION 'RV_PRICE_PRINT_HEAD'
        EXPORTING
          comm_head_i = komk
          language    = nast-spras
        IMPORTING
          comm_head_e = komk
        TABLES
          tkomv       = tkomv
          tkomvd      = tkomvd.
    ENDFORM.                    "GET_HEADER_PRICES
    *&      Form  HEADER_DATA_PRINT
          Printing of header data like terms, weights ....               *
    FORM header_data_print.
      CALL FUNCTION 'WRITE_FORM'
        EXPORTING
          element = 'HEADER_DATA'
        EXCEPTIONS
          element = 1
          window  = 2.
      IF sy-subrc NE 0.
        PERFORM protocol_update.
      ENDIF.
    ENDFORM.                               " HEADER_DATA_PRINT
          FORM HEADER_PRICE_PRINT                                       *
          Printout of the header prices                                 *
    FORM header_price_print.
      LOOP AT tkomvd.
        AT FIRST.
          IF komk-supos NE 0.
            CALL FUNCTION 'WRITE_FORM'
              EXPORTING
                element = 'ITEM_SUM'.
          ELSE.
            CALL FUNCTION 'WRITE_FORM'
              EXPORTING
                element = 'UNDER_LINE'
              EXCEPTIONS
                element = 1
                window  = 2.
            IF sy-subrc NE 0.
              PERFORM protocol_update.
            ENDIF.
          ENDIF.
        ENDAT.
        komvd = tkomvd.
        IF komvd-koaid = 'D'.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              element = 'TAX_LINE'.
        ELSE.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              element = 'SUM_LINE'.
        ENDIF.
      ENDLOOP.
      DESCRIBE TABLE tkomvd LINES sy-tfill.
      IF sy-tfill = 0.
        CALL FUNCTION 'WRITE_FORM'
          EXPORTING
            element = 'UNDER_LINE'
          EXCEPTIONS
            element = 1
            window  = 2.
        IF sy-subrc NE 0.
          PERFORM protocol_update.
        ENDIF.
      ENDIF.
    ENDFORM.                    "HEADER_PRICE_PRINT
          FORM HEADER_TEXT_PRINT                                        *
          Printout of the headertexts                                   *
    FORM header_text_print.
      CALL FUNCTION 'WRITE_FORM'
        EXPORTING
          element = 'HEADER_TEXT'
        EXCEPTIONS
          element = 1
          window  = 2.
      IF sy-subrc NE 0.
        PERFORM protocol_update.
      ENDIF.
    ENDFORM.                    "HEADER_TEXT_PRINT
          FORM ITEM_CHARACERISTICS_PRINT                                *
          Printout of the item characteristics -> configuration         *
    FORM item_characteristics_print.
      LOOP AT tkomcon.
        conf_out = tkomcon.
        IF sy-tabix = 1.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              element = 'ITEM_LINE_CONFIGURATION_HEADER'
            EXCEPTIONS
              OTHERS  = 1.
          IF sy-subrc NE 0.
            PERFORM protocol_update.
          ENDIF.
        ELSE.
          CALL FUNCTION 'WRITE_FORM'
            EXPOR

  • Very urjent how to send report output in mail

    hi experts,
    how to send report output in mail which function module should i use wht parameters should i pass.
    thanks in addavnce,
    points to be awarded.

      CALL FUNCTION 'GET_PRINT_PARAMETERS'
           EXPORTING
                destination    = '026c'
                copies         = count
                list_name      = 'VATS_ASBUILT'
                list_text      = v_list
                immediately    = 'X'
                release        = 'X'
                new_list_id    = 'X'
                expiration     = days
                line_size      = 132
                line_count     = 65
                layout         = 'X_65_132'
    *            sap_cover_page = 'X'
    *            cover_page     = 'X'
                receiver       = 'SAP*'
                department     = 'VATS'
                no_dialog      = 'X'
           IMPORTING
                out_parameters = params
                valid          = valid.
      SUBMIT zppr_vats_asbuilt  WITH p_aufnr EQ v_aufnr
                   TO SAP-SPOOL WITHOUT SPOOL DYNPRO
                      SPOOL PARAMETERS params
                         AND RETURN.
      SELECT SINGLE rqident FROM tsp01 INTO l_spoolno
                         WHERE rqtitle = v_list .
    * convert report to PDF format
      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 <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        EXIT .
      ENDIF.
    Now comes the part to send the mail
      try.
    * -------- create persistent send request ------------------------
          send_request = cl_bcs=>create_persistent( ).
          clear document.
    * -------- create and set document with attachment ---------------
    * create document from internal table with text
          document = cl_document_bcs=>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->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->set_message_subject
            exporting
              ip_subject = t_sub.
    * add document to send request
          call method send_request->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=>create( 'VATSUPPORT' ).
          call method send_request->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=>create_internet_address(
          AD_SMTPADR ).
    * add recipient with its respective attributes to send request
          call method send_request->add_recipient
            exporting
              i_recipient = recipient
              i_express   = 'X'.
          ENDLOOP.
          call method send_request->set_status_attributes
            exporting
              i_requested_status = 'E'
              i_status_mail      = 'E'.
    * To send the mail immediately
          call method send_request->set_send_immediately( 'X' ).
    * ---------- send document ---------------------------------------
          call method send_request->send( ).
          commit work.

  • How to send smartform output through email

    Hi,
    I want to send smartform output through email.....
    can u give me sample program to send it through email......
    Regards,
    Jenifer
    MOderator Message: Basic and Frequently asked question. Please search before posting.
    Edited by: kishan P on Nov 26, 2010 11:11 AM

    Hi Jenifer,
    There are many threads available on SDN.
    Just have a look at this thread
    <<link removed by moderator>>
    Kindly search before you post.
    Regard
    Abhii
    Moderator Message: You have been warned many times against point-hunting. Continuing ignoring of the Moderator warnings will lead to account deletion. Consider this your last warning
    Edited by: kishan P on Nov 26, 2010 11:09 AM

  • To send smartform output through email and fax

    Hi,
    I need to send smartform output through email if the email address is present else if the email address is present then it has to be sent through fax.If both the email address and fax are present,then it has to send an email.
    Now the issue is I am able to send the email and I am getting the message as 'Output was successfully issued'.But the entry corresponding to this is not shown in SOST transaction.
    Can anyone tell me what would be the reason for this?

    HI,
    Try to look in transaction SCOT
    Regards,
    Egle

  • Email sending: "sending report output directly to the body of the email"

    Hi
         I got one requirement.this is the enhancement to already exisitng report.when user clicks on send email check box,report has to be display and this report output has to be send to email of the particular vendor. it has be seen directly in the body of the mail.not as attachement.Report output is in ALV format.Data is stored in internal table t_data.can anyone suggest what is the procedure for this.

    Hi i have tried the same thing and it works very fine,
    i will share my code, you just follow exactly, hopefully you can solve the issue..
    you refer clearly the body of the mail,
    it should solve your issue/
    FORM send_email .
        DATA  lt_message     TYPE            bcsy_text.
        DATA  lv_mail_title  TYPE            so_obj_des.
        DATA  document       TYPE REF TO     cl_document_bcs.
        DATA  recipient      TYPE REF TO     if_recipient_bcs.
        DATA  send_request   TYPE REF TO     cl_bcs.
        DATA  sent_to_all    TYPE            os_boolean.
        DATA  bcs_execption  TYPE REF TO     cx_bcs.
        DATA  wf_string(200)  TYPE            c.
    *    DATA  wf_string      TYPE            string.
        DATA  doc_execption  TYPE REF TO     cx_document_bcs.
        DATA lv_status(20)    TYPE c.
        DATA lv_count_email TYPE i.
        DATA lv_temp_stepcount TYPE c.
        LOOP AT wt_email INTO wa_email.
          TRY.
              CLEAR send_request.
              send_request = cl_bcs=>create_persistent( ).
    *Create Title
              lv_mail_title = 'Report Title'.
    *Create Message(EMAIL Body)
              REFRESH lt_message.
              APPEND '<p><b>Dear Sir/Madam,</b></p>' TO lt_message.
              APPEND '<p>The following report shows the status of </p>' TO lt_message.
              APPEND '<br>' TO lt_message.
              APPEND '<table border= "1" color = 2>' TO lt_message.
              CLEAR wf_string.
              CONCATENATE '<th><tr>'
                          '<td>Vendor  </td>'
                          '<td>Vendor Name</td>'
                          '<td>Coloun 1</td>'
                          '<td>Coloum 2</td>'
                          '</tr></th>' INTO wf_string.
              APPEND wf_string TO lt_message.
              LOOP AT wt_itbl INTO wa_itbl WHERE vendor = wa_email-vendor. "-> Define your Condition here wt_email( should contains vendor and its respective email id)
               CLEAR wf_string.
                CONCATENATE '<tr><td>' wa_itbl-vendor '</td>' INTO wf_string.
                APPEND wf_string TO lt_message.
                CONCATENATE '<td>' wa_itbl-Vendor_name '</td>' INTO wf_string.
                APPEND wf_string TO lt_message.
                CONCATENATE '<td>' wa_itbl-COL2 '</td></tr>' INTO wf_string.
                APPEND wf_string TO lt_message.
                CONCATENATE '<td>' wa_itbl-COL3 '</td></tr>' INTO wf_string.
                APPEND wf_string TO lt_message.
              ENDLOOP.
              APPEND '</table>' TO lt_message.
              APPEND '<br>' TO lt_message.
              APPEND '<p><b>Thank You</b></p>' TO lt_message.
    *Create Document
              CLEAR  document.
              TRY.
                  CALL METHOD cl_document_bcs=>create_from_text
                    EXPORTING
                      i_text         = lt_message
                      i_documenttype = 'HTM'
                      i_subject      = lv_mail_title
                    RECEIVING
                      result         = document.
                CATCH cx_document_bcs INTO doc_execption.
              ENDTRY.
    *Add document to email
              send_request->set_document( document ).
    *Add recipients to send request
              IF wa_email-smtp_addr IS NOT INITIAL.
                recipient = cl_cam_address_bcs=>create_internet_address(
                          i_address_string = wa_email-smtp_addr ).
                send_request->add_recipient( i_recipient = recipient ).
              ENDIF.
    *Send Email
              CALL METHOD send_request->send
                RECEIVING
                  result = sent_to_all.
              COMMIT WORK.
              IF sent_to_all EQ 'X'.
                lv_count_email = lv_count_email + 1.
              ENDIF.
            CATCH cx_bcs INTO bcs_execption.
          ENDTRY.
        ENDLOOP.
        IF sent_to_all = 'X'.
          SKIP 2.
          FORMAT COLOR COL_GROUP INTENSIFIED ON.
          ULINE /(10).
          WRITE: / 'Remark : '.
          ULINE /(10).
          FORMAT RESET.
          WRITE: /  'Email Message Sent Succesfully'.
          RETURN.
        ENDIF.
      ENDFORM.

  • Send the report output in Email in the case of  HR ABAP

    Hi
        how can i send the output of report in email when i am doin the HR ABAP report .
              This report will be sheduled to run automatically every day.
    If any body can help please send the answer.
    Thanks.

    hi,
    u have to use excel sheet attachment with mail.
    u can put internal table data into excel sheet...
    sample code...for attachment u have to use objbin..
    clear objbin.
    refresh objbin.
    t<b>his is heading purpose</b>
      CONCATENATE 'Name' 'PS No.'  'Grade' 'Location' 'OD' 'DOB'
        INTO objbin SEPARATED BY con_tab.
      CONCATENATE con_cret objbin INTO objbin.
      APPEND objbin.
    loop at it_email into wa_email.<<<<----intenal table
    this is actual data from internal table
      CONCATENATE
              wa_email-emp_ename
              wa_email-emp_pernr
              wa_email-persk
              loc
              wa_email-od
              wa_email-dob
          INTO objbin SEPARATED BY con_tab.
        CONCATENATE con_cret objbin INTO objbin.
        APPEND objbin.
        CLEAR objbin.
    reclist-receiver = email.
      reclist-rec_type = 'U'.
    reclist-receiver = 'TC12'.
    reclist-rec_type = 'B'.
      APPEND reclist.
    CLEAR objpack.
      att_type = 'XLS'.<<<<<--attachment type
      objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
      objpack-transf_bin = 'X'.
      objpack-head_start = 1.
      objpack-head_num   = 1.
      objpack-body_start = 1.
      objpack-body_num   = tab_lines.
      objpack-doc_type   = att_type.
      objpack-obj_name   = 'Attachment'.
      objpack-obj_descr  = 'Report.xls'.
      APPEND objpack.
    *Function module to send email with an attachment
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = docdata
          put_in_outbox              = 'X'
          commit_work                = 'X'
        TABLES
          packing_list               = objpack
          object_header              = objhead
          contents_bin               = objbin
          contents_txt               = objtxt
          receivers                  = reclist
        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.
      ELSE.
        MESSAGE s899(m3) WITH 'Mail sent successfully!'.
      ENDIF.
    i hope it will be useful,
    regards
    vivek

  • How to send the Report output thru email

    Dear All,
    Is there a way to send the output of a abap report thru mail. I am sure it is there.
    My report output is as following.
    Emp Code : A01234
    Name: XYZ
    Email-ID: [email protected]
    Dear XYZ,
    You have Rs....... as outstanding. Please clear all dues by ..(date).
    Thankyou,
    asdf.
    Please advice how to accomplish this. Send a sample source code if possible.
    Regards,
    Alok.

    Below you can find the sample code for sending the report as email.
    Do use this as cross reference..
    DATA: reclist      LIKE somlreci1  OCCURS 0 WITH HEADER LINE,
            objpack      LIKE sopcklsti1 OCCURS  1 WITH HEADER LINE,
            objhead      LIKE solisti1   OCCURS  1 WITH HEADER LINE,
            objtxt       LIKE solisti1   OCCURS 10 WITH HEADER LINE,
            objhex       LIKE solix      OCCURS 10 WITH HEADER LINE,
            listobject   LIKE abaplist   OCCURS 0  WITH HEADER LINE,
            so_ali       LIKE soli       OCCURS 0  WITH HEADER LINE,
            list_index   LIKE  sy-lsind  VALUE 0,
            packing_list LIKE sopcklsti1,
            docdata      LIKE sodocchgi1,
            tab_lines    TYPE i,
            l_rqident    LIKE tsp01-rqident,
            att_type     LIKE soodk-objtp.
      objtxt[] = mail_text[].
      IF p_skip_attach IS INITIAL.      " INS SIR 3971 TODD
        SYSTEM-CALL LOAD LISTLEVEL-STACK INTO wrkstack.
        IF  wrkstack[] IS INITIAL.
          SKIP 2.
          WRITE: /30 text-001 COLOR 5.
        ENDIF.
      ENDIF.                                " INS SIR 3971 TODD
    Prepare Receipient List
      REFRESH:  reclist.
      LOOP AT rcpnt_userids.
        IF rcpnt_userids-l_adr_name NA '@'.
          reclist-receiver    = rcpnt_userids-usrnam.
          reclist-rec_type    = 'B'.
          reclist-express     = 'X'.
        ELSE.
          reclist-receiver    = rcpnt_userids-l_adr_name.
          reclist-rec_type    = 'U'.
          reclist-express     = 'X'.
        ENDIF.
        APPEND reclist.
        CLEAR reclist.
      ENDLOOP.
    Prepare Doc Data
      DESCRIBE TABLE objtxt LINES tab_lines.
      READ     TABLE objtxt INDEX tab_lines.
      docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
      docdata-obj_langu  = sy-langu.
      docdata-obj_name   = 'ABAP Listing'.
      docdata-obj_descr  = subject.
      docdata-sensitivty = 'O'.
    Prepare OBJPACK
      CLEAR objpack-transf_bin.
      objpack-head_start = 1.
      objpack-head_num   = 0.
      objpack-body_start = 1.
      objpack-body_num   = tab_lines.
      objpack-doc_type   = 'RAW'.
      APPEND objpack.
      att_type = 'ALI'.
      DESCRIBE TABLE so_ali LINES tab_lines.
      READ     TABLE so_ali INDEX tab_lines.
      objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( so_ali ).
      objpack-transf_bin = 'X'.
      objpack-head_start = 1.
      objpack-head_num   = 0.
      objpack-body_start = 1.
      objpack-body_num   = tab_lines.
      objpack-doc_type   = att_type.
      objpack-obj_name   = 'ATTACHMENT'.
      objpack-obj_descr  = subject.
      APPEND objpack.
    SAP supplied API function module to send Message
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = docdata
          put_in_outbox              = 'X'
          commit_work                = 'X'     "used from rel. 6.10
        TABLES
          packing_list               = objpack
          object_header              = objhead
          contents_bin               = so_ali
          contents_txt               = objtxt
          receivers                  = reclist
        EXCEPTIONS
          too_many_reclist           = 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 i398(00) WITH 'SAP Office API Error'
                              sy-subrc
      ENDIF.

  • Need to send the report output in email body.

    Hi Friends,
    I need to send the report output in body of the email but not as an attachment.
    Requesting your suggestions. Please elaborated answers are expected.
    Thanks & Regards,
    S.Suresh Babu.

    If you are looking for same output to be available in the email body, i think this is not possible.
    If you are just concentrated on the data, then you can do as below.
    1. In your custom program, submit the actual report program via spool and by making use of that spool, read the spool content (We have function modules which can download the content from spool to the internal table), and by making use of this internal table, build the actual internal table as required which will be passed to email function module lets say SO_OBJECT_SEND etc..
    2. You can make use of even LIST_TO_MEMORY and LIST_FROM_MEMORY function modules as well instead of spool, if you have data in the final internal table.
    I am not sure, how can we handle in terms of logos if any.....or the data in the top of page related things......

  • Send the Report output to email from spool

    Hi All,
    The following process which i am doing to send the report output(Executed in background) to my mail id.
    I ran the report in Background and got the output in the spool. i opened the spool from the transaction SM37 and send the output to my external mail id via the following process
    click Spool Request->forward-> send SAP data
    here i am getting one POP up in there i gave my mail id and tick the check box on Express and click copy.
    Now i received the output in my mail .
    By doing the above process in the Quality server i am receiving the output in the mail as a PDF format that is correct.(Output is also correct).
    But when i execute the same in production server i am receiving the output in the mail as HTML format. (output and format is totally wrong). I want to know why its coming as HTML format instead of PDF format.
    Kindly help me regarding this.. Any configuration is there? If yes please let me know soon..
    Regards,
    Navaneeth...

    Hi,
    use scon, double-click on SMTP, select internet
    and compare the types of you both SAP-Systems.
    Hope it helps.
    Regards, Dieter

  • Re: Sending report output in the body of Email (Not as an attachment)

    Hi,
    My requirement is to send the report output in body part of the mail itself.  I am able to send the mail with the output as an attachment but requirement is it shoud be in the body part not as an attachment..
    Thanks,
    Anshuman.

    Hi Anshu,
        Can you please let me know is the ERMS configured in your system or you are sending
        the mail to the customer using Action Profiles. If you are sending the mail using a smartform
        assigned to an Action profile  then you can display that report internal table data or etc.. in
         the smartform itself so that the output data will be available in the e-mail body itself.
        Please let me know the way you are sending the e-mail if the above ones are incorrect.
    Thanks
    Arun

  • Sending report output via E-mail (excel pivoted format)

    Hi all,
    i have a written a report where i need to send the report output to somebody via
    E-mail.i am sending this report output via E-mail successfully.The receiver receives, my output in excel format.but this excel is not <b>pivoted</b>.
    i want , the receiver should get my output in pivoted excel format.i.e my output data should be exactly fit in the excel sheet.
    now the columns in excel sheet are overlapping.once i double clicked, the columns are getting separated.i do not want to double click.i want all the columns should come properly i.e excel field  length should be adjusted as per the output field length.
    i am giving my coding below.plz suggest how i can do the above thing .it's urgent.
    any idea will be highly appreaciated.
    Regards
    if not p_email1 is initial.
         perform fill_report_csv.
         perform f_send_internet_mail.
      endif.
    FORM fill_report_csv.
       data :   l_text(232) type c,
               v_matnr1(21) type c,
               v_matnr(21) type c,
               v_matkl(14) type c,
               v_maktx(45) type c,
               v_ttlstk(14) type c,
               v_verpr(14) type c,
               v_werks(14) type c,
               v_lgort(14) type c,
               v_char(10) type c,
               v_stks type p ,
               v_po(40) type c,
               v_qty(13) type c,
                v_qty1 type sy-datum,
               v_date(15) type c,
               v_date1(15) TYPE C,
               v_name(35) type c,
               v_eknam(18) type c,
               v_lifnr(15) type c,
            l_po(40) type c,
            v_matnr(20) type c,
             l_rate(11) type  p decimals 5,
             l_flag type c.
      concatenate c_equal c_colon 'PO no.' c_colon
                    into v_po.
      concatenate c_equal c_colon 'Material no.' c_colon
                    into v_matnr.
      concatenate c_equal c_colon 'Description.' c_colon
                    into v_maktx.
      concatenate c_equal c_colon 'Due Qty.' c_colon
                    into v_qty.
      concatenate c_equal c_colon 'Del Date.' c_colon
                    into v_date.
      concatenate c_equal c_colon 'Vendor.' c_colon
                    into v_name.
      concatenate c_equal c_colon 'Buyer.' c_colon
                    into v_eknam.
      concatenate c_equal c_colon 'Vendor Code.' c_colon
                    into v_lifnr.
    concatenate
             v_po v_matnr v_maktx v_qty
             v_date v_name v_eknam v_lifnr
             into i_download
             SEPARATED BY con_tab.
      append i_download .
    clear : v_po,v_matnr, v_maktx, v_qty, v_date, v_name, v_eknam,v_lifnr .
    clear wa_output.
    loop at i_output into wa_output.
       on change of wa_output-ebeln.
         clear v_lines.
         loop at i_eket into wa_eket
                 where ebeln = wa_output-ebeln.
           v_lines = v_lines + 1.
           clear wa_eket.
         endloop.
    **-- Checking of page break
         v_lines = sy-linno + v_lines .
         if 55 < v_lines  .
           write:/0(161) sy-uline.
           new-page.
         endif.
      clear v_lines.
          loop at i_eket into wa_eket
                  where ebeln = wa_output-ebeln.
            v_lines = v_lines + 1.
            clear wa_eket.
          endloop.
    *-- Calculating the due qty.
        wa_output-dumng = wa_output-menge - wa_output-wemng.
    *-- Writing the Line items of the PO.
        read table i_ekpo into wa_ekpo
              with key ebeln = wa_output-ebeln
                       ebelp = wa_output-ebelp.
         l_rate = wa_ekpo-netpr / wa_ekpo-peinh.
    *-- Writing of PO detail
         if wa_output-dumng gt 0 .
         v_qty = wa_output-dumng.
        v_date1 = wa_output-eindt.
        v_maktx = wa_output-maktx.
         if wa_output-maktx+0(1) = '"' .
                concatenate  c_equal wa_output-maktx
                   into v_maktx  .
             else .
                concatenate  c_equal c_colon wa_output-maktx c_colon
                   into v_maktx  .
             endif .
       if wa_output-name1+0(1) = '"' .
                concatenate  c_equal wa_output-name1
                   into v_name  .
             else .
                concatenate  c_equal c_colon wa_output-name1 c_colon
                   into v_name  .
             endif .
        v_name = wa_output-name1.
        v_lifnr = wa_output-lifnr.
         write wa_output-eindt to v_date1 DD/MM/YYYY.
         concatenate '="' wa_output-ebeln '/'
                wa_output-ebelp '"' into v_po .
         concatenate '="' wa_output-matnr '"' into v_matnr .
             concatenate  c_equal c_colon wa_output-maktx c_colon
               into v_maktx  .
              concatenate  c_equal c_colon wa_output-dumng c_colon
               into v_qty1  .
               concatenate  c_equal c_colon wa_output-eindt c_colon
               into v_date1  .
              concatenate  c_equal c_colon wa_output-name1 c_colon
               into v_name  .
                concatenate  c_equal c_colon wa_output-eknam c_colon
                into v_eknam  .
              concatenate  c_equal c_colon wa_output-lifnr c_colon
               into v_lifnr  .
              concatenate  c_equal c_colon wa_mard-werks '/'
               wa_mard-lgort c_colon
               into v_lgort .
                 concatenate '="' wa_output-lifnr '"' into v_lifnr .
    condense:v_po,v_matnr, v_maktx, v_qty, v_date, v_name, v_eknam,v_lifnr .
         concatenate
             v_po v_matnr v_maktx v_qty
             v_date1 v_name v_eknam v_lifnr
             into i_download
             SEPARATED BY con_tab.
        concatenate con_cret i_download INTO i_download .
        append i_download .
      endif.
    clear : v_po,v_matnr, v_maktx, v_qty, v_date, v_name, v_eknam,v_lifnr .
    endloop.
    ENDFORM.                    " fill_report_csv
    *&      Form  f_send_internet_mail
          text
    -->  p1        text
    <--  p2        text
    FORM f_send_internet_mail.
    Variables
    data:   it_packing_list like sopcklsti1 occurs 0 with header line,
            it_contents like solisti1 occurs 0 with header line,
            it_receivers like somlreci1 occurs 0 with header line,
            it_attachment like solisti1 occurs 0 with header line,
            gd_cnt type i,
            gd_sent_all(1) type c,
            gd_doc_data like sodocchgi1,
            gd_error type sy-subrc.
    data:   it_message type standard table of SOLISTI1 initial size 0
                    with header line.
    data : found_receiver type c,
           v_title(80) type c,
           l_text(180) type c.
    Fill the document data.
      gd_doc_data-doc_size = 1.
    Adds text to email text table
      append 'Pls see attached open purchase order report.' to it_message.
      append '' to it_message.
      concatenate 'Note: This is system generated report'
                  ', figures may subject to actual physical count.'
                  into l_text separated by space.
      append l_text to it_message.
    Populate the subject/generic message attributes
      CLEAR gd_doc_data.
      READ TABLE i_download INDEX w_cnt.
      gd_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( i_download ).
      gd_doc_data-obj_langu  = sy-langu.
      gd_doc_data-obj_name   = 'SAPRPT'.
    if p_asdate is initial .
         concatenate p_title ' '
                  sy-datum sy-uzeit into v_title separated by space.
    else .
        concatenate p_title ' '
                 p_bldat p_cputm into v_title separated by space.
    endif .
      gd_doc_data-obj_descr  = v_title .
      gd_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = i_download[].
    Describe the body of the message
      clear it_packing_list.
      refresh it_packing_list.
      it_packing_list-transf_bin = space.
      it_packing_list-head_start = 1.
      it_packing_list-head_num = 0.
      it_packing_list-body_start = 1.
      describe table it_message lines it_packing_list-body_num.
      it_packing_list-doc_type = 'RAW'.
      append it_packing_list.
    Create attachment notification
      it_packing_list-transf_bin = 'X'.
      it_packing_list-head_start = 1.
      it_packing_list-head_num   = 1.
      it_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES it_packing_list-body_num.
      it_packing_list-doc_type   =  'XLS'.
      it_packing_list-obj_descr  =  'OPEN PURCHASE ORDER' .
      it_packing_list-obj_name   =  'PO.XLS' .
      it_packing_list-doc_size   =  it_packing_list-body_num * 255.
      APPEND it_packing_list.
    assign SAP user smtp address from successful retrieval.
      loop at p_email.
    Add the recipients email address
         found_receiver = 'X' .
         it_receivers-receiver = p_email-low.
         it_receivers-rec_type = 'U'.
         it_receivers-com_type = 'INT'.
         it_receivers-notif_del = ''.
         it_receivers-notif_ndel = 'X'.
         append it_receivers .
      endloop .
    Add default recipient email when unable to locate purc group email
       if found_receiver is initial .
           it_receivers-receiver = p_email.
           it_receivers-rec_type = 'U'.
           it_receivers-com_type = 'INT'.
           it_receivers-notif_del = ''.
           it_receivers-notif_ndel = 'X'.
          append it_receivers.
       endif .
    Call the FM to post the message to SAPMAIL
      call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           exporting
                document_data              = gd_doc_data
                put_in_outbox              = 'X'
                commit_work                = 'X'
           importing
                sent_to_all                = gd_sent_all
           tables
                packing_list               = it_packing_list
                contents_bin               = t_attachment
                contents_txt               = it_message
                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.
    Store function module return code
      gd_error = sy-subrc.
    Get it_receivers return code
      loop at it_receivers.
      endloop.
    Instructs mail send program for SAPCONNECT to send email.
      wait up to 2 seconds.
      if gd_error eq 0.
          submit rsconn01 with mode = 'INT'
                        with output = ' '
                        and return.
      endif.
    ENDFORM.                    " f_send_internet_mail

    Hi,
    go through this link,
    http://www.sapdevelopment.co.uk/reporting/email/emailhome.htm
    you have some sample programs.
    Regards,
    Raghavendra

Maybe you are looking for

  • How do i open my iphone 5 on my computer so i can download my music onto my computer without using itunes

    I want to upload my music that i downloaded on my iphone 5 onto my computer. I didnt download the music on itunes. My phone doesnt come up in my computer

  • PageLayout Icon missing in Page tab

    HI, I have Publishing Infrastructure feature enabled (at the site collection level) and Server Publishing enabled (at the site level). I am not able to see the page lay out icon in my page tab to change my page layout Am I missing something? Please h

  • Embedding 3D text in Photoshop CS6?

    I was wanting to create an image of text embedded in a metal block. Is there any way to use the 3D tools in Photoshop CS6 to create this kind of effect ? I've only been able to extrude text 'up' ( if you know what I mean ! ) rather than down into a n

  • Urgent: Access Manager resource Adapter

    Hi, I am able to provision TAM using Access Manager Resource adapter from SUN IDM. But TAM has some custom attributes which need to be provisioned through IDM. Can Access Manager Resource adapter do it? Has anyone come across this scenario and what i

  • Transfer speed from Hard Drive

    Am I correct in thinking that data access is faster from an internal drive than an external one? I've got a stock MBP (5400 rpm?) drive and an external Firewire drive that runs at 7200 rpm. Is it faster to use the external drive as a scratch disk for