Submit Report as an attachement Excel via mail

Hi,
I want to send an email with the result of report O4B1 as attachment Excel with columns separated in Excel.
Best regards.

REPORT  YJAJUR_EMAILOPTIONS                     .
tables: kna1.
data: begin of it_kna1 occurs 0," with header line,
      kunnr like kna1-kunnr,
      land1 like kna1-land1,
      name1 like kna1-name1,
      end of it_kna1.
data: w_sender like somlreci1-receiver.
CONSTANTS:
con_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
con_cret TYPE c VALUE cl_abap_char_utilities=>cr_lf.
data: it_mess_att like solisti1 occurs 0 with header line,
        gd_attachment_desc type sopcklsti1-obj_descr.
data: gd_subject   like sodocchgi1-obj_descr,
      it_mess_bod like solisti1 occurs 0 with header line,
      gd_sender_type     like soextreci1-adr_typ,
       gd_attachment_name type so_obj_des.
select-options: p_email for w_sender no intervals.
PARAMETER mailid TYPE adr6-smtp_addr NO-DISPLAY.
data : it_kna2 type kna1 occurs 0 with header line.
  select kunnr
         land1
         name1
         from kna1 into table it_kna1 .
   select * from kna1 into table it_kna2.
   concatenate 'EMSIL OPTIONS DONE BY sANTOSH.s.jAJU' 'MODEL WISE upto' Into gd_attachment_desc separated by space.
concatenate  'Custmer' 'custmer name' 'custmer land1'      con_tab into
it_mess_att separaTED BY con_tab.
CONCATENATE con_cret it_mess_att INTO it_mess_att.
   APPEND it_mess_att.
   CLEAR it_mess_att.
*loop at p_email.
*endloop.
data: i1 type string.
perform email.
loop at p_email.
i1 = i1 + 1.
concatenate 'email' ':' i1 space p_email-low into it_mess_bod.
it_mess_bod = p_email-low..
APPEND it_mess_bod.
clear it_mess_bod.
perform send_mail.
endloop.
perform display_data..
*&      Form  email
      text
-->  p1        text
<--  p2        text
FORM email .
loop at it_kna2.
      concatenate con_cret  it_kna2-kunnr con_tab
                it_kna2-name1 con_tab it_kna2-land1 into it_mess_att.
        APPEND it_mess_att.
   CLEAR it_mess_att.
endloop.
ENDFORM.                    " email
*&      Form  send_mail
      text
-->  p1        text
<--  p2        text
FORM send_mail .
DATA: send_request  TYPE REF TO cl_bcs,
      document      TYPE REF TO cl_document_bcs,
      recipient     TYPE REF TO cl_cam_address_bcs,
      bcs_exception TYPE REF TO cx_bcs,
      sent_to_all   TYPE os_boolean,
      lt_tab        TYPE TABLE OF makt,
      lt_fields     TYPE TABLE OF w3fields,
      lt_html       TYPE TABLE OF w3html.
data: ld_error    type sy-subrc,
        ld_reciever type sy-subrc,
        ld_mtitle like sodocchgi1-obj_descr,
        ld_email like  somlreci1-receiver,
        ld_format type  so_obj_tp ,
        ld_attdescription type  sopcklsti1-obj_descr,
        ld_attfilename type  so_obj_des ,
        ld_sender_address like  soextreci1-receiver,
        ld_sender_address_type like  soextreci1-adr_typ,
        ld_receiver like  sy-subrc.
  data:   t_packing_list like sopcklsti1 occurs 0 with header line,
          t_contents like solisti1 occurs 0 with header line,
          t_receivers like somlreci1 occurs 0 with header line,
          t_attachment like solisti1 occurs 0 with header line,
          t_object_header like solisti1 occurs 0 with header line,
          w_cnt type i,
          w_sent_all(1) type c,
          w_doc_data like sodocchgi1.
MOVE P_EMAIL TO MAILID.
SELECT * FROM makt UP TO 10 ROWS INTO TABLE lt_tab WHERE spras = 'E'.
CALL FUNCTION 'WWW_ITAB_TO_HTML'
  TABLES
    html   = lt_html[]
    fields = lt_fields
    itable = lt_tab.
TRY.
    send_request = cl_bcs=>create_persistent( ).
    document = cl_document_bcs=>create_document(  i_type    = 'HTM'
                                                  i_text    = lt_html
                                                  i_subject = 'Table' ).
    send_request->set_document( document ).
    recipient = cl_cam_address_bcs=>create_internet_address( MAILID ).
    send_request->add_recipient( EXPORTING i_recipient = recipient
                                           i_express   = 'X' ).
    send_request->set_send_immediately( 'X' ).
    send_request->send( EXPORTING i_with_error_screen = 'X'
                        RECEIVING result              = sent_to_all ).
    COMMIT WORK.
  CATCH cx_bcs INTO bcs_exception.
    EXIT.
ENDTRY.
  ld_email   = p_email-low.
  ld_mtitle = gd_attachment_desc.
  ld_format              = 'XLS'.
  ld_attdescription      = gd_attachment_desc.
  concatenate gd_attachment_desc '.XLS' into ld_attfilename.
ld_attfilename         = p_filename.
  ld_sender_address      = w_sender.
ld_sender_address_type = 'INT'.
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_mess_att index 1.
  w_doc_data-doc_size =  ( w_cnt - 1 ) * 255 + strlen( it_mess_att ).
  w_doc_data-obj_langu  = sy-langu.
  w_doc_data-obj_name   = 'SAPRPT'.
  w_doc_data-obj_descr  = gd_attachment_desc.
  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_mess_bod 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 it_mess_att 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               = it_mess_att
      contents_txt               = it_mess_bod
      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.
  wait up to 5 seconds.
  submit rsconn01 with mode   = 'INT'
                  with output = 'X'
                  and return.
ENDFORM.                    " send_mail
*&      Form  display_data
      text
-->  p1        text
<--  p2        text
FORM display_data .
loop at it_kna2.
     write:/ it_kna2-kunnr,it_kna2-land1,it_kna2-name1.
endloop.
ENDFORM.                    " display_data
ref this code i guess this will works

Similar Messages

  • Submit Report as an attachement Excel via mail using planified job SM37

    Hi,
    I'm executing a program in background via job to get back the result of a report as an attachment XLS on mail.
    the result of my program give me just title of Excel columns , but when i execute it manually , the result is perfect.
    my code is :
    ******************************FORM MAIL*******************************
    FORM mail.
    CONCATENATE 'Expédition' 'TExp' 'PtOT' 'Crée' 'Crée le' 'St.' 'Déb.
    chargt'
    'Désignation' 'Div.' 'Doc. vente' 'Réceptionnaire' 'Nom1' 'Nom2'
    'Volume' 'UQ' INTO it_mess_att
    SEPARATED BY con_tab.
    CONCATENATE con_cret it_mess_att INTO it_mess_att.
    APPEND it_mess_att.
    CONCATENATE SPACE SPACE INTO it_mess_att
    SEPARATED BY con_tab.
    CONCATENATE con_cret it_mess_att INTO it_mess_att.
    APPEND it_mess_att.
    *CLEAR it_mess_att.
    LOOP AT it_tab into wa_tab.
    *VAL = it_tab-ZQTEMAX.
    CONCATENATE wa_tab-SHNUMBER wa_tab-SHTYPE
    wa_tab-TPLST wa_tab-CRE_NAME
    wa_tab-CRE_DATE wa_tab-OIG_SSTSF
    wa_tab-LOAD_STDTA wa_tab-VMODE_TEXT
    wa_tab-WERKS wa_tab-VBELN
    wa_tab-KUNNR wa_tab-NAME1
    wa_tab-CARRIER_DE
    wa_tab-WGT_UOM INTO it_mess_att
    SEPARATED BY con_tab.
    CONCATENATE con_cret it_mess_att INTO it_mess_att.
    APPEND it_mess_att.
    *CLEAR it_mess_att.
    ENDLOOP.
    ENDFORM.
    *************************FORM SEND_MAIL*******************************
    FORM send_mail .
    DATA: send_request TYPE REF TO cl_bcs,
    document TYPE REF TO cl_document_bcs,
    recipient TYPE REF TO cl_cam_address_bcs,
    bcs_exception TYPE REF TO cx_bcs,
    sent_to_all TYPE os_boolean,
    lt_fields TYPE TABLE OF w3fields,
    lt_html TYPE TABLE OF w3html.
    DATA: ld_error TYPE sy-subrc,
    ld_reciever TYPE sy-subrc,
    ld_mtitle LIKE sodocchgi1-obj_descr,
    ld_email LIKE somlreci1-receiver,
    ld_format TYPE so_obj_tp , ld_attdescription TYPE sopcklsti1-obj_descr,
    ld_attfilename TYPE so_obj_des , ld_sender_address LIKE
    soextreci1-receiver, ld_sender_address_type LIKE soextreci1-adr_typ,
    ld_receiver LIKE sy-subrc.
    DATA: t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
    t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
    t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    t_object_header LIKE solisti1 OCCURS
    0 WITH HEADER LINE, w_cnt TYPE i,
    w_sent_all(1) TYPE c, w_doc_data LIKE sodocchgi1.
    *MOVE p_email TO mailid.
    ***************ADD ADRESS MAIL**************
    p_email1-RECEIVER = mail .
    append p_email1.
    ld_email = mail.
    ld_mtitle = gd_attachment_desc.
    ld_format = 'XLS'.
    ld_attdescription = gd_attachment_desc.
    ld_attdescription = 'Liste expéditions PN'.
    CONCATENATE ld_attdescription '.XLS' INTO ld_attfilename.
    ld_attfilename = p_filename.
      ld_sender_address = w_sender.
      ld_sender_address_type = 'INT'.
    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_mess_att INDEX 1.
      w_doc_data-doc_size = ( w_cnt - 1 ) * 255 + STRLEN( it_mess_att ).
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name = 'SAPRPT'.
      w_doc_data-obj_descr = gd_attachment_desc.
      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_mess_bod 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 it_mess_att 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.
      loop at p_email1.
      t_receivers-receiver = p_email1-receiver.
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
      endloop.
      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 = it_mess_att
            contents_txt = it_mess_bod
            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.
      WAIT UP TO 5 SECONDS.
      SUBMIT rsconn01 WITH mode = 'INT' WITH output = 'X' AND RETURN.
    ENDFORM. " send_mail

    Hi,
    I'm executing a program in background via job to get back the result of a report as an attachment XLS on mail.
    the result of my program give me just title of Excel columns , but when i execute it manually , the result is perfect.
    my code is :
    ******************************FORM MAIL*******************************
    FORM mail.
    CONCATENATE 'Expédition' 'TExp' 'PtOT' 'Crée' 'Crée le' 'St.' 'Déb.
    chargt'
    'Désignation' 'Div.' 'Doc. vente' 'Réceptionnaire' 'Nom1' 'Nom2'
    'Volume' 'UQ' INTO it_mess_att
    SEPARATED BY con_tab.
    CONCATENATE con_cret it_mess_att INTO it_mess_att.
    APPEND it_mess_att.
    CONCATENATE SPACE SPACE INTO it_mess_att
    SEPARATED BY con_tab.
    CONCATENATE con_cret it_mess_att INTO it_mess_att.
    APPEND it_mess_att.
    *CLEAR it_mess_att.
    LOOP AT it_tab into wa_tab.
    *VAL = it_tab-ZQTEMAX.
    CONCATENATE wa_tab-SHNUMBER wa_tab-SHTYPE
    wa_tab-TPLST wa_tab-CRE_NAME
    wa_tab-CRE_DATE wa_tab-OIG_SSTSF
    wa_tab-LOAD_STDTA wa_tab-VMODE_TEXT
    wa_tab-WERKS wa_tab-VBELN
    wa_tab-KUNNR wa_tab-NAME1
    wa_tab-CARRIER_DE
    wa_tab-WGT_UOM INTO it_mess_att
    SEPARATED BY con_tab.
    CONCATENATE con_cret it_mess_att INTO it_mess_att.
    APPEND it_mess_att.
    *CLEAR it_mess_att.
    ENDLOOP.
    ENDFORM.
    *************************FORM SEND_MAIL*******************************
    FORM send_mail .
    DATA: send_request TYPE REF TO cl_bcs,
    document TYPE REF TO cl_document_bcs,
    recipient TYPE REF TO cl_cam_address_bcs,
    bcs_exception TYPE REF TO cx_bcs,
    sent_to_all TYPE os_boolean,
    lt_fields TYPE TABLE OF w3fields,
    lt_html TYPE TABLE OF w3html.
    DATA: ld_error TYPE sy-subrc,
    ld_reciever TYPE sy-subrc,
    ld_mtitle LIKE sodocchgi1-obj_descr,
    ld_email LIKE somlreci1-receiver,
    ld_format TYPE so_obj_tp , ld_attdescription TYPE sopcklsti1-obj_descr,
    ld_attfilename TYPE so_obj_des , ld_sender_address LIKE
    soextreci1-receiver, ld_sender_address_type LIKE soextreci1-adr_typ,
    ld_receiver LIKE sy-subrc.
    DATA: t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
    t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
    t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    t_object_header LIKE solisti1 OCCURS
    0 WITH HEADER LINE, w_cnt TYPE i,
    w_sent_all(1) TYPE c, w_doc_data LIKE sodocchgi1.
    *MOVE p_email TO mailid.
    ***************ADD ADRESS MAIL**************
    p_email1-RECEIVER = mail .
    append p_email1.
    ld_email = mail.
    ld_mtitle = gd_attachment_desc.
    ld_format = 'XLS'.
    ld_attdescription = gd_attachment_desc.
    ld_attdescription = 'Liste expéditions PN'.
    CONCATENATE ld_attdescription '.XLS' INTO ld_attfilename.
    ld_attfilename = p_filename.
      ld_sender_address = w_sender.
      ld_sender_address_type = 'INT'.
    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_mess_att INDEX 1.
      w_doc_data-doc_size = ( w_cnt - 1 ) * 255 + STRLEN( it_mess_att ).
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name = 'SAPRPT'.
      w_doc_data-obj_descr = gd_attachment_desc.
      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_mess_bod 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 it_mess_att 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.
      loop at p_email1.
      t_receivers-receiver = p_email1-receiver.
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
      endloop.
      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 = it_mess_att
            contents_txt = it_mess_bod
            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.
      WAIT UP TO 5 SECONDS.
      SUBMIT rsconn01 WITH mode = 'INT' WITH output = 'X' AND RETURN.
    ENDFORM. " send_mail

  • Report to send a List via mail

    Hi everybody,
    at the moment we hava a report which we have to start every day to generate a customer List. Via SAP Office we can send this list via email to a specific person. Now I like to automate this report and start it as a job which automativly send this list via mail.
    Do you have an idea how this will work?
    Thanks a lot for your help.
    Kind regards
    Christian

    Hi Christian.
    You could put the lines of your list in a table of type SOLISTI1 and then use the function module SO_NEW_DOCUMENT_SEND_API1 to send the content of this table. You have to fill the table RECEIVERS with the address you want to send the report to.
    Hope that helps,
    Timo.

  • How to send ALV list report as html attachment in a mail??

    Hi all,
    I have an ALV report which I want to send as an HTML attachment in a mail to an external id. I know that spool can be converted to HTML attachment in a mail. But I don't want to have 2 programs - one for generating ALV and the other to send mail with the spool-converted of the first report as attachment. I want to send the mail in the same program itself. Is it possible? Helpful answers will be suitably rewarded.

    Hi Sandip,
    In your ALV program after the alv output is build in the program do the following steps.
    1). Export the list to memory
    2). Import the list from mempry
    3). Do a COmpress of the data
    4). Send an email as an attachment using the normal FM.
    Take a look at the following links which will explain how to do the above steps.
    http://www.geocities.com/mpioud/Z_EMAIL_ABAP_REPORT.html
    http://www.thespot4sap.com/Articles/SAP_Mail_SO_Object_Send.asp
    http://www.sapdevelopment.co.uk/reporting/email/attach_xls.htm
    remember to change the doc type as 'HTM' in the FM to send email.
    Cheers
    VJ

  • Error while opening PDF attachment sent via mail

    Hi,
    I am attaching PDF file to PO in me22n and sending the same file as attachment in the mail to the vendor using class CL_BCS.
    The mail is sent to the vendor successfully and they are able to successfully open the PDF attachment. But in some cases the mail is successfully received but while opening the attachment it is giving the error as file is corrupted.
    Please help me to resolve this issue.
    Thanks and regards,
    Jayashree

    Hi,
    I would like to know what font type, you are using in the forms.
    Ideally it should be HELVETICA .
    If you are using any other font in your style/form,try changing it to HELVETICA & Test.
    Also Check the OTF data at the call of gen. FM,before converting it to PDF.
    Regds,
    AS
    Edited by: abheesawant on Oct 12, 2011 7:48 AM

  • Report output to be sent via mail

    Hi Experts,
    I want to send my customized ABAP report output to an email address (e.g my own email ID) as I need to send to the vendor (who doesn't have SAP access) as per the requirement.
    Can you please let me know is there any transaction or any other way with the help of which i can just input this report name and the email Id and then it will automatically send the output of the report to that email id.
    Thanks in advance.
    Any helpful entry will be rewarded.
    Warm regards,
    Raman.

    You might want to write a small program that retrieves your spool information, and send the corresponding ALV (internal table) by converting it and sending it via SAP Connect. Here is a sample of hos to attach and send your internal table:
    FORM send_file .
      DATA: send_request       TYPE REF TO cl_bcs,
            text               TYPE bcsy_text,
            document           TYPE REF TO cl_document_bcs,
            recipient          TYPE REF TO if_recipient_bcs,
            copy               TYPE ad_smtpadr,
            bcs_exception      TYPE REF TO cx_bcs,
            sent_to_all        TYPE os_boolean,
            att_name           TYPE sood-objdes,
            subject            TYPE so_obj_des.
    Get attachment name
      CONCATENATE g_ret_id '_' sy-datum sy-uzeit '_' g_fileid '.CSV' INTO
      att_name.
      TRY.
    Create the send request
          send_request = cl_bcs=>create_persistent( ).
    Create the document with attachments
    Main document
            APPEND 'Attachment test' TO text.
          document = cl_document_bcs=>create_document(
                        i_type    = 'RAW'
                        i_text    = text
                        i_subject = subject ).
    Add text attachment to document
          document->add_attachment( i_attachment_type    = 'CSV'
                                    i_attachment_subject = att_name
                                    i_att_content_text   = itab_file ).
          send_request->set_document( document ).
    Create recipient and add to send request
          LOOP AT itab_recipients INTO wa_recipients.
            IF wa_recipients-copy IS INITIAL.
              "To recipient
              MOVE wa_recipients-address TO g_rec_send.
              recipient = cl_cam_address_bcs=>create_internet_address(
              g_rec_send ).
              send_request->add_recipient( i_recipient = recipient ).
              CLEAR g_rec_send.
            ELSE.
              "CC
              MOVE wa_recipients-address TO g_rec_send.
              recipient = cl_cam_address_bcs=>create_internet_address(
              g_rec_send ).
              send_request->add_recipient( i_recipient = recipient
                                           i_copy = 'X' ).
              CLEAR g_rec_send.
            ENDIF.
          ENDLOOP.
    Send
          sent_to_all = send_request->send( i_with_error_screen = 'X' ).
          IF sent_to_all = 'X'.
            MESSAGE s022.
          ENDIF.
        CATCH cx_bcs INTO bcs_exception.
          MESSAGE e865 WITH bcs_exception->error_type.
      ENDTRY.
    ENDFORM.                    " send_file
    REPORT TO EMAIL
    ALV output to email
    How to send ALV Grid report to Email?
    Check the code...on http://sap4.com/wiki/index.php?title=ZOUTLOOK
    sending the output of a program through an email
    report output to email
    Sending ABAP Report by email
    Rewards if useful..............
    Minal

  • Fm to attach excel in mail

    Hi,
    can anyone send me the FM which is used to send mail with excel attachment other than 'SO_DOCUMENT_SEND_API'.
    IS there anyother document which illustrates the above?
    Regards,
    Storm.

    Hi,
    Check these FM...
    ISR_FI_SEND_EMAIL
    ISR_FI_SEND_EMAIL_NEW_USER
    SLS_CUST_SEND_EMAIL_TOOL
    ********Reward points ,if useful

  • Submit a transaction O4B1 via job and the result as an attachment Excel

    Hi, I'm executing a program in background via job to get back the result of a report as an attachment XLS on mail. the result of my program give me just title of Excel columns , but when i execute it manually , the result is perfect.
    my code is : ******************************FORM MAIL******************************* FORM mail. CONCATENATE 'Expédition' 'TExp' 'PtOT' 'Crée' 'Crée le' 'St.' 'Déb. chargt' 'Désignation' 'Div.' 'Doc. vente' 'Réceptionnaire' 'Nom1' 'Nom2' 'Volume' 'UQ' INTO it_mess_att SEPARATED BY con_tab. CONCATENATE con_cret it_mess_att INTO it_mess_att. APPEND it_mess_att. CONCATENATE SPACE SPACE INTO it_mess_att SEPARATED BY con_tab. CONCATENATE con_cret it_mess_att INTO it_mess_att. APPEND it_mess_att. *CLEAR it_mess_att. LOOP AT it_tab into wa_tab. *VAL = it_tab-ZQTEMAX. CONCATENATE wa_tab-SHNUMBER wa_tab-SHTYPE wa_tab-TPLST wa_tab-CRE_NAME wa_tab-CRE_DATE wa_tab-OIG_SSTSF wa_tab-LOAD_STDTA wa_tab-VMODE_TEXT wa_tab-WERKS wa_tab-VBELN wa_tab-KUNNR wa_tab-NAME1 wa_tab-CARRIER_DE wa_tab-WGT_UOM INTO it_mess_att SEPARATED BY con_tab. CONCATENATE con_cret it_mess_att INTO it_mess_att. APPEND it_mess_att. *CLEAR it_mess_att. ENDLOOP. ENDFORM. *************************FORM SEND_MAIL******************************* FORM send_mail . DATA: send_request TYPE REF TO cl_bcs, document TYPE REF TO cl_document_bcs, recipient TYPE REF TO cl_cam_address_bcs, bcs_exception TYPE REF TO cx_bcs, sent_to_all TYPE os_boolean, lt_fields TYPE TABLE OF w3fields, lt_html TYPE TABLE OF w3html. DATA: ld_error TYPE sy-subrc, ld_reciever TYPE sy-subrc, ld_mtitle LIKE sodocchgi1-obj_descr, ld_email LIKE somlreci1-receiver, ld_format TYPE so_obj_tp , ld_attdescription TYPE sopcklsti1-obj_descr, ld_attfilename TYPE so_obj_des , ld_sender_address LIKE soextreci1-receiver, ld_sender_address_type LIKE soextreci1-adr_typ, ld_receiver LIKE sy-subrc. DATA: t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE, t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE, t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE, t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE, t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE, w_cnt TYPE i, w_sent_all(1) TYPE c, w_doc_data LIKE sodocchgi1. *MOVE p_email TO mailid. ***************ADD ADRESS MAIL************** p_email1-RECEIVER = mail . append p_email1. ********************************************* ld_email = mail. ld_mtitle = gd_attachment_desc. ld_format = 'XLS'. * ld_attdescription = gd_attachment_desc. ld_attdescription = 'Liste expéditions PN'. CONCATENATE ld_attdescription '.XLS' INTO ld_attfilename. * ld_attfilename = p_filename. ld_sender_address = w_sender. ld_sender_address_type = 'INT'. * 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_mess_att INDEX 1. w_doc_data-doc_size = ( w_cnt - 1 ) * 255 + STRLEN( it_mess_att ). w_doc_data-obj_langu = sy-langu. w_doc_data-obj_name = 'SAPRPT'. w_doc_data-obj_descr = gd_attachment_desc. 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_mess_bod 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 it_mess_att 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. loop at p_email1. t_receivers-receiver = p_email1-receiver. t_receivers-rec_type = 'U'. t_receivers-com_type = 'INT'. t_receivers-notif_del = 'X'. t_receivers-notif_ndel = 'X'. APPEND t_receivers. endloop. 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 = it_mess_att contents_txt = it_mess_bod 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. WAIT UP TO 5 SECONDS. SUBMIT rsconn01 WITH mode = 'INT' WITH output = 'X' AND RETURN. ENDFORM. " send_mail

    good answer

  • Send file as attachment via mail

    Dear All,
    I want to send a report (ALV) as attachment to some mail. I am using SO_NEW_DOCUMENT_SEND_API1. Can you please suggest how can I send mail as attachment. I am able to send ALV report as HTML format. I want to send it as attachment.
    Thanks and regards,
    Atanu

    Hi,
    plz check the below code.
    it sends Excel sheet attachment with the mail using FM 'SO_DOCUMENT_SEND_API1'
    code>>>>>>>>>>>>>>>>>>>>.
    form send_email_with_attachment .
    DATA: l_t_objbin LIKE solisti1 OCCURS 100 WITH HEADER LINE.
      DATA: i_body TYPE soli_tab WITH HEADER LINE.
      DATA: l_t_objtxt  LIKE solisti1   OCCURS 100 WITH HEADER LINE.
      DATA: l_t_objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
      DATA: l_t_objhead LIKE solisti1   OCCURS 1 WITH HEADER LINE.
      DATA: l_t_reclist LIKE somlreci1  OCCURS 5 WITH HEADER LINE.
      DATA: w_tabln TYPE i .              "for number of table lines
      DATA: w_line        TYPE so_text255.       " Line of text
      DATA: l_doc_chng  LIKE sodocchgi1.
      DATA: l_tab_lines LIKE sy-tabix.
      DATA: l_att_lines TYPE i.
      DATA: lv_lines  TYPE i.
      DATA : BEGIN OF wa_mrpnm,
               werks TYPE ZCSVT024D-werks,
               dispo TYPE ZCSVT024D-dispo,
               name_first TYPE ZCSVT024D-name_first,
               name_last  TYPE ZCSVT024D-name_last,
             END OF wa_mrpnm,
             l_i_mrpnm LIKE STANDARD TABLE OF wa_mrpnm.
      DATA : l_name TYPE string.
    *Used for delimiting the columns in Excel Sheet.
      CLASS cl_abap_char_utilities DEFINITION LOAD.
      CONSTANTS:
      cr_mark(2) TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
      constants c_l_newline type ABAP_CHAR1 value %_NEWLINE. "#EC NOTEXT
      CLEAR : l_t_objpack,
      l_t_objhead,
      l_t_objbin,
      l_t_objtxt,
      l_t_reclist.
      REFRESH: l_t_objpack,
      l_t_objhead,
      l_t_objbin,
      l_t_objtxt,
      l_t_reclist.
    Creating the content of the e-mail message text
      IF sy-sysid(1) = 'P'.
        IF p_order = 'X'.
         l_doc_chng-obj_name   = 'Subcontracting Setup Report'(m02).
          CONCATENATE 'Details of Orders Extract'(028) 'for Plant'(029)
                       p_werks
                       INTO l_doc_chng-obj_descr SEPARATED BY space.
          l_doc_chng-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( l_t_objtxt ).
        ELSE.
         l_doc_chng-obj_name   = 'TEST ONLY!! SC Setup Report'(m03).
          CONCATENATE 'Details of Forecast Extract'(030) 'for Plant'(029)
                       p_werks
                       INTO l_doc_chng-obj_descr SEPARATED BY space.
          l_doc_chng-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( l_t_objtxt ).
        ENDIF.
      ELSE.
        IF p_order = 'X'.
         l_doc_chng-obj_name   = 'Subcontracting Setup Report'(m02).
          CONCATENATE 'Details of Orders Extract'(028) 'for Plant'(029)
                       p_werks 'TEST TEST TEST'
                       INTO l_doc_chng-obj_descr SEPARATED BY space.
          l_doc_chng-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( l_t_objtxt ).
        ELSE.
         l_doc_chng-obj_name   = 'TEST ONLY!! SC Setup Report'(m03).
          CONCATENATE 'Details of Forecast Extract'(030) 'for Plant'(029)
                       p_werks 'TEST TEST TEST'
                       INTO l_doc_chng-obj_descr SEPARATED BY space.
          l_doc_chng-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( l_t_objtxt ).
        ENDIF.
      ENDIF.
      l_t_objtxt = 'Hi,'(036).
      APPEND l_t_objtxt.
      CLEAR l_t_objtxt.
      APPEND l_t_objtxt.
      CONCATENATE 'Please open the attachment to review details of the Report'(031)
                  'for plant'(029) p_werks INTO l_t_objtxt
                   SEPARATED BY space.
      APPEND l_t_objtxt.
      CLEAR l_t_objtxt.
      APPEND l_t_objtxt.
      DESCRIBE TABLE t_ddow LINES sy-tfill .
      IF sy-tfill GT 0 .
        MOVE 'These Materials have been marked as DDOW materials.'(032)
                TO l_t_objtxt.
        APPEND l_t_objtxt.
        CLEAR l_t_objtxt.
        APPEND l_t_objtxt.
        APPEND l_t_objtxt.
        APPEND l_t_objtxt.
        CONCATENATE 'Note! - This is an automatically generated email by the'(034)
                         'SAP system. Pls do not reply to the sender.'(035)
                   INTO  l_t_objtxt
                   SEPARATED BY space.
        APPEND l_t_objtxt.
        DESCRIBE TABLE l_t_objtxt LINES l_tab_lines.
        READ TABLE l_t_objtxt INDEX l_tab_lines.
       l_doc_chng-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( l_t_objtxt )
      Creating the entry for the email text in the packing list
        CLEAR l_t_objpack-transf_bin.
        l_t_objpack-head_start = 1.
        l_t_objpack-head_num = 1.
        l_t_objpack-body_start = 1.
        l_t_objpack-body_num = l_tab_lines.
        l_t_objpack-doc_type = 'RAW'.
        lv_lines = l_tab_lines.
        APPEND l_t_objpack.
    Columns Heading for Excel Attachment.
        CONCATENATE  'MRP Controller'(044)
                     'MRP Name'(047)
                     'Material'(037)
                     'Plant'(026)
                     'PP Cal'(038)
                     'Ship Date'(009)
                     'PO Number'(014)
                     'PO Line'(033)
                     'PP Text'(041)
             INTO i_body
            SEPARATED BY cr_mark.
        concatenate ' ' i_body into i_body separated by c_l_newline.
        APPEND i_body TO l_t_objtxt.
        CLEAR i_body.
      Get MRP Names
        SELECT werks dispo name_first name_last
          FROM ZCSVT024D
          INTO TABLE l_i_mrpnm
          FOR ALL ENTRIES IN t_ddow
          WHERE werks = t_ddow-werks
            AND dispo = t_ddow-dispo.
        IF sy-subrc = 0.
          SORT l_i_mrpnm by werks dispo.
        ENDIF.
    Data to be shown in Excel Sheet.
        LOOP AT t_ddow INTO w_ddow.
          CLEAR : l_name.
          READ TABLE l_i_mrpnm INTO wa_mrpnm WITH KEY werks = w_ddow-werks
                                                      dispo = w_ddow-dispo
                                                      BINARY SEARCH.
          IF sy-subrc = 0.
            CONCATENATE wa_mrpnm-name_first wa_mrpnm-name_last
              INTO l_name SEPARATED BY space.
          ENDIF.
          CONCATENATE  w_ddow-dispo
                       l_name
                       w_ddow-matnr
                       w_ddow-werks
                       w_ddow-mrppp
                       w_ddow-datum
                       w_ddow-ebeln
                       w_ddow-ebelp
                       w_ddow-pptxt
                INTO i_body
            SEPARATED BY cr_mark.
          concatenate ' ' i_body into i_body separated by c_l_newline.
          APPEND i_body TO l_t_objtxt.
          CLEAR : w_ddow.
        ENDLOOP.
        DESCRIBE TABLE l_t_objtxt LINES l_tab_lines.
        DESCRIBE TABLE l_t_objtxt LINES l_att_lines.
        l_tab_lines = l_tab_lines - lv_lines.
      Creating the entry for attachment in the packing list
      objpack-transf_bin = 'X'.
        lv_lines = lv_lines + 1.
        l_t_objpack-head_start = 2.
        l_t_objpack-head_num = 1.
        l_t_objpack-body_start = lv_lines.
        l_t_objpack-body_num = l_tab_lines.
        l_t_objpack-doc_type = 'XLS'.
        l_t_objpack-obj_name = 'DDOW_Materials'(045).
        l_t_objpack-obj_descr = 'DDOW Marked Materials'(046).
        l_t_objpack-doc_size = l_tab_lines * 255.
        APPEND l_t_objpack.
        lv_lines = l_att_lines.
         **RECEIVERS...
        LOOP AT t_ddow INTO w_ddow.
          REFRESH l_t_reclist .
          CLEAR l_t_reclist.
    * get the MRP controller from table
          READ TABLE t_mrpc INTO w_mrpc WITH KEY werks = p_werks
                                                 dispo = w_ddow-dispo
                                                 BINARY SEARCH .
          IF sy-subrc EQ 0 .
            MOVE: 'X'               TO l_t_reclist-express   ,
                  'U'               TO l_t_reclist-rec_type  ,
                  w_mrpc-smtp_addr  TO l_t_reclist-receiver  .
                  APPEND l_t_reclist.
            EXIT.
          ENDIF.
        ENDLOOP.
      Sending the document
        IF NOT l_t_reclist[] IS INITIAL.
          CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
            EXPORTING
              document_data              = l_doc_chng
              commit_work                = 'X'
            TABLES
              packing_list               = l_t_objpack
              object_header              = l_t_objhead
              contents_bin               = l_t_objbin
              contents_txt               = l_t_objtxt
              receivers                  = l_t_reclist
            EXCEPTIONS
              too_many_receivers         = 1
              document_not_sent          = 2
              operation_no_authorization = 4
              OTHERS                     = 99.
        ENDIF.
        IF sy-subrc <> 0.
    * Do nothing
        ELSE.
          COMMIT WORK AND WAIT.
          MESSAGE s899(8a) WITH 'Email Message sent successfully'."#EC
        ENDIF.
      ENDIF.
    <<<<<<<<<<<<<<<<<<<<<<<
    regards,
    vikas.
    plz reward if helpful..

  • Excel form of SAP-BW reports sending via mail as an attachment

    Hi Friends,
    I want to take your opinion about a scenario....
    We access SAP-BW reports in Enterprise portal, there the user can export the report to excel.
    I wish to know if it is possible that the excel form of this report could automatically be sent as an attachment via mail to the outlook accounts of users on a daily basis. Please let me know how.
    Regards,
    Amit Srivastava

    Hi,
    1st you need to congigure the Precalculation server.Inform BASIS people to do that. After that you can check in RSPRECADMIN T-code. There you can see how many servers are there in active(green light). Save your query as workbook and then distribute that workbook from tools menu. -->it will open it in new window. there you can create new setting and then provide Email-ids in 1st tab, and provide subject line and message in 2nd tab, And finally provide variables in 3rd tab. Finnaly save it and Schedule in background by providing date & time. you can use periodic also.
    Regards
    Pcrao.

  • Send An Internal Table Via Excel File As An Attachment of E-mail

    Hi,
    I've sent my internal table via Excel file as an attachment of email but all records of internal table are in a row of sended excel file.
    How can i send an internal table via excel file , records of internal table for each rows of excel file,as an attachment of email correctly?
    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     "   t_packing_list-doc_type   =  'XLS'.
                contents_bin               = pit_attach " this is a normal internal table.
                contents_txt               = pit_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.

    Hi,
    CLASS CL_ABAP_CHAR_UTILITIES DEFINITION LOAD.
    CONSTANTS:
    CON_TAB TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,
    CON_CRET TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF.
          LOOP AT T_FINAL INTO WA_T_FINAL.
            CONCATENATE WA_T_FINAL-PERNR
                        WA_T_FINAL-NAME
                        WA_T_FINAL-LEVEL
                        WA_T_FINAL-POS
                        WA_T_FINAL-JOB
                        WA_T_FINAL-SECTION
                        WA_T_FINAL-DEPT
                        WA_T_FINAL-GROUP
                        WA_T_FINAL-EX_HEAD
                        WA_T_FINAL-SUPID
                        WA_T_FINAL-SUPNM
                        WA_T_FINAL-FHRNM
                        WA_T_FINAL-VACID
                        WA_T_FINAL-VAC_SECTION
                        WA_T_FINAL-VAC_DEPT
                        WA_T_FINAL-VAC_GROUP
                        WA_T_FINAL-VAC_EX_HEAD
                        WA_T_FINAL-VAC_FHRNM
            INTO T_FINAL3 SEPARATED BY CON_TAB.
            CONCATENATE CON_CRET T_FINAL3 INTO T_FINAL3.
            APPEND T_FINAL3.
          ENDLOOP.
    *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 = 'REPORT'.
      W_DOC_DATA-OBJ_DESCR = LD_MTITLE . "mail description
      W_DOC_DATA-SENSITIVTY = 'F'.
    *Fill the document data and get size of attachment
      CLEAR W_DOC_DATA.
      READ TABLE T_FINAL1 INDEX W_CNT.
      W_DOC_DATA-DOC_SIZE =
      ( W_CNT - 1 ) * 255 + STRLEN( T_FINAL1 ).
      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[] = PT_FINAL1[].
    *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 1st 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 = 'Application 1'.
      T_PACKING_LIST-OBJ_NAME = 'Application 1'.
      T_PACKING_LIST-DOC_SIZE = T_PACKING_LIST-BODY_NUM * 255.
      APPEND T_PACKING_LIST.
      CLEAR 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.
    Edited by: Rahul Ghosh on Apr 6, 2009 6:42 AM

  • ALV Report to be send as a mail as an Excel sheet attachment

    Hi,
             I have designed a Report that has the mailing functionality by attaching the ALV report output in the Excel sheet.
    1. I am using SUBMITT PROGRAM....EXPORTING MEMORY ID.
              Here  I am retrieving the required ALV report.
    2. I am passing of ALV Report output to internal table, say XLS_TAB using FM LIST_TO_ASCI.
    I can see the data in the internal table. But the problem is when the report output has many columns (i.e) greater than 255 Char, the columns get truncated(data is missed).
    So, how to prevent the missing of the columns. I don't want split each record into new line. Because, when it is passed to Excel, each record should be in a single line without missing any column.
                   If you say the FM can be valid upto 255 Char, what can be the alternative solution?
    Immediate response is appreciated.
    Thanks for your help.
    Sravan.

    Hi deepan
    DESCRIBE TABLE objtxt LINES tab_lines.
      READ TABLE objtxt INDEX tab_lines.
    docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ) . <---- make it 1024 instead of 255
      CLEAR objpack-transf_bin.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = gv_tab_lines.
    objpack-doc_type = RAW
      APPEND objpack
    then looping contents of the final table to OBJBIN1.
    DESCRIBE TABLE objbin1 LINES tab_lines.
      objpack-doc_size = tab_lines * 255 .    <-------- make it has 1024 instead of 255
      objpack-transf_bin = 'X'.
      objpack-head_start = 1.
      objpack-head_num = 1.
      objpack-body_start = 1.
      objpack-body_num = tab_lines.
      objpack-doc_type = .XLS
      APPEND objpack.
    Regards
    vijay

  • Error to send a report via mail with BI Publisher

    Hello,
    I am working with BIP 10.1.3.4 over Windows Server 2003 Standard Edition, and I would like to send a report via mail.
    I added one Email server navigation via Admin>Delivery Configuration > Email with the server name and host.
    Then Send report via Email, got error.
    oracle.apps.xdo.service.delivery.DeliveryException: oracle.apps.xdo.delivery.DeliveryException: smtp
         at oracle.apps.xdo.service.delivery.impl.DeliveryServiceImpl.deliverToEmail(DeliveryServiceImpl.java:228)
         at oracle.apps.xdo.servlet.scheduler.XDOJob.deliver(XDOJob.java:1190)
         at oracle.apps.xdo.servlet.scheduler.XDOJob.execute(XDOJob.java:478)
         at org.quartz.core.JobRunShell.run(JobRunShell.java:195)
         at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
    Caused by: oracle.apps.xdo.delivery.DeliveryException: smtp
         at oracle.apps.xdo.delivery.smtp.SMTPDeliveryRequestHandler.submitRequest(Unknown Source)
         at oracle.apps.xdo.delivery.AbstractDeliveryRequest.submit(Unknown Source)
         at oracle.apps.xdo.service.delivery.impl.DeliveryServiceImpl.deliverToEmail(DeliveryServiceImpl.java:222)
         ... 4 more
    Caused by: javax.mail.NoSuchProviderException: smtp
         at javax.mail.Session.getService(Session.java:764)
         at javax.mail.Session.getTransport(Session.java:689)
         at javax.mail.Session.getTransport(Session.java:632)
         at javax.mail.Session.getTransport(Session.java:612)
         ... 7 more
    I have followed this SR, and I applied the solution, but it isn't solved the issue (ID: 1072742.1)
    https://support.oracle.com/CSP/ui/flash.html#tab=KBHome%28page=KBHome&id=%28%29%29,%28page=KBNavigator&id=%28from=BOOKMARK&viewingMode=1143&bmDocTitle=BI%20Publisher%20With%20JDE%20Fails%20To%20Send%20Email,%20Error:%20javax.mail.NoSuchProviderException:&bmDocID=1072742.1&bmDocType=PROBLEM&bmDocDsrc=KB%29%29
    Regards,
    Mónica.

    Hi Christian.
    You could put the lines of your list in a table of type SOLISTI1 and then use the function module SO_NEW_DOCUMENT_SEND_API1 to send the content of this table. You have to fill the table RECEIVERS with the address you want to send the report to.
    Hope that helps,
    Timo.

  • To Send HTML Format and excel file attachment  in same mail

    Dear All,
            Have requerment ,to send a mail options HTML table format and same data in excel file attachement.have capable to do the html format using methods BCS .but how to send excel format attachment in same  mail.
    Please guide me how to do it.
    Regards ,
    Santhu
    Edited by: santosh jajur on Apr 9, 2010 1:54 PM

    Santhosh,
    please check the code:
    report bcs_example_7.
    This report provides an example for sending an Excel
    attachment in Unicode Systems
    constants:
      gc_tab  type c value cl_bcs_convert=>gc_tab,
      gc_crlf type c value cl_bcs_convert=>gc_crlf.
    parameters:
      mailto type ad_smtpadr
       default 'ur mail id'.                    "#EC *
    data send_request   type ref to cl_bcs.
    data document       type ref to cl_document_bcs.
    data recipient      type ref to if_recipient_bcs.
    data bcs_exception  type ref to cx_bcs.
    data main_text      type bcsy_text.
    data binary_content type solix_tab.
    data size           type so_obj_len.
    data sent_to_all    type os_boolean.
    start-of-selection.
      perform create_content.
      perform send.
    form send.
      try.
          send_request = cl_bcs=>create_persistent( ).
        create document object from internal table with text
          append 'Hello world!' to main_text.                   "#EC NOTEXT
          document = cl_document_bcs=>create_document(
            i_type    = 'RAW'
            i_text    = main_text
            i_subject = 'Test Created By BCS_EXAMPLE_7' ).      "#EC NOTEXT
        add the spread sheet as attachment to document object
          document->add_attachment(
            i_attachment_type    = 'xls'                        "#EC NOTEXT
            i_attachment_subject = 'ExampleSpreadSheet'         "#EC NOTEXT
            i_attachment_size    = size
            i_att_content_hex    = binary_content ).
        add document object to send request
          send_request->set_document( document ).
        --------- add recipient (e-mail address) -----------------------
        create recipient object
          recipient = cl_cam_address_bcs=>create_internet_address( mailto ).
        add recipient object to send request
          send_request->add_recipient( recipient ).
        ---------- send document ---------------------------------------
          sent_to_all = send_request->send( i_with_error_screen = 'X' ).
          commit work.
          if sent_to_all is initial.
            message i500(sbcoms) with mailto.
          else.
            message s022(so).
          endif.
      endtry.
    endform.                    "send
    form create_content.
      data lv_string type string.
      data ls_t100 type t100.
    columns are separated by TAB and each line ends with CRLF
      concatenate 'This Is Just Example Text!'                  "#EC NOTEXT
                  gc_crlf gc_crlf
                  into lv_string.
    header line
      concatenate lv_string
                  'MSGID'    gc_tab
                  'MSGNO'    gc_tab
                  'Language' gc_tab                             "#EC NOTEXT
                  'Text'     gc_crlf                            "#EC NOTEXT
                  into lv_string.
    data lines
      select * from t100 into ls_t100
        where arbgb = 'SO' and msgnr = '182'.
        concatenate lv_string
                    ls_t100-arbgb gc_tab
                    ls_t100-msgnr gc_tab
                    ls_t100-sprsl gc_tab
                    ls_t100-text  gc_crlf
                    into lv_string.
      endselect.
      select * from t100 into ls_t100
        where arbgb = 'SO' and msgnr = '316'.
        concatenate lv_string
                    ls_t100-arbgb gc_tab
                    ls_t100-msgnr gc_tab
                    ls_t100-sprsl gc_tab
                    ls_t100-text  gc_crlf
                    into lv_string.
      endselect.
      try.
          cl_bcs_convert=>string_to_solix(
            exporting
              iv_string   = lv_string
              iv_codepage = '4103'  "suitable for MS Excel, leave empty
              iv_add_bom  = 'X'     "for other doc types
            importing
              et_solix  = binary_content
              ev_size   = size ).
        catch cx_bcs.
          message e445(so).
      endtry.
    endform.                    "create_content
    Thanks.

  • Excel sheet as an attachment to the mail box

    Hi,
    i need to send an excel sheet as an attachement to the outlook mail box..
    is any function module is there which serves my requirement? or if any other way is there pls let me know.
    thanks..

    Here is some sample code.
    report zrich_0001.
    parameters: p_email   type somlreci1-receiver
                                   default [email protected]'.
    data: begin of it001 occurs 0,
          bukrs type t001-bukrs,
          butxt type t001-butxt,
          end of it001.
    data:   imessage type standard table of solisti1 with header line,
            iattach type standard table of solisti1 with header line,
            ipacking_list like sopcklsti1 occurs 0 with header line,
            ireceivers like somlreci1 occurs 0 with header line,
            iattachment like solisti1 occurs 0 with header line.
    start-of-selection.
      select bukrs butxt into table it001 from t001.
    *   Populate table with detaisl to be entered into .xls file
      perform build_xls_data .
    * Populate message body text
      clear imessage.   refresh imessage.
      imessage = 'Please find attached excel file'.
      append imessage.
    * Send file by email as .xls speadsheet
      perform send_email_with_xls tables imessage
                                          iattach
                                    using p_email
                                          'Example Excel Attachment'
                                          'XLS'
                                          'TestFileName'
                                          'CompanyCodes'.
    *      Form  BUILD_XLS_DATA
    form build_xls_data .
      constants: con_cret type x value '0D',  "OK for non Unicode
                 con_tab type x value '09'.   "OK for non Unicode
    *If you have Unicode check active in program attributes thnen you will
    *need to declare constants as follows
    *class cl_abap_char_utilities definition load.
    *constants:
    *    con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
    *    con_cret type c value cl_abap_char_utilities=>CR_LF.
      concatenate 'BUKRS' 'BUTXT'
             into iattach separated by con_tab.
      concatenate con_cret iattach into iattach.
      append  iattach.
      loop at it001.
        concatenate it001-bukrs it001-butxt
               into iattach separated by con_tab.
        concatenate con_cret iattach  into iattach.
        append  iattach.
      endloop.
    endform.
    *      Form  SEND_EMAIL_WITH_XLS
    form send_email_with_xls tables pit_message
                                              pit_attach
                                        using p_email
                                              p_mtitle
                                              p_format
                                              p_filename
                                              p_attdescription.
      data: xdocdata like sodocchgi1,
            xcnt type i.
    * Fill the document data.
      xdocdata-doc_size = 1.
    * Populate the subject/generic message attributes
      xdocdata-obj_langu = sy-langu.
      xdocdata-obj_name  = 'SAPRPT'.
      xdocdata-obj_descr = p_mtitle .
    * Fill the document data and get size of attachment
      clear xdocdata.
      read table iattach index xcnt.
      xdocdata-doc_size =
         ( xcnt - 1 ) * 255 + strlen( iattach ).
      xdocdata-obj_langu  = sy-langu.
      xdocdata-obj_name   = 'SAPRPT'.
      xdocdata-obj_descr  = p_mtitle.
      clear iattachment.  refresh iattachment.
      iattachment[] = pit_attach[].
    * Describe the body of the message
      clear ipacking_list.  refresh ipacking_list.
      ipacking_list-transf_bin = space.
      ipacking_list-head_start = 1.
      ipacking_list-head_num = 0.
      ipacking_list-body_start = 1.
      describe table imessage lines ipacking_list-body_num.
      ipacking_list-doc_type = 'RAW'.
      append ipacking_list.
    * Create attachment notification
      ipacking_list-transf_bin = 'X'.
      ipacking_list-head_start = 1.
      ipacking_list-head_num   = 1.
      ipacking_list-body_start = 1.
      describe table iattachment lines ipacking_list-body_num.
      ipacking_list-doc_type   =  p_format.
      ipacking_list-obj_descr  =  p_attdescription.
      ipacking_list-obj_name   =  p_filename.
      ipacking_list-doc_size   =  ipacking_list-body_num * 255.
      append ipacking_list.
    * Add the recipients email address
      clear ireceivers.  refresh ireceivers.
      ireceivers-receiver = p_email.
      ireceivers-rec_type = 'U'.
      ireceivers-com_type = 'INT'.
      ireceivers-notif_del = 'X'.
      ireceivers-notif_ndel = 'X'.
      append ireceivers.
      call function 'SO_DOCUMENT_SEND_API1'
           exporting
                document_data              = xdocdata
                put_in_outbox              = 'X'
                commit_work                = 'X'
           tables
                packing_list               = ipacking_list
                contents_bin               = iattachment
                contents_txt               = imessage
                receivers                  = ireceivers
           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.
    endform.
    Regards,
    Rich Heilman

Maybe you are looking for

  • Excel file download issue

    Hi Experts, I am downloading an excel file which is stored at the MII server using JSP file. I am using the below code for the same. I am able to download the excel file successfully but when I open the same I get some junk value as content. I mean t

  • Timer works if I set the time before the current one

    Hi, I've got a block that is part of an actionListener that has 4 buttons, anyway I want the timer to execute something exactly at the time I set it.....but in the code that I have it also executes if i set the time before the current time Here's the

  • Help I did not order skype premium

    Please Help!! I did not order skype premium and out of the blue my credit is deducted $20 and a message that it has been purchased???

  • How to configure terminal services in Windows 2012 server to make multiple connection simulteniously

    Hi I am configuring a Windows Server 2012 in a way so that 10 user can access this server through remote desktop connection simultaneously. We have purchased 10 UserCal license for this server. Please guide me step by step ho to configure this server

  • Is Servlet thread safe?

    Hi, I have created a application. All that the application does is that it listens at a predefined port say 8080 and for every request that is made to the application, the request header information is dumped into a file. I have implemented it by cre