Sending SAP Script output as a PDF attachment through mail

Dear Guru,
I am using SAP 4.0B version, DATABASE Oracle 8i, OS is sun solaris 7.5.
I want to send SAP script output as a
PDF attachement through mail.Please suggest a solution.
Regards,
Rajesh

Hi Rajesh,
In your print program, while calling OPEN_FORM, pass options-TDGETOTF = 'X'. This is used for returning print output in OTF format.
Then in CLOSE_FORM, get the table OTFDATA returned from the function module. for example
DATA: OTF_DATA LIKE ITCOO OCCURS 0 WITH HEADER LINE.
    CALL FUNCTION 'CLOSE_FORM'
      IMPORTING
        RESULT  = RESULT
      TABLES
        OTFDATA = OTF_DATA.
now you can convert this OTF data to PDF using function module CONVERT_OTF
Then send this data as attachment to a mail using function module SO_NEW_DOCUMENT_ATT_SEND_API1
Regards,
Komal.

Similar Messages

  • Sending log files for scheduled jobs as attachment through mail

    Hi All,
    Can any one please help me out to write a pl/sql program to send log files for scheduled jobs as attachment through mail.
    Thanks.

    Why would anyone do that as this code has already been posted here a thousand times, it is all over the Internet, and the only thing you need to do is to search for it?
    I agree it would cost you some effort, but you are getting paid for it, and we are not getting paid for delivering it on a golden plate on your doorstep, as you can not be bothered to use online resources.
    Sybrand Bakker
    Senior Oracle DBA

  • How to send pdf attachment through mail using Webdynpro-Java

    How can i send the Adobe Interactive Form with data involved as a PDF attachment to mail? using Webdynpro-Java.
    Is there any Adobe API or jar file for generating pdf?
    Helpful answer is highly appreciable and rewarded with points.!

    Hi Sankar,
    try [Offline Interactive PDF Form Using E-Mail|/docs/DOC-8061#49]
    Michal

  • Send SAP Script output (PDF) through Mail

    Dear Friends,
    Looking for sample program to send <b>SAP Script</b> output in PDF format to external mails while printing.
    Regards,
    Praveen Lobo

    Hi,
    better option is to convert your spool request to PDF and send it
    call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
    exporting
    src_spoolid = mi_rqident
    no_dialog = c_no
    dst_device = c_device
    importing
    pdf_bytecount = gd_bytecount
    tables
    pdf = it_pdf_output
    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.
    check sy-subrc = 0.
    Transfer the 132-long strings to 255-long strings
    loop at it_pdf_output.
    translate it_pdf_output using ' ~'.
    concatenate gd_buffer it_pdf_output into gd_buffer.
    endloop.
    translate gd_buffer using '~ '.
    do.
    it_mess_att = gd_buffer.
    append it_mess_att.
    shift gd_buffer left by 255 places.
    if gd_buffer is initial.
    exit.
    endif.
    enddo.
    then call FM after populating attachment data
    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

  • Sending smartform as pdf attachment through mail

    Dear All,
    Can anyone suggest me sample code of how an sap smartform output is sent as pdf attachment to a receipients email address?
    Thanks
    M A

    hi,
    chk this sample code.
    * Internal Table declarations
    DATA: i_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
          i_tline TYPE TABLE OF tline WITH HEADER LINE,
          i_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE,
          i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    * Objects to send mail.
          i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
          i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
    * Work Area declarations
          wa_objhead TYPE soli_tab,
          w_ctrlop TYPE ssfctrlop,
          w_compop TYPE ssfcompop,
          w_return TYPE ssfcrescl,
          wa_doc_chng typE sodocchgi1,
          w_data TYPE sodocchgi1,
          wa_buffer TYPE string,"To convert from 132 to 255
    * Variables declarations
          v_form_name TYPE rs38l_fnam,
          v_len_in LIKE sood-objlen,
          v_len_out LIKE sood-objlen,
          v_len_outn TYPE i,
          v_lines_txt TYPE i,
          v_lines_bin TYPE i.
    call function 'SSF_FUNCTION_MODULE_NAME'
         exporting
              formname           = 'ZZZ_TEST1'
         importing
              fm_name            = v_form_name
         exceptions
              no_form            = 1
              no_function_module = 2
              others             = 3.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    w_ctrlop-getotf = 'X'.
    w_ctrlop-no_dialog = 'X'.
    w_compop-tdnoprev = 'X'.
    CALL FUNCTION v_form_name
         EXPORTING
              control_parameters = w_ctrlop
              output_options     = w_compop
              user_settings      = 'X'
         IMPORTING
              job_output_info    = w_return
         EXCEPTIONS
              formatting_error   = 1
              internal_error     = 2
              send_error         = 3
              user_canceled      = 4
              OTHERS             = 5.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    i_otf[] = w_return-otfdata[].
    call function 'CONVERT_OTF'
           EXPORTING
                format                = 'PDF'
                max_linewidth         = 132
           IMPORTING
                bin_filesize          = v_len_in
           TABLES
                otf                   = i_otf
                lines                 = i_tline
           EXCEPTIONS
                err_max_linewidth     = 1
                err_format            = 2
                err_conv_not_possible = 3
                others                = 4.
    *   Fehlerhandling
      if sy-subrc <> 0.
      endif.
      loop at i_tline.
        translate i_tline using '~'.
        concatenate wa_buffer i_tline into wa_buffer.
      endloop.
      translate wa_buffer using '~'.
      do.
        i_record = wa_buffer.
        append i_record.
        shift wa_buffer left by 255 places.
        if wa_buffer is initial.
          exit.
        endif.
      enddo.
    * Attachment
      refresh:
        i_reclist,
        i_objtxt,
        i_objbin,
        i_objpack.
      clear wa_objhead.
      i_objbin[] = i_record[].
    ******* Create Message Body
    **** Title and Description
      i_objtxt = 'test with pdf-Attachment!'.
      append i_objtxt.
      describe table i_objtxt lines v_lines_txt.
      read table i_objtxt index v_lines_txt.
      wa_doc_chng-obj_name = 'smartform'.
      wa_doc_chng-expiry_dat = sy-datum + 10.
      wa_doc_chng-obj_descr = 'smartform'.
      wa_doc_chng-sensitivty = 'F'.
      wa_doc_chng-doc_size = v_lines_txt * 255.
    **** Main Text
    *  wa_doc_chng-doc_size = ( v_lines_txt - 1 ) * 255 + strlen( i_objtxt )
      clear i_objpack-transf_bin.
      i_objpack-head_start = 1.
      i_objpack-head_num = 0.
      i_objpack-body_start = 1.
      i_objpack-body_num = v_lines_txt.
      i_objpack-doc_type = 'RAW'.
      append i_objpack.
    **** Attachment
    * (pdf-Attachment)
      i_objpack-transf_bin = 'X'.
      i_objpack-head_start = 1.
      i_objpack-head_num = 0.
      i_objpack-body_start = 1.
    * Länge des Attachment ermitteln
      describe table i_objbin lines v_lines_bin.
      read table i_objbin index v_lines_bin.
      i_objpack-doc_size =  v_lines_bin * 255 .
      i_objpack-body_num = v_lines_bin.
      i_objpack-doc_type = 'PDF'.
      i_objpack-obj_name = 'smart'.
      i_objpack-obj_descr = 'test'.
      append i_objpack.
      clear i_reclist.
      i_reclist-receiver = '[email protected]'.
      i_reclist-rec_type = 'U'.
      append i_reclist.
        call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
             EXPORTING
                  document_data              = wa_doc_chng
                  put_in_outbox              = 'X'
             TABLES
                  packing_list               = i_objpack
                  object_header              = wa_objhead
                  CONTENTS_BIN               = i_objbin
                  contents_txt               = i_objtxt
                  receivers                  = i_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.
    Regards
    Anver

  • Send PDF  attachment through mail

    i have one PDF document on my desktop, i want to sent that PDF as attachment to mail through SAP.
    can anybody have idea how to get?

    i also had the same requirement... the following code is to attach a pdf file from PC. 'PDF' has been hard coded. to attach a text file change it to 'TXT'.
    *& Report  Y_FILE_FROM_PC
    REPORT  y_file_from_pc.
    * This program will allowed you to send email with attachment.
    First, specify the attachment file from your local hardisk and execute.
    Next, specify the sender email address and click the send button.
    DATA: method1 LIKE sy-ucomm,
    g_user LIKE soudnamei1,
    g_user_data LIKE soudatai1,
    g_owner LIKE soud-usrnam,
    g_receipients LIKE soos1 OCCURS 0 WITH HEADER LINE,
    g_document LIKE sood4 ,
    g_header LIKE sood2,
    g_folmam LIKE sofm2,
    g_objcnt LIKE soli OCCURS 0 WITH HEADER LINE,
    g_objhead LIKE soli OCCURS 0 WITH HEADER LINE,
    g_objpara LIKE selc OCCURS 0 WITH HEADER LINE,
    g_objparb LIKE soop1 OCCURS 0 WITH HEADER LINE,
    g_attachments LIKE sood5 OCCURS 0 WITH HEADER LINE,
    g_references LIKE soxrl OCCURS 0 WITH HEADER LINE,
    g_authority LIKE sofa-usracc,
    g_ref_document LIKE sood4,
    g_new_parent LIKE soodk.
    DATA: BEGIN OF g_files OCCURS 10 ,
    text(4096) TYPE c,
    END OF g_files.
    DATA : fold_number(12) TYPE c,
    fold_yr(2) TYPE c, fold_type(3) TYPE c.
    PARAMETERS ws_file(4096) TYPE c DEFAULT 'c:\debugger.PDF'.
    can me any file fromyour pc ....either xls or word or ppt etc ...
    g_user-sapname = sy-uname.
    CALL FUNCTION 'SO_USER_READ_API1'
    EXPORTING user = g_user
    prepare_for_folder_access = ' '
    IMPORTING
    user_data = g_user_data
    *EXCEPTIONS
    user_not_exist = 1
    parameter_error = 2
    x_error = 3
    OTHERS = 4
    IF sy-subrc NE 0.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    fold_type = g_user_data-outboxfol+0(3).
    fold_yr = g_user_data-outboxfol+3(2).
    fold_number = g_user_data-outboxfol+5(12).
    CLEAR g_files.
    REFRESH : g_objcnt, g_objhead, g_objpara, g_objparb, g_receipients, g_attachments, g_references, g_files.
    method1 = 'SAVE'.
    g_document-foltp = fold_type.
    g_document-folyr = fold_yr.
    g_document-folno = fold_number.
    g_document-objtp = g_user_data-object_typ.
    *g_document-objyr = '27'.
    *g_document-objno = '000000002365'.
    *g_document-objnam = 'MESSAGE'.
    g_document-objdes = 'attach file from pc'.
    g_document-folrg = 'O'.
    *g_document-okcode = 'CHNG'.
    g_document-objlen = '0'.
    g_document-file_ext = 'PDF'.
    g_header-objdes = 'attach file from pc'.
    g_header-file_ext = 'PDF'.
    CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'
    EXPORTING method = method1
    office_user = sy-uname
    ref_document = g_ref_document
    new_parent = g_new_parent
    IMPORTING
    authority = g_authority
    TABLES
    objcont = g_objcnt
    objhead = g_objhead
    objpara = g_objpara
    objparb = g_objparb
    recipients = g_receipients
    attachments = g_attachments
    references = g_references
    files = g_files
    CHANGING
    document = g_document
    header_data = g_header
    folmem_data =
    receive_data =
    file from the pc to send..
    method1 = 'ATTCREATEFROMPC'.
    g_files-text = ws_file.
    APPEND g_files.
    CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'
      EXPORTING
        method       = method1
        office_user  = g_owner
        ref_document = g_ref_document
        new_parent   = g_new_parent
      IMPORTING
        authority    = g_authority
      TABLES
        objcont      = g_objcnt
        objhead      = g_objhead
        objpara      = g_objpara
        objparb      = g_objparb
        recipients   = g_receipients
        attachments  = g_attachments
        references   = g_references
        files        = g_files
      CHANGING
        document     = g_document
        header_data  = g_header.
    method1 = 'SEND'.
    g_receipients-recnam = 'ABAP'.
    g_receipients-recesc = 'B'.
    g_receipients-sndex = 'X'.
    APPEND g_receipients.
    CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'
      EXPORTING
        method       = method1
        office_user  = g_owner
        ref_document = g_ref_document
        new_parent   = g_new_parent
      IMPORTING
        authority    = g_authority
      TABLES
        objcont      = g_objcnt
        objhead      = g_objhead
        objpara      = g_objpara
        objparb      = g_objparb
        recipients   = g_receipients
        attachments  = g_attachments
        references   = g_references
        files        = g_files
      CHANGING
        document     = g_document
        header_data  = g_header.
    hope this helps!

  • Send RFQ as an PDF attachment through mail

    Hi All,
      I wanna send the quotation format to multiple vendors in PDF through mail.
    I have developed RFQ using smartforms.
    Please lemme know how to do this and wat r the steps to be taken.
    Regards,
    Priya

    Hello,
    you only need to convert your smartform into PDF and next send.
    The sending can be seen for example here:
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c2567f2b-0b01-0010-b7b5-977cbf80665d
    or you can just search for the sending code, you will find something like this:
    http://monoceros85.blogspot.com/2009/04/send-email-in-abap-using-class-clbcs.html
    Email using cl_bcs
    Or direct example is here:
    Multiple PDF attachments using CL_BCS Class
    Regards, Otto
    p.s.: please search the next time first and ask later

  • How To send SAP SCRIPT AS an email.

    Hi,
    Any one knows how to send sap script output to users in the form of an email.
    Is there any other way to send it apart from sending the script output to spool and converting the spool to PDF and send that PDF to user?
    It would it helpful for me if u can let me know any peace of code as an example for the same.
    Message was edited by: Narasimha

    Hi,
    This may be too late but here is a really easy way
    Here is a snippet of code that will help you out.
    You can use the OPEN_FORM of the SAPscript to have a device type of MAIL instead of PRINTER
          Form  OPEN_FORM
          Open SAPscript form to send to user
    FORM OPEN_FORM .
    *--- Set recipient
      GW_COMM_VALUES-ADSMTP-SMTP_ADDR = '[email protected]'.
    *--- Set NAST details as these will not currently be set....
      CLEAR GW_SNAST.
      GW_SNAST-ANZAL = 1.
      GW_TITLE = 'Mail Header Title'.
      MOVE GW_TITLE TO GW_SNAST-TDCOVTITLE.
    *--- Set sender and recipient details
      CALL FUNCTION 'CONVERT_COMM_TYPE_DATA'
        EXPORTING
          PI_COMM_TYPE              = 'INT'
          PI_COMM_VALUES            = GW_COMM_VALUES
          PI_REPID                  = SY-REPID
          PI_SNAST                  = GW_SNAST
          PI_MAIL_SENDER            = SY-UNAME
        IMPORTING
          PE_ITCPO                  = GW_ITCPO
          PE_MAIL_RECIPIENT         = GW_RECIPIENT
          PE_MAIL_SENDER            = GW_SENDER
        EXCEPTIONS
          COMM_TYPE_NOT_SUPPORTED   = 1
          RECIPIENT_CREATION_FAILED = 2
          SENDER_CREATION_FAILED    = 3
          OTHERS                    = 4.
    *--- Open SAPscript in MAIL mode for e-mailing
      CALL FUNCTION 'OPEN_FORM'
        EXPORTING
          DEVICE                      = 'MAIL'
          DIALOG                      = 'X'
          FORM                        = SapScript Form Name
          LANGUAGE                    = SY-LANGU
          OPTIONS                     = GW_ITCPO
          MAIL_SENDER                 = GW_SENDER
          MAIL_RECIPIENT              = GW_RECIPIENT
        EXCEPTIONS
          CANCELED                    = 1
          DEVICE                      = 2
          FORM                        = 3
          OPTIONS                     = 4
          UNCLOSED                    = 5
          MAIL_OPTIONS                = 6
          ARCHIVE_ERROR               = 7
          INVALID_FAX_NUMBER          = 8
          MORE_PARAMS_NEEDED_IN_BATCH = 9
          SPOOL_ERROR                 = 10
          CODEPAGE                    = 11
          OTHERS                      = 12.
    When you have finished your SAPscript and call function CLOSE_FORM make sure you do a COMMI WORK after the call of this function.
    You should then see the mail created in SOST.
    Kind regards
    Colin

  • To convert Sap Script output to PDF format and send it via email.

    Hi Friends,
    Could any one please tell me, how to convert the Sap Script output to PDF format and send it via email. If any one have the code, kindly mail me to [email protected]
    Thanks & Regards,
    John

    Plese check this sample code from other thread.
    REPORT zzz_jaytest .
    Types Declaration
    TYPES : BEGIN OF ty_pa0001,
    pernr TYPE pa0001-pernr,
    bukrs TYPE pa0001-bukrs,
    werks TYPE pa0001-werks,
    END OF ty_pa0001.
    Internal Table Declaration
    DATA : i_pa0001 TYPE STANDARD TABLE OF ty_pa0001, "For pa0001 Details
    i_otf TYPE STANDARD TABLE OF itcoo, "For OTF data
    i_content_txt TYPE soli_tab, "Content
    i_content_bin TYPE solix_tab, "Content
    i_objhead TYPE soli_tab,
    Work Area Declaration
    w_pa0001 TYPE ty_pa0001, "For pa0001 Details
    w_res TYPE itcpp, "SAPscript output
    "parameters
    w_otf TYPE itcoo, "For OTF
    w_pdf TYPE solisti1, "For PDF
    w_transfer_bin TYPE sx_boolean, "Content
    w_options TYPE itcpo, "SAPscript output
    "interface
    Variable Declaration
    v_len_in TYPE so_obj_len,
    v_size TYPE i.
    Constants Declaration
    CONSTANTS : c_x TYPE c VALUE 'X', "X
    c_locl(4) TYPE c VALUE 'LOCL', "Local Printer
    c_otf TYPE sx_format VALUE 'OTF', "OTF
    c_pdf TYPE sx_format VALUE 'PDF', "PDF
    c_printer TYPE sx_devtype VALUE 'PRINTER', "PRINTER
    c_bin TYPE char10 VALUE 'BIN', "BIN
    c_name TYPE string VALUE 'C:\ZZZ_JAYTEST.PDF',"Downloading
    "File Name
    c_form(11) TYPE c VALUE 'ZZZ_JAYTEST'. "Form Name
    START-OF-SELECTION.
    Selecting the records from pa0001
    SELECT pernr bukrs werks FROM pa0001
    INTO TABLE i_pa0001 UP TO 10 ROWS.
    Setting the options
    w_options-tdcopies = 1 ."Number of copies
    w_options-tdnoprev = c_x."No print preview
    w_options-tdgetotf = c_x."Return of OTF table
    w_options-tddest = c_locl."Spool: Output device
    Opening the form
    CALL FUNCTION 'OPEN_FORM'
    EXPORTING
    form = c_form
    device = c_printer
    language = sy-langu
    OPTIONS = w_options
    IMPORTING
    RESULT = w_res.
    LOOP AT i_pa0001 INTO w_pa0001.
    Writting into the form
    CALL FUNCTION 'WRITE_FORM'
    EXPORTING
    element = 'MAIN'
    window = 'MAIN'.
    ENDLOOP.
    Closing the form
    CALL FUNCTION 'CLOSE_FORM'
    IMPORTING
    RESULT = w_res
    TABLES
    otfdata = i_otf
    EXCEPTIONS
    unopened = 1
    bad_pageformat_for_print = 2
    send_error = 3
    spool_error = 4
    codepage = 5
    OTHERS = 6.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    Converting OTF data to single line
    LOOP AT i_otf INTO w_otf.
    CONCATENATE w_otf-tdprintcom w_otf-tdprintpar
    INTO w_pdf.
    APPEND w_pdf TO i_content_txt.
    ENDLOOP.
    Converting to PDF Format
    CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
    EXPORTING
    format_src = c_otf
    format_dst = c_pdf
    devtype = c_printer
    CHANGING
    transfer_bin = w_transfer_bin
    content_txt = i_content_txt
    content_bin = i_content_bin
    objhead = i_objhead
    len = v_len_in
    EXCEPTIONS
    err_conv_failed = 1
    OTHERS = 2.
    v_size = v_len_in.
    Downloading the PDF File
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    bin_filesize = v_size
    filename = c_name
    filetype = c_bin
    TABLES
    data_tab = i_content_bin.
    The extension is put the it_mailpack-obj_name parameter of 'SO_NEW_DOCUMENT_ATT_SEND_API1'.

  • Smartform/Sap script output to Text file/PDF/WORD

    Hi,
    I need to download/transfer the output of smartforms/sap script to text file/pdf file or word file.How do i do that?
    Do I need to create a new output device?
    thnx in advance
    chirantan

    Hi,
    Go through the following Code
    Mail a sapscript
    SAPscript: Autotmatically e-mail as PDF
    How to convert sapscript(Purchage order) inot pdf format & send in  mail
    Check the following Code
    REPORT ZRICH_0003.
    DATA: ITCPO LIKE ITCPO,
          TAB_LINES LIKE SY-TABIX.
    Variables for EMAIL functionality
    DATA: MAILDATA   LIKE SODOCCHGI1.
    DATA: MAILPACK   LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
    DATA: MAILHEAD   LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
    DATA: MAILBIN    LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    DATA: MAILTXT    LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    DATA: MAILREC    LIKE SOMLREC90 OCCURS 0  WITH HEADER LINE.
    DATA: SOLISTI1   LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
    PERFORM SEND_FORM_VIA_EMAIL.
          FORM  SEND_FORM_VIA_EMAIL                                      *
    FORM  SEND_FORM_VIA_EMAIL.
      CLEAR:    MAILDATA, MAILTXT, MAILBIN, MAILPACK, MAILHEAD, MAILREC.
      REFRESH:  MAILTXT, MAILBIN, MAILPACK, MAILHEAD, MAILREC.
    Creation of the document to be sent File Name
      MAILDATA-OBJ_NAME = 'TEST'.
    Mail Subject
      MAILDATA-OBJ_DESCR = 'Subject'.
    Mail Contents
      MAILTXT-LINE = 'Here is your file'.
      APPEND MAILTXT.
    Prepare Packing List
      PERFORM PREPARE_PACKING_LIST.
    Set recipient - email address here!!!
      MAILREC-RECEIVER = '[email protected]'.
      MAILREC-REC_TYPE  = 'U'.
      APPEND MAILREC.
    Sending the document
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           EXPORTING
                DOCUMENT_DATA              = MAILDATA
                PUT_IN_OUTBOX              = ' '
           TABLES
                PACKING_LIST               = MAILPACK
                OBJECT_HEADER              = MAILHEAD
                CONTENTS_BIN               = MAILBIN
                CONTENTS_TXT               = MAILTXT
                RECEIVERS                  = MAILREC
           EXCEPTIONS
                TOO_MANY_RECEIVERS         = 1
                DOCUMENT_NOT_SENT          = 2
                OPERATION_NO_AUTHORIZATION = 4
                OTHERS                     = 99.
    ENDFORM.
         Form  PREPARE_PACKING_LIST
    FORM PREPARE_PACKING_LIST.
      CLEAR:    MAILPACK, MAILBIN, MAILHEAD.
      REFRESH:  MAILPACK, MAILBIN, MAILHEAD.
      DESCRIBE TABLE MAILTXT LINES TAB_LINES.
      READ TABLE MAILTXT INDEX TAB_LINES.
      MAILDATA-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( MAILTXT ).
    Creation of the entry for the compressed document
      CLEAR MAILPACK-TRANSF_BIN.
      MAILPACK-HEAD_START = 1.
      MAILPACK-HEAD_NUM = 0.
      MAILPACK-BODY_START = 1.
      MAILPACK-BODY_NUM = TAB_LINES.
      MAILPACK-DOC_TYPE = 'RAW'.
      APPEND MAILPACK.
    Creation of the document attachment
    This form gets the OTF code from the SAPscript form.
    If you already have your OTF code, I believe that you may
    be able to skip this form.  just do the following code, looping thru
    your SOLISTI1 and updating MAILBIN.
      PERFORM GET_OTF_CODE.
      LOOP AT SOLISTI1.
        MOVE-CORRESPONDING SOLISTI1 TO MAILBIN.
        APPEND MAILBIN.
      ENDLOOP.
      DESCRIBE TABLE MAILBIN LINES TAB_LINES.
      MAILHEAD = 'TEST.OTF'.
      APPEND MAILHEAD.
    Creation of the entry for the compressed attachment
      MAILPACK-TRANSF_BIN = 'X'.
      MAILPACK-HEAD_START = 1.
      MAILPACK-HEAD_NUM = 1.
      MAILPACK-BODY_START = 1.
      MAILPACK-BODY_NUM = TAB_LINES.
      MAILPACK-DOC_TYPE = 'OTF'.
      MAILPACK-OBJ_NAME = 'TEST'.
      MAILPACK-OBJ_DESCR = 'Subject'.
      MAILPACK-DOC_SIZE = TAB_LINES * 255.
      APPEND MAILPACK.
    ENDFORM.
         Form  GET_OTF_CODE
    FORM  GET_OTF_CODE.
      DATA: BEGIN OF OTF OCCURS 0.
              INCLUDE STRUCTURE ITCOO .
      DATA: END OF OTF.
      DATA: ITCPO LIKE ITCPO.
      DATA: ITCPP LIKE ITCPP.
      CLEAR ITCPO.
      ITCPO-TDGETOTF = 'X'.
    Start writing OTF code
      CALL FUNCTION 'OPEN_FORM'
           EXPORTING
                FORM     = 'ZTEST_FORM'
                LANGUAGE = SY-LANGU
                OPTIONS  = ITCPO
                DIALOG   = ' '
           EXCEPTIONS
                OTHERS   = 1.
      CALL FUNCTION 'START_FORM'
           EXCEPTIONS
                ERROR_MESSAGE = 01
                OTHERS        = 02.
      CALL FUNCTION 'WRITE_FORM'
           EXPORTING
                WINDOW        = 'MAIN'
           EXCEPTIONS
                ERROR_MESSAGE = 01
                OTHERS        = 02.
    Close up Form and get OTF code
      CALL FUNCTION 'END_FORM'
           EXCEPTIONS
                ERROR_MESSAGE = 01
                OTHERS        = 02.
      MOVE-CORRESPONDING ITCPO TO ITCPP.
      CALL FUNCTION 'CLOSE_FORM'
           IMPORTING
                RESULT  = ITCPP
           TABLES
                OTFDATA = OTF
           EXCEPTIONS
                OTHERS  = 1.
    Move OTF code to structure SOLI form email
      CLEAR SOLISTI1. REFRESH SOLISTI1.
      LOOP AT OTF.
        SOLISTI1-LINE = OTF.
        APPEND SOLISTI1.
      ENDLOOP.
    ENDFORM.
    Regards
    Sreeni

  • To send output as a PDF attachment via email

    Hi experts
    I have the (smartform) output data in OTF format..and displaying it in PDF form with FM 'HR_EFI_SHOW_PDF_FORM' .
    Now the requirement is <b>to send this output as a PDF attachment via email</b>.
    Please help me with sample code to perform this.
    Regards,
    Matt.

    Hi,
    Check this links,
    /people/sap.user72/blog/2004/11/10/bsphowto-generate-pdf-output-from-a-bsp
    Also for email:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/8cd6adbb-0301-0010-39ba-938c601d5db9
    Refer the following link for more details:
    http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm
    Thanks,
    Reward If Helpful.

  • Sending Cheque as PDF attachment in Mail using F110.

    Hi all,
    We have a requirement to send the cheque as as PDF attachment in Mail while printing it through transaction F110.Mail has to be triggered when the payment run is done through F110.Is there any config setting to do this without doing any changes to Print program RFFOUS_C.
    Thanks and Regards
    Kiran

    Hi,
    check below link
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/email%2bfrom%2bsap 
    Regards,
    Madhu

  • SAP Script output to RTF document

    Hi Team,
       We have a requirement of converting the SAPSCRIPT output to RTF document.
    I have seen some documents like BC - Word-Processing in the SAPscript Editor for this.
    But i could not clearly understand how to do it.
    Could please help me out by providing an overview of the process involved.
    Thanks & Regards,
    Vamsi.
    Edited by: Vamsi Krishna on Jul 7, 2010 12:42 PM

    Hi,
      Check the links below it might help you.
    Sending Sapscript as mail with multiple attachments
    Re: send sap script to client through mail
    Sending Sapscript as mail with multiple attachments
    Thanks & regards,
    Neela

  • Download Sap script output in XL.

    hi all,
    can anybody plz tell me that is there any possibility to download SAP script output in editable XL format? actually i got a new requirement in my company so plz can anybody help me for this?
    regards saurabh.

    Hi, Below code used for convert output into PDF format. May be you can convert into XL.
    In close form, collect output data into OTF format.
        call function 'CLOSE_FORM'
          TABLES
            otfdata                  = it_otfdata
          EXCEPTIONS
            unopened                 = 1
            bad_pageformat_for_print = 2
            send_error               = 3
            others                   = 4.
        if sy-subrc <> 0.
          PERFORM protocol_update.
          retcode = 1.
        endif.
      call function 'CONVERT_OTF'
        EXPORTING
          format                = c_pdf
        IMPORTING
          bin_filesize          = h_size
        TABLES
          otf                   = it_otfdata
          lines                 = it_pdf
        EXCEPTIONS
          err_max_linewidth     = 1
          err_format            = 2
          err_conv_not_possible = 3
          others                = 4.
      if sy-subrc <> 0.
       MOVE sy-subrc                 TO   h_retcode.
      endif.
      perform table_shift.
    form table_shift.
      describe table it_pdf    lines  hltlines.
      DESCRIBE FIELD IT_PDF    LENGTH FLE1 in character mode.
      DESCRIBE FIELD X_OBJCONT LENGTH FLE2 in character mode.
      clear   x_objcont.
      refresh x_objcont.
      clear off1.
      clear hfeld.
      loop at it_pdf.
        htabix = sy-tabix.
        move it_pdf to hfeld+off1.
        if htabix = hltlines.
          fle1 = strlen( it_pdf ).
        endif.
        off1 = off1 + fle1.
        if off1 ge fle2.
          clear x_objcont.
          x_objcont = hfeld(fle2).
          append x_objcont.
          shift hfeld by fle2 places.
          off1 = off1 - fle2.
        endif.
        if htabix = hltlines.
          if off1 gt 0.
            clear x_objcont.
            x_objcont = hfeld(off1).
            append x_objcont.
          endif.
        endif.
      endloop.
    endform.                    " TABLE_SHIFT

  • Dispalying SAP script output in landscape format

    Hello All,
    Could anyone please tell me the step by step process to display a SAP Script output in landscape format?
    Also is it possible to display a column name in 2 lines if it does not fit into 1 line.
    Regards
    Indrajit.

    Hi,
    Here is the way to print the SAPSCRIPT in landscape ..
    Goto SE71, then give you layout name then press change, then press the Header button(CAP ICON), then you will get the Header infomation, then select the Basic Settings pushbutton, then there we have an option to Print the Layout in  Portrait format or Landscapr format, then select the LANDSCAPR format Radio button then activate it
    Regards
    Sudheer

Maybe you are looking for

  • New dualshock3 controller don't pair with z2 tablet

    Today I received my new dualshock3 controller but when I connect it to my z2 tablet and try to pair them after some seconds I receive this message : Unfortunately, dualshock3 wireless controller stopped Anyone have the same problem? What do I do?

  • I-tunes wont download podcast or purchased music

    After upgrading i-tunes and getting the crazy spinning i-con i managed to sort that problem but ever since i cant download any podcasts or purchase music i get a message reading your are not connected to the internet or the url is incorrect etc etc.

  • Xserve/Windows Network Issue - can't see computers

    seriously, everything was fine until xmas eve. Now I can't see the computers on the network on a mac or a pc. Now, when I go to Start/My Network places on a pc the share points do not show up. Also when I go View Workgroup Computers - it returns an e

  • Cross Company Sales Automatic Vendor Invoice Not Created

    Hi, I have an issue in Cross company Sales Scenario (Inter company Sales), During the Intercompany Invoice we can trigger output RD04 to create Automatic Vendor Invoice in the Ordering Company. I have done the necessary configuration for creating Ido

  • Firefox 'opens containing folder' with...

    ...Leafpad here, which of course does not always helps /-} Arch Linux x86_64, Firefox, i3 window manager. Up to date. For an user and two profiles, the Mozilla browser opens "containing folder" with Leafpad (on both profiles). While for the other use