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

Similar Messages

  • Send sap script to client through mail

    hi gurus,
    here it goes..
    i have made a sap script and when i execute the driver program a screen pops up showing print parameters like 'print',printpreview , spool request etc.
    i assign a local printer lp01 to it and slect new spool request and click on print .
    but after that nothing happens . actually i want to view the spool number i go to transaction sp01 where i cannot find any spool numbers under my id.
    secondly,
    if i get the spool number (if i get) how to send the sap script to client's email id directly .also the sap script delivered to client should be in a printable form
    do help .points will be awarded.

    HI
    Use FM:
    Read the Spool:
        call function 'RSPO_RETURN_SPOOLJOB'
             exporting
                  rqident              = w_spoolid
                  desired_type         = c_raw  "'RAW'
             tables
                  buffer               = x_buffer
             exceptions
                  no_such_job          = 1
                  job_contains_no_data = 2
                  selection_empty      = 3
                  no_permission        = 4
                  can_not_access       = 5
                  read_error           = 6
                  type_no_match        = 7
                  others               = 8.
    Then move it ,
       loop at  x_buffer.
          x_contents = x_buffer.
          append x_contents.
          clear  x_contents.
        endloop.
    , where x_contents like solisti1 occurs 0 with header line.
    Then, fill the desired parameters and call,
    call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
               exporting
                    document_data              = wa_document_data
               tables
                    packing_list               = x_packing_list
                    object_header              = x_object_header
                    contents_bin               = x_contents_bin
                    contents_txt               = x_contents_txt
                    receivers                  = x_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.
    Take help of this FM documentation.
    Regards
    Subramanian

  • 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.

  • 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

  • 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

  • Convert sap script to pdf and send mail before close_form

    hi experts,
    I am converting a sap script to PDF and then sending that pdf to vendor mail ids.
    I am getting the Data for the conversion of pdf From close_form.But it contains the data for all the vendors . But i have to Send the mail to the specific vendors.For ex if my script output has 5 sheets each with different vendors . I have to send  1 sheet as a pdf mail for that particular vendor. so,1 sheet each for 5 differrent vendors . But the data i get from close_form is the data for all the 5 vendors. How to split the data ?. can any one help me on this issue.
    with thanks in advance,
    syed

    Hi,
        Change your driver program so that it calls the script n no of times .. and every time send mail to particular vendor ..
        Loop at vendors.
         call the form ...
         send mail ...
        endloop ...
    Regards,
    Srini.

  • 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'.

  • How to save sap script output in  pdf document

    hi abapers
    how to save the output of sap script in sap so that can retrieve the saved document later.
    i have to save the rcia output from sap script in pdf document in sap so that it can be retrieved later
    how to use dms

    PDF Creation + connection to DMS
    cheers
    Aveek

  • How to save the output of sap script to pdf document in sap

    hi abapers
    how to save the output of sap script in sap so that can retrieve the saved document later.
    i have to save the rcia output from sap script in pdf document in sap so that it can be retrieved later
    how to use dms

    Hi deepika,
    This thread will solve ur problem OTF  -> PDF
    Regards,
    Pravin

  • 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

  • SAP Script to PDF and then Archeiving

    Hi
    Kindly let me know how to convert SAP Script to PDF. And once it is done, archeiving of data is to be done.
    Regards
    Ramesh Sundaram

    Hi,
    Use the code below
    Before OPEN_FORM
    Data: gi_otf TYPE STANDARD TABLE OF itcoo,
             gi_line TYPE TABLE OF tline,
             bin_file TYPE i.
             itcpo-tdgetotf = 'X'.
    After CLOSE_FORM
    CALL FUNCTION 'CONVERT_OTF'
      EXPORTING
        format                = 'PDF'
      IMPORTING
        bin_filesize          = bin_file  
      TABLES
        otf                   = gi_otf
        lines                 = gi_line
      EXCEPTIONS
        err_max_linewidth     = 1
        err_format            = 2
        err_conv_not_possible = 3
        err_bad_otf           = 4
        OTHERS                = 5.
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Regards,
    Manish

  • 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

  • Send the billing output by e-mail for the user

    Hi,
    Can you tell me if it's possible to send the billing output by e-mail (Medium = 5 - External send) for the user that create the billing document? the e-mail of the user is in SU01D.
    Thanks in advance
    Dora

    Hi Dora,
    What you can do is when you want to send a mail to customer after you receive the email for bill is do the following settings.
    1) Create a condition record VV31 with the required Key combination where you can give the name of the Employee or end user with the email id.
    2) Select the trasmission medium as 7 ( Simple Mail)
    3) Once the Billing is done E-Mail will be triggered.
    4) Downlaod it or forward it to your client with the additional text in the E-Mail.
    Hope this helps.
    Thanks and Regards
    Rohit Dujari

  • Conversion of QC21 sap script to pdf

    Hello Experts
    I was working on QC21 sap script layout,got guidance from u guys & i managed to finish.
    now can anyone tell me how to convert the sap script to pdf format?
    Kash

    Hi,
    if u wish to automate the process, then u can write the following code...
    DATA: V_PRINT_PARMS LIKE PRI_PARAMS.
    DATA: V_PDFSPOOLID TYPE TSP01-RQIDENT,
              V_RQIDENT TYPE TSP01-RQIDENT.
    DATA: V_RQ2NAME TYPE STRING.
    DATA: T_PDF LIKE TLINE OCCURS 0 WITH HEADER LINE.
    DATA: T_RSPAR TYPE STANDARD TABLE OF RSPARAMS.
    To Setup The Print Parameters
    CALL FUNCTION 'GET_PRINT_PARAMETERS'
      EXPORTING
        AUTHORITY   = SPACE
        COPIES    = '1'
        COVER_PAGE    = SPACE
        DATA_SET     = SPACE
        DEPARTMENT      = SPACE
        DESTINATION    = SPACE
        EXPIRATION     = '1'
        IMMEDIATELY     = SPACE
        LAYOUT     = SPACE
        MODE       = SPACE
        NEW_LIST_ID    = 'X'
        NO_DIALOG      = 'X'
        USER     = SY-UNAME
      IMPORTING
        OUT_PARAMETERS     = V_PRINT_PARMS.
    IF SY-SUBRC EQ 0.
    Submit Program & Store Spool ID Into Memory
    CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
        EXPORTING
          CURR_REPORT     = 'RQCAAP01'
        TABLES
          SELECTION_TABLE = T_RSPAR.
    ENDIF.
    SUBMIT RQCAAP01 VIA SELECTION-SCREEN TO SAP-SPOOL WITHOUT SPOOL DYNPRO
               SPOOL PARAMETERS V_PRINT_PARMS
               WITH SELECTION-TABLE T_RSPAR
               AND RETURN.
    Retrieving Spool ID From TSP01 Table
    CONCATENATE V_RQ2NAME SY-UNAME INTO V_RQ2NAME.
    SELECT * FROM TSP01
    WHERE RQ2NAME EQ V_RQ2NAME ORDER BY RQCRETIME DESCENDING.
      V_RQIDENT = TSP01-RQIDENT.
      EXIT.
    ENDSELECT.
    IF SY-SUBRC NE 0.
      CLEAR V_RQIDENT.
    ENDIF.
    To Convert Spool ID To PDF Format
    CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
      EXPORTING
        SRC_SPOOLID              = V_RQIDENT
      TABLES
        PDF                      = T_PDF.
    IF SY-SUBRC EQ 0.
    To Download The File In PDF Format
    to get file name and location for saving
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
        EXPORTING
          WINDOW_TITLE         = 'Select The Path Where The PDF Should Be Saved'
          DEFAULT_FILE_NAME    = 'Certificate Of Analysis.PDF'
        CHANGING
          FILENAME             = v_filename
          PATH                 = v_filepath
          FULLPATH             = v_fullpath.
    To download the PDF file
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          FILENAME                = v_fullpath
          FILETYPE                = 'BIN'
        TABLES
          DATA_TAB                = T_PDF.
    ENDIF.
    I hope this resolves ur issue...
    Regards,
    Radhika

  • SAP Script output extra page is coming

    Dear friends
                             In my sap script output i m getting one extra page with empty main window. Even i have  not used NEW-PAGE Command,
    No Empty lines and window size also correct. Can anyone solute for this issue.
    Regards
    Balamurugan N

    Hi,
    check those details:
    1) In your SAPSCRIPT contains one page or two pages?
    2) In the sapscript check did u assign any nextpage as different page?
    Regards,
    Dhina..

Maybe you are looking for

  • Unable to Delete  init request

    HI ALL, i have a delta laod infoapckage, i tried init w/o data tranfer. request  generated with '0' in the data target tab tab. tried making it green and activate, i tried making it red and delete.. but its not getting deleted.. under update tab delt

  • IBooks Author v. Keynote for digital timeline--URGENT

    I have been working on a digital timeline project that will be viewed on an ipad in a museum that a visitor can scroll through and also see on a large screen above the kiosk. I have gone back and forth on the best application to use for this project

  • So... Can I buy MBP now?

    Hello everyone, So, I have made up my mind and decided to invest into newly 2.16GHz, 1GB RAM, 256VRAM, 100GB MBP (this is not a built-to-order, but a stock one from the Apple store). I will go to buy it sometimes next month. And after days and hours

  • RPRAPA00 program deletion flag update issue

    Hi, I am stuck up with a specific company code whose deletion flag is updated for UPDATE variant(05001UDEMPVEN) when I execute PRAA tcode (or program RPRAPA00 ) and program writes to a file with the following contents: 2BLFB1                        

  • Leopard logic pro 8 3rd party plugins

    Hey all, are all 3rd Party Plugins working in Leopard??