Create an Excel and send it as an email

Hi All,
I have an ALV block list which has 4 internal tables appened..
I have displayed the data but i wanted to create an excel and mail it to the users who are intersted.
as there are 4 internal tables displayed in the output how to send all of them into one excel sheet?
Please help.
Thank you,
Suresh.

hi Suresh,
You have to fill an internal table with XML Strings.
[https://www.sdn.sap.com/irj/scn/wiki?path=/display/abap/exportingdatatoExcel-XMLtotherescue]
This Wiki explains how to generate XML String.
data: begin of xml_data occurs 0,
      TDLINE like TLINE-TDLINE,
      end of xml_data.
e.g.
*Fill internal table with xml data
TEXT = '<?xml version="1.0"?>'.
move text to xml_data-tdline. append xml_data.
TEXT = '<?mso-application progid="Excel.Sheet"?>'.
move text to xml_data-tdline. append xml_data.
TEXT = '<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"'.
move text to xml_data-tdline. append xml_data.
TEXT = ' <Worksheet ss:Name="Sheet1">'.
move text to xml_data-tdline. append xml_data.
TEXT = '  <Table ss:ExpandedColumnCount="22" >'.
move text to xml_data-tdline. append xml_data.
TEXT = '  </Table>'.
move text to xml_data-tdline. append xml_data.
TEXT = ' </Worksheet>'.
move text to xml_data-tdline. append xml_data.
TEXT = ' </Workbook>'.
move text to xml_data-tdline. append xml_data.
*Download data into xml file
call function 'GUI_DOWNLOAD'
  exporting
  BIN_FILESIZE                    =
    FILENAME                        = 'C:     est.xml'
    FILETYPE                         = 'ASC'
  APPEND                          = ' '
  WRITE_FIELD_SEPARATOR           = ' '
  HEADER                          = '00'
  TRUNC_TRAILING_BLANKS           = ' '
  WRITE_LF                        = 'X'
  COL_SELECT                      = ' '
  COL_SELECT_MASK                 = ' '
  DAT_MODE                        = ' '
  CONFIRM_OVERWRITE               = ' '
  NO_AUTH_CHECK                   = ' '
  CODEPAGE                        = ' '
  IGNORE_CERR                     = ABAP_TRUE
  REPLACEMENT                     = '#'
  WRITE_BOM                       = ' '
  TRUNC_TRAILING_BLANKS_EOL       = 'X'
  WK1_N_FORMAT                    = ' '
  WK1_N_SIZE                      = ' '
  WK1_T_FORMAT                    = ' '
  WK1_T_SIZE                      = ' '
  WRITE_LF_AFTER_LAST_LINE        = ABAP_TRUE
  SHOW_TRANSFER_STATUS            = ABAP_TRUE
IMPORTING
  FILELENGTH                      =
  TABLES
    DATA_TAB                        = xml_data
  FIELDNAMES                      =
EXCEPTIONS
   FILE_WRITE_ERROR                = 1
   NO_BATCH                        = 2
   GUI_REFUSE_FILETRANSFER         = 3
   INVALID_TYPE                    = 4
   NO_AUTHORITY                    = 5
   UNKNOWN_ERROR                   = 6
   HEADER_NOT_ALLOWED              = 7
   SEPARATOR_NOT_ALLOWED           = 8
   FILESIZE_NOT_ALLOWED            = 9
   HEADER_TOO_LONG                 = 10
   DP_ERROR_CREATE                 = 11
   DP_ERROR_SEND                   = 12
   DP_ERROR_WRITE                  = 13
   UNKNOWN_DP_ERROR                = 14
   ACCESS_DENIED                   = 15
   DP_OUT_OF_MEMORY                = 16
   DISK_FULL                       = 17
   DP_TIMEOUT                      = 18
   FILE_NOT_FOUND                  = 19
   DATAPROVIDER_EXCEPTION          = 20
   CONTROL_FLUSH_ERROR             = 21
   OTHERS                          = 22
if SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
hope this helps!
Monalisa

Similar Messages

  • Create a csv file and send it in an email

    In coldfusion, is it possible to  create a csv file and send it in an email, without ever saving that file on the hard drive?

    Yes, you can create an email attachment without writing a file to disk.  This feature was introduced in CF 8.0.1.
    I've posted a sample to a previous thread on the forums.
    http://forums.adobe.com/message/2123297
    See the CFMAILPARAM section of CF 8.0.1 release notes for attachments without a file on disk.
    http://www.adobe.com/support/documentation/en/coldfusion/801/cf801releasenotes.pdf

  • How to convert script output to excel and send through mail in the report

    I need a solution for Converting script into EXCEL  and sending Excel as a attachment to the mail. In my current Program I am getting OTF data from script and converting into PDF using Function module ' CONVERT_OTF'
    And sending PDF as a mail attachment using Function module 'SO_NEW_DOCUMENT_SEND_API1' it is working fine but
    My current requirement is I need to send Excel as a mail attachment instead of PDF.
    Hope it is clear for you, please give me possible solutions with sample code..

    hi
    good
    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 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
             INTO IT_ATTACH SEPARATED BY CON_TAB.
      CONCATENATE CON_CRET IT_ATTACH  INTO IT_ATTACH.
      APPEND  IT_ATTACH.
      LOOP AT IT_EKPO INTO WA_CHAREKPO.
        CONCATENATE WA_CHAREKPO-EBELN WA_CHAREKPO-EBELP
                    WA_CHAREKPO-AEDAT WA_CHAREKPO-MATNR
               INTO IT_ATTACH SEPARATED BY CON_TAB.  " Check here
        CONCATENATE CON_CRET IT_ATTACH  INTO IT_ATTACH.  " Check here
        APPEND  IT_ATTACH.
      ENDLOOP.
    thanks
    mrutyun^

  • Do not know how to take a saved doc and send it as an email attachment in my gmail account

    how do i take a scanned doc, saved in my doc folder and send it as an email to recipient.
    I get confirmation that it was sent but person says it was not attached

    Hi,
    The following is the program[Click Here| http://saptechnical .com/Tips/ABAP/email/EmailProgram.txt] which will send any format file. Actual Creator of the program is Amit Bisht.
    Thanks & Regards,
    Rock.

  • ı wanna delete my purcahe but it did hide and where is the hidding ı wanna delete my purchase please because I am not looking a few purchase (dowloaded at the apple store) help me and send message to my email thank you have good work.

    ı wanna delete my purchase but it did hide and where is the hidding ı wanna delete my purchase please because I am not looking a few purchase (dowloaded at the apple store) help me and send message to my email thank you have good work.

    what?

  • In Gmail we have two mailboxes mine and my wife's. When I send from my mailbox and when i indicate my mailbox in the 'from' box, it always picks up and sends my wife's email address. Help

    in Gmail we have two mailboxes mine and my wife's. When I send from my mailbox and when i indicate my mailbox in the 'from' box, it always picks up and sends my wife's email address. Help

    I have this exact problem.  I have 3 email addresses on my mac and I can select one, and the email still be sent through another account and I won't know it until I get a reply for that email in one of the other accounts.
    MacBook Pro, Mac OS X 10.9

  • When i go to buy a app or music it tells me to enter verify in me and i dont know it and send it to my email and it does not go to my email?

    when i go to buy a app or music it tells me to enter verify in me and i dont know it and send it to my email and it does not go to my email?

    Try here...
    http://www.apple.com/support/mac/app-store/

  • Convert SAP spoolOR list to excel and send as an email attachment

    Hello All Masterminds ,
      Iu2019ve developed a utility, in which users has to maintain one u201CZu201D view where they can give any report name, type of attachment (PDF, XLS, TXT) and sender email addresses.u201DNote: thing to remember here is Iu2019m creating XLS,TXT,PDF format dynamicallyu201D 
    It is working fine for PDF. Iu2019m submitting the program and creating spool and converting it to PDF and sending to their emails as an attachment.  It looks fantastic. When Iu2019m doing the same thing for XLS it is showing messy output, I tried many functions and search lots of unanswered, unfinished SDN posts. I almost tried every single clue given in these posts but no luck. Email part is working fine using classes (  l_document = cl_document_bcs=>create_document , l_document->add_attachment , l_send_request->set_document( l_document ).,cl_sapuser_bcs=>create( l_uname ).,l_send_request->add_recipient,  l_send_request->set_send_immediately( '' ).  ) .
    My real deal is to create a beautiful XLS out put. I also tried FMs LIST_FROM_MEMORY and LIST_TO_ASCI but no-luck. I thought instead of spool if I use u201CSubmit  EXPORTING LIST TO MEMORY u201C option may be It works but BIG NO 
       Iu2019m sure some genius out there has done something like his , I ain`t genius that is why I am stuck   Please guys throw me some bones .  As I said, I am able to do most of the things. I need some magic code /answer which turns my messy, ugly unformatted excel sheet attachment to beautiful u201Cpiece of art u201CExcel output.
      Here are the FMs I tried so far with different combinations.
    CALL FUNCTION 'LIST_FROM_MEMORY'
    CALL FUNCTION 'LIST_TO_ASCI'
    CALL FUNCTION 'GUI_DOWNLOAD'
    CALL FUNCTION 'RSPO_DOWNLOAD_SPOOLJOB'
    CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
    CALL FUNCTION 'CONVERT_OTF'
    CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
    And logic like to get rid of things getting in Asci tables
    cl_abap_char_utilities=>newline.
    cl_abap_char_utilities=>horizontal_tab
    cl_abap_char_utilities=>VERTICAL_TAB
    cl_abap_char_utilities=>cr_lf
    FIELD-SYMBOLS: <lfs_table>,    " Internal table structure
                     <lfs_con>.      " Field Content
      DATA: l_text TYPE char1024.     " Text content for mail attachment
      DATA: l_con(50) TYPE c.        " Field Content in character format
    Columns to be tab delimeted
      LOOP AT FINAL ASSIGNING <lfs_table>.
        DO.
          ASSIGN COMPONENT sy-index OF STRUCTURE <lfs_table>
                 TO <lfs_con>.
          IF sy-subrc NE 0.
            CONCATENATE c_cr l_text INTO l_text.
            APPEND l_text TO i_attach.
            EXIT.
          ELSE.
            CLEAR: l_con.
            MOVE <lfs_con> TO l_con.
            CONDENSE l_con.
            IF sy-index = 1.
              CLEAR: l_text.
              MOVE l_con TO l_text.
            ELSE.
              CONCATENATE l_text l_con INTO l_text
                 SEPARATED BY c_tab.
            ENDIF.
          ENDIF.
        ENDDO.
      ENDLOOP.
    Posts : https://forums.sdn.sap.com/click.jspa?searchID=14756211&messageID=4401940
    https://forums.sdn.sap.com/click.jspa?searchID=14756211&messageID=4796657
    https://forums.sdn.sap.com/search.jspa?threadID=&q=convertspoolintoexcelformatforsendingmail&objID=c42&dateRange=all&numResults=30&rankBy=10001
    Will appreciate your help and time.
    Thanks,
    Saquib Khan

    Hi,
    i send excel-att like this.
    REPORT Z_EMAIL_CL_BCS MESSAGE-ID ZZ.
    More examples here BCS_EXAMPLE_* with se38
    DATA: SEND_REQUEST       TYPE REF TO CL_BCS.
    DATA: SUBJECT            TYPE SO_OBJ_DES.
    DATA: ATT_TYPE           TYPE SOODK-OBJTP.
    DATA: IT_TEXT            TYPE BCSY_TEXT.
    DATA: WA_TEXT            LIKE SOLI.
    DATA: IT_BIN             TYPE SOLIX_TAB.
    DATA: WA_BIN             TYPE SOLIX.
    DATA: DOCUMENT           TYPE REF TO CL_DOCUMENT_BCS.
    DATA: SENDER             TYPE REF TO CL_SAPUSER_BCS.
    DATA: RECIPIENT          TYPE REF TO IF_RECIPIENT_BCS.
    DATA: BCS_EXCEPTION      TYPE REF TO CX_BCS.
    DATA: SENT_TO_ALL        TYPE OS_BOOLEAN.
    Bytes der Datei
    DATA: IT_LENGHT          TYPE SO_OBJ_LEN.
    DATA: N10(10)            TYPE N.
    CONSTANTS: CON_NEWL TYPE ABAP_CHAR1 VALUE CL_ABAP_CHAR_UTILITIES=>NEWLINE,
               CON_TAB  TYPE ABAP_CHAR1 VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    CONSTANTS: CON_NEWL TYPE X VALUE '0D', "OK for non Unicode
                CON_TAB  TYPE X VALUE '09'. "OK for non Unicode
    START-OF-SELECTION.
      PERFORM MAIN.
    END-OF-SELECTION.
    FORM MAIN.
      TRY.
        -------- create persistent send request ------------------------
          SEND_REQUEST = CL_BCS=>CREATE_PERSISTENT( ).
          PERFORM HEAD_CONT.
          PERFORM XLS_ATT.
        add document to send request
          CALL METHOD SEND_REQUEST->SET_DOCUMENT( DOCUMENT ).
        --------- set sender -------------------------------------------
          SENDER = CL_SAPUSER_BCS=>CREATE( SY-UNAME ).
          CALL METHOD SEND_REQUEST->SET_SENDER
            EXPORTING
              I_SENDER = SENDER.
        --------- set recipent -----------------------------------------
          RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS(
                                            'the email adress' ).
        add recipient with its respective attributes to send request
          CALL METHOD SEND_REQUEST->ADD_RECIPIENT
            EXPORTING
              I_RECIPIENT = RECIPIENT
              I_EXPRESS   = 'X'.
         RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS(
                                           'the email adress 2' ).
        add recipient with its respective attributes to send request
         CALL METHOD SEND_REQUEST->ADD_RECIPIENT
           EXPORTING
             I_RECIPIENT = RECIPIENT
             I_EXPRESS   = 'X'.
        ---------- send document ---------------------------------------
          CALL METHOD SEND_REQUEST->SEND(
            EXPORTING
              I_WITH_ERROR_SCREEN = 'X'
            RECEIVING
              RESULT              = SENT_TO_ALL ).
          COMMIT WORK.
        CATCH CX_BCS INTO BCS_EXCEPTION.
          WRITE: 'Fehler aufgetreten.'(001).
          WRITE: 'Fehlertyp:'(002), BCS_EXCEPTION->ERROR_TYPE.
          EXIT.
      ENDTRY.
    ENDFORM.                    "main
    FORM HEAD_CONT.
      CLEAR: IT_TEXT[], WA_TEXT, SUBJECT.
      ATT_TYPE = 'RAW'.
      CONCATENATE 'Betreffzeile am' SY-DATUM 'um' SY-UZEIT
      INTO SUBJECT SEPARATED BY SPACE.
      WA_TEXT = 'Hello!'.
      APPEND WA_TEXT TO IT_TEXT.
    WA_TEXT = 'dieses ist eine Testmail'.
    APPEND WA_TEXT TO IT_TEXT.
    WA_TEXT = 'Gruß'.
    APPEND WA_TEXT TO IT_TEXT.
      DESCRIBE TABLE IT_TEXT LINES N10.
      N10 = ( N10 - 1 ) * 255 + STRLEN( WA_TEXT ).
      IT_LENGHT = N10.
      DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT(
                I_TYPE    = ATT_TYPE
                I_TEXT    = IT_TEXT
                I_LENGTH  = IT_LENGHT
                I_SUBJECT = SUBJECT ).
    ENDFORM.                    "HEAD_CONT
    FORM XLS_ATT.
      DATA: BEGIN OF ITAB OCCURS 0,
            MATNR     LIKE MARA-MATNR,
            MTART     LIKE MARA-MTART,
            MATKL     LIKE MARA-MATKL,
            BRGEW     LIKE MARA-BRGEW,
          END   OF ITAB.
      DATA: BRGEW(18).
      CLEAR: IT_BIN[], WA_BIN, SUBJECT.
      SELECT MATNR MTART MATKL BRGEW INTO TABLE ITAB FROM MARA UP TO 10 ROWS.
      CONCATENATE 'Material'      CON_TAB
            'Materialart'   CON_TAB
            'Warengruppe'   CON_TAB
            'Bruttogewicht' CON_NEWL
              INTO WA_BIN.
      APPEND WA_BIN TO IT_BIN.
      LOOP AT ITAB.
        WRITE ITAB-BRGEW TO BRGEW.
        CONCATENATE ITAB-MATNR CON_TAB
                    ITAB-MTART CON_TAB
                    ITAB-MATKL CON_TAB
                         BRGEW CON_NEWL
                    INTO WA_BIN.
        APPEND WA_BIN TO IT_BIN.
      ENDLOOP.
      ATT_TYPE = 'XLS'.
      SUBJECT = 'My XLS attachment'.
      DESCRIBE TABLE IT_BIN LINES N10.
      N10 = ( N10 - 1 ) * 255 + STRLEN( WA_BIN ).
      IT_LENGHT = N10.
      CALL METHOD DOCUMENT->ADD_ATTACHMENT
        EXPORTING
          I_ATTACHMENT_TYPE    = ATT_TYPE
          I_ATT_CONTENT_HEX    = IT_BIN
          I_ATTACHMENT_SIZE    = IT_LENGHT
          I_ATTACHMENT_SUBJECT = SUBJECT.
    ENDFORM.                    "XLS_ATT
    Perhaps it helps.
    regards, Dieter

  • How to Convert file to excel and send it via email

    Hi experts.
    Can anyone tell me how to convert a spool data in to excel format and the send it through e-mail......
    We have a function module for converting spool data to pdf and send it through mail ie FM CONVERT_ABAPSPOOLJOB_2_PDF,
    but is there any FM for Excel ....
    Kindly help me.....
    Thanks
    Naveen

    you can send a file as an exel attachment in mail,
    step 1:
       send file data to an internal table.
    step 2:
       loop through the internal table(itab).
        concatinate itab-field1
                          abap_char_utilities=>horizontal tab
                         itab-field2
                         abap_char_utilities=>horizontal tab
                        abap_char_utilities=>vertical tab
            into t_attachment-line
    append t_attachment
    step 3:
    Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.  
      w_doc_data-doc_size =
      ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
    Describe the body of the message
      CLEAR t_packing_list.
      REFRESH t_packing_list.
      t_packing_list-transf_bin = space.
      t_packing_list-head_start = 1.
      t_packing_list-head_num = 0.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE it_message LINES t_packing_list-body_num.
      t_packing_list-doc_type = 'RAW'.
      APPEND t_packing_list.
    Create attachment notification
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num = 1.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
      t_packing_list-doc_type = 'XLS'.
       t_packing_list-doc_size = t_packing_list-body_num * 255.
      t_packing_list-obj_name   = 'Attachment'.
      t_packing_list-obj_descr  = 'mail xls'
      APPEND t_packing_list.
    Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
        MOVE: mail id TO t_receivers-receiver,
        'U' TO t_receivers-rec_type,
        APPEND t_receivers.
      CALL  FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = w_doc_data
          put_in_outbox              = 'X'
          commit_work                = 'X'
        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.
    check the FM and creat the internal table types
    by this way you can send excel as an attachment 
    but problem in sending EXCEL attachment is if the data crosses the limit of excle file the file will not open.

  • Function moduls to create csv-file and send it per mail

    Hello,
    we have the following requirement.
    We created an eventhandler.
    Inside this eventhandler we built up an internal table with 1-n entries.
    Now we want to create a csv-file or excel-file in background and send it to the users mailadress.
    Are there standard function modules which we can use for this requirement.
    We can´t download the file directly to the users client with cl_gui_frontend_services because we are not in SAP GUI but in CRM Webclient UI.
    Thank you
    Best regards
    Manfred

    hello,
    thank you.
    a coding example would be very helpfull.
    the internal table shall be added as csv-attachment to the mail and the recipient shall be the current user.
    Thanks a lot in advance.
    Kind regards
    Manfred

  • Converting alv list  to excel and send to sapoffice or mail in batch mode

    Hi every one.
    I have the alv list and then I can send to sapoffice or mail in batch mode.
    If I open the list in Sapoffice I can save the list in XLS format or if I open the list by mail, I can select all the content (because is a html file), select the copy option and then open EXCEL and paste the content.
    Can I use an option to convert the alv list to an excel format and then send to mail or sapconnect in batch mode?

    if your requirement is to send a Excel sheet by Email then use this sample program.
    *& Report  ZEMAIL_ATTACH                                               *
    *& Example of sending external email via SAPCONNECT                    *
    REPORT  ZEMAIL_ATTACH                   .
    TABLES: ekko.
    PARAMETERS: p_email   TYPE somlreci1-receiver
                                      DEFAULT '[email protected]'.
    TYPES: BEGIN OF t_ekpo,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
    END OF t_ekpo.
    DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,
          wa_ekpo TYPE t_ekpo.
    TYPES: BEGIN OF t_charekpo,
      ebeln(10) TYPE c,
      ebelp(5)  TYPE c,
      aedat(8)  TYPE c,
      matnr(18) TYPE c,
    END OF t_charekpo.
    DATA: wa_charekpo TYPE t_charekpo.
    DATA:   it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE.
    DATA:   it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE.
    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,
            gd_error    TYPE sy-subrc,
            gd_reciever TYPE sy-subrc.
    *START_OF_SELECTION
    START-OF-SELECTION.
      Retrieve sample data from table ekpo
      PERFORM data_retrieval.
      Populate table with detaisl to be entered into .xls file
      PERFORM build_xls_data_table.
    *END-OF-SELECTION
    END-OF-SELECTION.
    Populate message body text
      perform populate_email_message_body.
    Send file by email as .xls speadsheet
      PERFORM send_file_as_email_attachment
                                   tables it_message
                                          it_attach
                                    using p_email
                                          'Example .xls documnet attachment'
                                          'XLS'
                                          'filename'
                                 changing gd_error
                                          gd_reciever.
      Instructs mail send program for SAPCONNECT to send email(rsconn01)
      PERFORM initiate_mail_execute_program.
    *&      Form  DATA_RETRIEVAL
          Retrieve data form EKPO table and populate itab it_ekko
    FORM data_retrieval.
      SELECT ebeln ebelp aedat matnr
       UP TO 10 ROWS
        FROM ekpo
        INTO TABLE it_ekpo.
    ENDFORM.                    " DATA_RETRIEVAL
    *&      Form  BUILD_XLS_DATA_TABLE
          Build data table for .xls document
    FORM build_xls_data_table.
      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 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
             INTO it_attach SEPARATED BY con_tab.
      CONCATENATE con_cret it_attach  INTO it_attach.
      APPEND  it_attach.
      LOOP AT it_ekpo INTO wa_charekpo.
        CONCATENATE wa_charekpo-ebeln wa_charekpo-ebelp
                    wa_charekpo-aedat wa_charekpo-matnr
               INTO it_attach SEPARATED BY con_tab.
        CONCATENATE con_cret it_attach  INTO it_attach.
        APPEND  it_attach.
      ENDLOOP.
    ENDFORM.                    " BUILD_XLS_DATA_TABLE
    *&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
          Send email
    FORM send_file_as_email_attachment tables pit_message
                                              pit_attach
                                        using p_email
                                              p_mtitle
                                              p_format
                                              p_filename
                                              p_attdescription
                                              p_sender_address
                                              p_sender_addres_type
                                     changing p_error
                                              p_reciever.
      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  so_obj_nam ,
            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.
      ld_email   = p_email.
      ld_mtitle = p_mtitle.
      ld_format              = p_format.
      ld_attdescription      = p_attdescription.
      ld_attfilename         = p_filename.
      ld_sender_address      = p_sender_address.
      ld_sender_address_type = p_sender_addres_type.
    Fill the document data.
      w_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name  = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle .
      w_doc_data-sensitivty = 'F'.
    Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.
      w_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
      w_doc_data-obj_langu  = sy-langu.
      w_doc_data-obj_name   = 'SAPRPT'.
      w_doc_data-obj_descr  = ld_mtitle.
      w_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = pit_attach[].
    Describe the body of the message
      CLEAR t_packing_list.
      REFRESH t_packing_list.
      t_packing_list-transf_bin = space.
      t_packing_list-head_start = 1.
      t_packing_list-head_num = 0.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE it_message LINES t_packing_list-body_num.
      t_packing_list-doc_type = 'RAW'.
      APPEND t_packing_list.
    Create attachment notification
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 1.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
      t_packing_list-doc_type   =  ld_format.
      t_packing_list-obj_descr  =  ld_attdescription.
      t_packing_list-obj_name   =  ld_attfilename.
      t_packing_list-doc_size   =  t_packing_list-body_num * 255.
      APPEND t_packing_list.
    Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
      t_receivers-receiver = ld_email.
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
           EXPORTING
                document_data              = w_doc_data
                put_in_outbox              = 'X'
                sender_address             = ld_sender_address
                sender_address_type        = ld_sender_address_type
                commit_work                = 'X'
           IMPORTING
                sent_to_all                = w_sent_all
           TABLES
                packing_list               = t_packing_list
                contents_bin               = t_attachment
                contents_txt               = it_message
                receivers                  = t_receivers
           EXCEPTIONS
                too_many_receivers         = 1
                document_not_sent          = 2
                document_type_not_exist    = 3
                operation_no_authorization = 4
                parameter_error            = 5
                x_error                    = 6
                enqueue_error              = 7
                OTHERS                     = 8.
    Populate zerror return code
      ld_error = sy-subrc.
    Populate zreceiver return code
      LOOP AT t_receivers.
        ld_receiver = t_receivers-retrn_code.
      ENDLOOP.
    ENDFORM.
    *&      Form  INITIATE_MAIL_EXECUTE_PROGRAM
          Instructs mail send program for SAPCONNECT to send email.
    FORM initiate_mail_execute_program.
      WAIT UP TO 2 SECONDS.
      SUBMIT rsconn01 WITH mode = 'INT'
                    WITH output = 'X'
                    AND RETURN.
    ENDFORM.                    " INITIATE_MAIL_EXECUTE_PROGRAM
    *&      Form  POPULATE_EMAIL_MESSAGE_BODY
           Populate message body text
    form populate_email_message_body.
      REFRESH it_message.
      it_message = 'Please find attached a list test ekpo records'.
      APPEND it_message.
    endform.                    " POPULATE_EMAIL_MESSAGE_BODY
    - Guru

  • BPEL process to create a PDF and send it as attachment in SOAP response

    We have a requirement to have a webservice created using BPEL, which can receive input from a client and create a PDF using the input and send the PDF as attachment in the SOAP response.
    We have found the below link in Oracle docs and our basic understanding on the functionality given is that the MIMEService is being used to read a SOAP attachment from some other service and send it as an attachment in the SOAP response to the requester. As explained above, this doesn't completely satisfy our requirement.
    http://docs.oracle.com/cd/E11036_01/integrate.1013/b28981/manipdoc.htm#BABCJIAH
    Please suggest if there is any other approach that suites our requirement.
    Thanks.

    Hi,
    I have a Weblogic webservice which returns me a PDF attachment as resposne ( here I have MIME related stuff).I need to get attachment as bpel response.
    I have created a BPEL process to invoke the weblogic webservice. I have explictly added the MIME part in bpel.wsdl same as weblogic webservice wsdl.
    I tried to assign the response variable( of type base64binary) of bpel.wsdl and my webservice .wsdl . I am getting some error with no attachment.
    Below is my xsd used in BPEL.wsdl*
    <?xml version="1.0" encoding="UTF-8"?>
    <schema attributeFormDefault="unqualified"
         elementFormDefault="qualified"
         targetNamespace="http://xmlns.oracle.com/MIMEApp/test/BPELProcess1"
         xmlns="http://www.w3.org/2001/XMLSchema">
         <complexType name="process">
                   <sequence>
                        <element name="input" type="string"/>
                   </sequence>
         </complexType>
         <complexType name="processResponse">
                   <sequence>
                        <element name="result" type="string"/>
                   </sequence>
         </complexType>
    <complexType name="GetAttachmentPDF">
    <sequence>
    <element minOccurs="0" name="Pdf" nillable="false" type="base64Binary"/>
    </sequence>
    </complexType>
    </schema>
    Below is my BPEL.wsdl*
    <?xml version="1.0" encoding="UTF-8"?>
    <wsdl:definitions name="BPELProcess1"
    targetNamespace="http://xmlns.oracle.com/MIMEApp/test/BPELProcess1"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:client="http://xmlns.oracle.com/MIMEApp/test/BPELProcess1"
    xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/">
    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         TYPE DEFINITION - List of services participating in this BPEL process
         The default output of the BPEL designer uses strings as input and
         output to the BPEL Process. But you can define or import any XML
         Schema type and use them as part of the message types.
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <wsdl:types>
    <schema xmlns="http://www.w3.org/2001/XMLSchema">
    <import namespace="http://xmlns.oracle.com/MIMEApp/test/BPELProcess1"
    schemaLocation="xsd/BPELProcess1.xsd"/>
    </schema>
    </wsdl:types>
    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         MESSAGE TYPE DEFINITION - Definition of the message types used as
         part of the port type defintions
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <wsdl:message name="BPELProcess1RequestMessage">
    <wsdl:part name="payload" type="client:process"/>
    </wsdl:message>
    <wsdl:message name="BPELProcess1ResponseMessage">
    <wsdl:part name="payload" type="client:processResponse"/>
    <wsdl:part name="attachment" type="client:GetAttachmentPDF"/>
    </wsdl:message>
    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         PORT TYPE DEFINITION - A port type groups a set of operations into
         a logical service unit.
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <!-- portType implemented by the BPELProcess1 BPEL process -->
    <wsdl:portType name="BPELProcess1">
    <wsdl:operation name="process">
    <wsdl:input message="client:BPELProcess1RequestMessage"/>
    <wsdl:output message="client:BPELProcess1ResponseMessage"/>
    </wsdl:operation>
    </wsdl:portType>
    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         PARTNER LINK TYPE DEFINITION
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <plnk:partnerLinkType name="BPELProcess1">
    <plnk:role name="BPELProcess1Provider">
    <plnk:portType name="client:BPELProcess1"/>
    </plnk:role>
    </plnk:partnerLinkType>
    <wsdl:binding name="BPELProcess1SOAP11Binding" type="client:BPELProcess1">
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="process">
    <soap:operation style="rpc"
    soapAction="http://xmlns.oracle.com/MIMEApp/test/BPELProcess1/process"/>
    <wsdl:input>
    <soap:body use="literal"
    namespace="http://xmlns.oracle.com/MIMEApp/test/BPELProcess1"/>
    </wsdl:input>
    <wsdl:output>
    <mime:multipartRelated>
    <mime:part>
    <soap:body use="literal"
    namespace="http://xmlns.oracle.com/MIMEApp/test/BPELProcess1"/>
    </mime:part>
    <mime:part>
    <mime:content part="attachment" type="application/pdf"/>
    </mime:part>
    </mime:multipartRelated>
    </wsdl:output>
    </wsdl:operation>
    </wsdl:binding>
    </wsdl:definitions>
    Below is my WL WS WSDL*
    <?xml version="1.0" encoding="UTF-8"?>
    <WL5G3N0:definitions
    name="NewWSDLFile"
    targetNamespace="http://www.example.org/NewWSDLFile/"
    xmlns:WL5G3N5="http://schemas.xmlsoap.org/wsdl/mime/"
    xmlns:WL5G3N4="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:WL5G3N3="http://www.example.org/NewWSDLFile/"
    xmlns:WL5G3N2="java:com.rogers.service"
    xmlns:WL5G3N0="http://schemas.xmlsoap.org/wsdl/"
    xmlns:WL5G3N1="http://www.w3.org/2001/XMLSchema"
    >
    <WL5G3N0:types>
    <xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="java:com.rogers.service"
    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:s="java:com.rogers.service"
    xmlns:s0="http://schemas.xmlsoap.org/wsdl/" xmlns:s1="http://www.w3.org/2001/XMLSchema"
    xmlns:s2="java:com.rogers.service" xmlns:s3="http://www.example.org/NewWSDLFile/"
    xmlns:s4="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s5="http://schemas.xmlsoap.org/wsdl/mime/"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.example.org/NewWSDLFile/"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:complexType name="GetAttachmentPDF">
    <xsd:sequence>
    <xsd:element minOccurs="0" name="Pdf" nillable="false" type="xs:base64Binary"/>
    </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="GetAttachmentResult">
    <xsd:sequence>
    <xsd:element minOccurs="1" name="Message" nillable="true" type="xs:string"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:schema>
    </WL5G3N0:types>
    <WL5G3N0:message name="NewOperationRequest">
    <WL5G3N0:part name="GetAttachment" type="WL5G3N1:string"/>
    </WL5G3N0:message>
    <WL5G3N0:message name="NewOperationResponse">
    <WL5G3N0:part name="NewOperationResponse" type="WL5G3N2:GetAttachmentResult"/>
    <WL5G3N0:part name="attachment" type="WL5G3N2:GetAttachmentPDF"/>
    </WL5G3N0:message>
    <WL5G3N0:portType name="NewWSDLFile">
    <WL5G3N0:operation name="NewOperation">
    <WL5G3N0:input message="WL5G3N3:NewOperationRequest"/>
    <WL5G3N0:output message="WL5G3N3:NewOperationResponse"/>
    </WL5G3N0:operation>
    </WL5G3N0:portType>
    <WL5G3N0:binding name="NewWSDLFileSOAP" type="WL5G3N3:NewWSDLFile">
    <WL5G3N4:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
    <WL5G3N0:operation name="NewOperation">
    <WL5G3N4:operation soapAction="http://www.example.org/NewWSDLFile/NewOperation"/>
    <WL5G3N0:input>
    <WL5G3N4:body use="literal" namespace="http://www.example.org/NewWSDLFile/"/>
    </WL5G3N0:input>
    <WL5G3N0:output>
    <WL5G3N5:multipartRelated>
    <WL5G3N5:part>
    <WL5G3N4:body use="literal" namespace="http://www.example.org/NewWSDLFile/"/>
    </WL5G3N5:part>
    <WL5G3N5:part>
    <WL5G3N5:content part="attachment" type="application/pdf"/>
    </WL5G3N5:part>
    </WL5G3N5:multipartRelated>
    </WL5G3N0:output>
    </WL5G3N0:operation>
    </WL5G3N0:binding>
    <WL5G3N0:service name="NewWSDLFile">
    <WL5G3N0:port name="NewWSDLFileSOAP" binding="WL5G3N3:NewWSDLFileSOAP">
    <WL5G3N4:address location="http://localhost:7001/something/NewWSDLFileImpl"/>
    </WL5G3N0:port>
    </WL5G3N0:service>
    </WL5G3N0:definitions>
    I refered the below link:
    http://docs.oracle.com/cd/B14099_19/integrate.1012/b14448/manipdoc.htm.
    4.16.1.1 WSDL File Contents
    They are using ra:writeBinaryToFile() and ora:ReadBinaryFromFile(). I couldnt get a proper sample to understand the use of these functions.
    Please advise.
    Regards
    Ipsita

  • How to create Word file and send file in mail as an attachment

    Hi Guys,
    I want to create report which fetech data from table and create word file of the same data and send file in mail as an attachment.

    Hello Sagar,
    Before posting please use GOOGLE,any way it may help u,
    DivulgeSAP: Send email with PDF, ZIP, TXT etc., as attachment from CL_BCS interface
    Thanks
    Sam

  • Convert spool output of ABAP list into excel and send email

    Hello All,
      I have a requirement where we need to
    1. schedule a background job programtically
    2. moniter backround job (if complete or not)
    3. once its complete take spool output ,convert into excel and email.
    I have following difficulties.
      1. i have reached upto stage 3. However, i am not getting proper ouput of excel via mail. it contains junk characters. I searched SDN and tried various option but not successful.
    2. AT last i have submited report and collected output in memory rather than submiting back ground job. Now excel out put is coming somewhat as required but while sending mail , i am getting limitation of 255 chars . My excel row has more than 255 line size.
    Please suggest.
    Thanks in advance,
    jigs.
    <<text removed>>
    Edited by: Matt on Jul 1, 2009 3:52 PM - removed point offer

    I've edited your post.  Please take the time to read the Rules of Engagement of these forums.  Offering points is not permitted for reasons outline in the Rules of Engagement.
    matt

  • Create an excel and upload it in document library through c#

     Hi everyone,
       I have one requirement in my organization . pickup data from multiple lists from sharepoint silte and convert it as an excel spredsheet and save it to the document library in c# progamming
     Can any one help me 
    Thanks 
    Nag

    Hi Nag,
    Per my understanding, you might want to gather data from multiple lists, generate an Excel file and save to a Document Library using C#.
    There will be several steps in this scenario: get data from SharePoint List using SharePoint Object Model, create an Excel file and save to a Document Library, then
    access this Excel file with the help of Excel Web Services.
    About the retrieving data from a SharePoint list, we can use SharePoint Object Model:
    SharePoint Object Model - SPListItem class
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splistitem.aspx
    Add, Update and Delete List Items Programmatically in SharePoint
    http://www.mindfiresolutions.com/Add-Update-and-Delete-List-Items-Programmatically-in-Sharepoint-372.php
    About how to create document in a SharePoint library programmatically:
    https://nickgrattan.wordpress.com/2008/12/08/code-for-creating-new-documents-based-on-a-content-type-and-template/
    About how to work with Excel web Services: 
    https://msdn.microsoft.com/en-us/library/office/ms572330(v=office.15).aspx
    https://msdn.microsoft.com/en-us/library/office/ff640648(v=office.14).aspx
    Best regards
    Patrick Liang
    TechNet Community Support

Maybe you are looking for

  • Can no longer get FCPX clip search to find anything

    Image below demonstrates my quandry. Clearly have a clip labeled "24fps". Searched for "24fps". Nothing found. Happens no matter what I search search term I use in the event library. Fresh install of FCPX, there is only one event library present.

  • Portal Password Reset - Active Directory - Urgent

    Friends We are using SAP Portal 6.0 SP 18.  The Portal UME data source has been configured with Microsoft ADS. Now we have an requirement to change the user Password in the Active Directory from the Portal. How can we achieve this...?  I am OK even t

  • Disc 4137 - query based on login?

    We have a sales table in Discoverer that we want to allow sales managers to access so they can define their own ad-hoc queries. However we only want them to be able to query based on sales attributed to them i.e. they can't query on other sales manag

  • Packet writing on Mac

    I have finally figured out how to use packet writing on Mac OS X. This information had to be shared. The software needed for writing to a DVD like a floppy disk is already in Mac OS 10.6. I think the main problem is trying to format a DVD in the UDF

  • Animation failure/not autoplaying

    I have made two animations (created in Edge). One linking to the other. One should close and the other open.  They are also suppose to auto play an animation from the start every time I am clicking a button. The only thing that happens is that the la