SEND ALV report to Exter email

Moved to correct forum by moderator.
hi.
i want to export my alv customer ledger data throug email on weekly sheduling basis through email.n e body tell me how  can i do this
Edited by: Matt on Nov 27, 2008 11:04 AM

hi you can try the following code:
FORM docu_send_email USING pv_otfdata  TYPE tsfotf
                           pv_emailid  TYPE any
                           pv_formname TYPE any.
  DATA: lv_filesize    TYPE i,
        lv_buffer      TYPE string,
        lv_attachment  TYPE i,
        lv_testo       TYPE i.
  DATA: li_pdfdata  TYPE STANDARD TABLE OF tline,
        li_mess_att TYPE STANDARD TABLE OF solisti1,
        li_mtab_pdf TYPE STANDARD TABLE OF tline,
        li_objpack  TYPE STANDARD TABLE OF sopcklsti1,
        li_objtxt   TYPE STANDARD TABLE OF solisti1,
        li_objbin   TYPE STANDARD TABLE OF solisti1,
        li_reclist  TYPE STANDARD TABLE OF somlreci1,
        li_objhead  TYPE soli_tab.
  DATA: lwa_pdfdata  TYPE tline,
        lwa_objpack  TYPE sopcklsti1,
        lwa_mess_att TYPE solisti1,
        lwa_objtxt   TYPE solisti1,
        lwa_objbin   TYPE solisti1,
        lwa_reclist  TYPE somlreci1,
        lwa_doc_chng TYPE  sodocchgi1.
  CONSTANTS: lc_u           TYPE char1  VALUE 'U',
             lc_0           TYPE char1  VALUE '0',
             lc_1           TYPE char1  VALUE '1',
             lc_pdf         TYPE char3  VALUE 'PDF',
             lc_raw         TYPE char3  VALUE 'RAW',
             lc_ordform     TYPE char15 VALUE 'ZORDCONFIRM_01',
             lc_attachment  TYPE char10 VALUE 'ATTACHMENT'.
  CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
      format                = lc_pdf
      max_linewidth         = 132
    IMPORTING
      bin_filesize          = lv_filesize
    TABLES
      otf                   = pv_otfdata
      lines                 = li_pdfdata
    EXCEPTIONS
      err_max_linewidth     = 1
      err_format            = 2
      err_conv_not_possible = 3
      err_bad_otf           = 4
      OTHERS                = 5.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  LOOP AT li_pdfdata INTO lwa_pdfdata.
    TRANSLATE lwa_pdfdata USING ' ~'.
    CONCATENATE lv_buffer lwa_pdfdata INTO lv_buffer.
    CLEAR lwa_pdfdata.
  ENDLOOP.
  TRANSLATE lv_buffer USING '~ '.
  DO.
    lwa_mess_att = lv_buffer.
    APPEND lwa_mess_att TO li_mess_att.
    CLEAR lwa_mess_att.
    SHIFT lv_buffer LEFT BY 255 PLACES.
    IF lv_buffer IS INITIAL.
      EXIT.
    ENDIF.
  ENDDO.
*  Object with PDF.
  REFRESH li_objbin.
  li_objbin[] = li_mess_att[].
  DESCRIBE TABLE li_objbin LINES lv_attachment.
*  Object with main text of the mail.
  lwa_objtxt = space.
  APPEND lwa_objtxt TO li_objtxt.
  CLEAR lwa_objtxt.
  DESCRIBE TABLE li_objtxt LINES lv_testo.
*  Create the document which is to be sent
  lwa_doc_chng-obj_name  = text-008.
  lwa_doc_chng-obj_descr = text-008.
  lwa_doc_chng-sensitivty = lc_0.
  lwa_doc_chng-obj_prio = lc_1.
  lwa_doc_chng-doc_size = lv_testo * 225.
*  Pack to main body.
  CLEAR lwa_objpack-transf_bin.
*  header
  lwa_objpack-head_start = 1.
*  The document needs no header (head_num = 0)
  lwa_objpack-head_num   = 0.
*  body
  lwa_objpack-body_start = 1.
  lwa_objpack-body_num   = lv_testo.
  lwa_objpack-doc_type   = lc_raw.
  APPEND lwa_objpack TO li_objpack.
  CLEAR lwa_objpack.
* Create the attachment.
* Fill the fields of the packing_list for the attachment:
  lwa_objpack-transf_bin = gc_x .
*  header
  lwa_objpack-head_start = 1.
  lwa_objpack-head_num   = 1.
*  body
  lwa_objpack-body_start = 1.
  lwa_objpack-body_num   = lv_attachment.
  lwa_objpack-doc_type   = lc_pdf.
  lwa_objpack-obj_name   = lc_attachment.
  lwa_objpack-obj_descr  = text-008.
  lwa_objpack-doc_size =  lv_attachment * 255.
  APPEND lwa_objpack TO li_objpack.
  CLEAR lwa_objpack.
  lwa_reclist-receiver   = pv_emailid.
  lwa_reclist-rec_type   = lc_u.
  lwa_reclist-notif_del  = gc_x.
  lwa_reclist-notif_ndel = gc_x.
  APPEND lwa_reclist TO li_reclist.
  IF li_reclist IS NOT INITIAL.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
      EXPORTING
        document_data              = lwa_doc_chng
        put_in_outbox              = gc_x
      TABLES
        packing_list               = li_objpack
        object_header              = li_objhead
        contents_bin               = li_objbin
        contents_txt               = li_objtxt
        receivers                  = li_reclist
      EXCEPTIONS
        too_many_receivers         = 1
        document_not_sent          = 2
        document_type_not_exist    = 3
        operation_no_authorization = 4
        parameter_error            = 5
        x_error                    = 6
        enqueue_error              = 7
        OTHERS                     = 8.
Edited by: Matt on Nov 27, 2008 11:05 AM Please use  tags around your ABAP

Similar Messages

  • Sending ALV report(As a attachment ) through EMail

    Dear Friends,
    Could anyone please help me to solve this problem.
    I need to send ALV report <b>as an attachment</b> to External mail-id as well as SAP USER ID..The user wants to schedule this ABAP program in background, at the end the final output should be send to his ID. I facing problem to locate correct Functional Module....
    I would like to thank, if anyone give some idea on this issue also if possible a sample code.
    Thanks in advance
    With Reg
    Babu

    HI Kamal Babu
    After sending your ABAP List to the spool request (SP01), you can use the SAP standard spool PDF conversion program.
    RSTXPDFT4 - This report program converts ABAP List to PDF files.
    Or Just try this sample code:
    After running the background jobs, send the spool to the SAP users Office Mail Box.
    REPORT ZMAILSPOOL.
    INCLUDE LBTCHDEF.
    Include the Business Object Repository object
    INCLUDE <CNTN01>.
    DATA ABAPNM LIKE SY-REPID.
    DATA BEGIN OF LOCAL_JOB.
    INCLUDE STRUCTURE TBTCJOB.
    DATA END OF LOCAL_JOB.
    DATA BEGIN OF LOCAL_STEP_TBL OCCURS 10.
    INCLUDE STRUCTURE TBTCSTEP.
    DATA END OF LOCAL_STEP_TBL.
    Data declarations for the mail recipient
    DATA RECIPIENT TYPE SWC_OBJECT.
    DATA RECIPIENT_OBJ LIKE SWOTOBJID.
    SWC_CONTAINER CONTAINER.
    Data declarations for the background job
    PARAMETERS ABAPNAME(20) DEFAULT 'ZTEST1'.
    PARAMETERS EMPFNAME LIKE SY-UNAME DEFAULT SY-UNAME.
    ABAPNM = ABAPNAME.
    LOCAL_JOB-JOBNAME = ABAPNAME.
    Generate recipient object (see report RSSOKIF1 for an example)
    1. Create the recipient:
    IF EMPFNAME <> SPACE.
    "** 1.1 Generate an object reference to a recipient object
    SWC_CREATE_OBJECT RECIPIENT 'RECIPIENT' SPACE.
    "** 1.2 Write the import parameters for method
    "** recipient.createaddress into the container
    "** and empty the container
    SWC_CLEAR_CONTAINER CONTAINER.
    "** Set address element (internal user 'JSMITH')
    SWC_SET_ELEMENT CONTAINER 'AddressString' EMPFNAME.
    "** Set address type (internal user)
    SWC_SET_ELEMENT CONTAINER 'TypeId' 'B'.
    "** 1.3 Call the method recipient.createaddress
    SWC_CALL_METHOD RECIPIENT 'CreateAddress' CONTAINER.
    "** Issue any error message generated by a method exception
    IF SY-SUBRC NE 0.
    MESSAGE ID SY-MSGID TYPE 'E' NUMBER SY-MSGNO.
    ENDIF.
    SWC_CALL_METHOD RECIPIENT 'Save' CONTAINER.
    SWC_OBJECT_TO_PERSISTENT RECIPIENT RECIPIENT_OBJ.
    ENDIF.
    Recipient has been generated and is ready for use in a
    background job
    CALL FUNCTION 'JOB_OPEN'
         exporting
         DELANFREP              = ' '
         JOBGROUP               = ' '
           jobname                = LOCAL_JOB-JOBNAME
         SDLSTRTDT              = NO_DATE
         SDLSTRTTM              = NO_TIME
         IMPORTING
           JOBCOUNT               = LOCAL_JOB-JOBCOUNT
         EXCEPTIONS
           CANT_CREATE_JOB        = 1
           INVALID_JOB_DATA       = 2
           JOBNAME_MISSING        = 3
           OTHERS                 = 4
       if sy-subrc <> 0.
          WRITE: / 'JOB_OPEN PROBLEM ', SY-SUBRC.
       ELSE.
          WRITE: / 'JOB OPEN SUCCESS',
                                      LOCAL_JOB-JOBNAME, LOCAL_JOB-JOBCOUNT.
       endif.
    CALL FUNCTION 'JOB_SUBMIT'
         exporting
         ARCPARAMS                         =
           authcknam                         = SY-UNAME
         COMMANDNAME                       = ' '
         OPERATINGSYSTEM                   = ' '
         EXTPGM_NAME                       = ' '
         EXTPGM_PARAM                      = ' '
         EXTPGM_SET_TRACE_ON               = ' '
         EXTPGM_STDERR_IN_JOBLOG           = 'X'
         EXTPGM_STDOUT_IN_JOBLOG           = 'X'
         EXTPGM_SYSTEM                     = ' '
         EXTPGM_RFCDEST                    = ' '
         EXTPGM_WAIT_FOR_TERMINATION       = 'X'
           jobcount                          = LOCAL_JOB-JOBCOUNT
           jobname                           = LOCAL_JOB-JOBNAME
         LANGUAGE                          = SY-LANGU
         PRIPARAMS                         = ' '
           REPORT                            = ABAPNM
         REPORT                            = 'ZTEST1'
         VARIANT                           = ' '
       IMPORTING
         STEP_NUMBER                       = LOCAL_JOB-STEPCOUNT
         EXCEPTIONS
           BAD_PRIPARAMS                     = 1
           BAD_XPGFLAGS                      = 2
           INVALID_JOBDATA                   = 3
           JOBNAME_MISSING                   = 4
           JOB_NOTEX                         = 5
           JOB_SUBMIT_FAILED                 = 6
           LOCK_FAILED                       = 7
           PROGRAM_MISSING                   = 8
           PROG_ABAP_AND_EXTPG_SET           = 9
           OTHERS                            = 10
       if sy-subrc <> 0.
          WRITE: / 'JOB_SUBMIT PROBLEM ', LOCAL_JOB-JOBCOUNT,
                   LOCAL_JOB-JOBNAME, ABAPNAME, SY-SUBRC.
       endif.
    IF EMPFNAME <> SPACE.
    CALL FUNCTION 'JOB_CLOSE'
      exporting
      AT_OPMODE                         = ' '
      AT_OPMODE_PERIODIC                = ' '
      CALENDAR_ID                       = ' '
      EVENT_ID                          = ' '
      EVENT_PARAM                       = ' '
      EVENT_PERIODIC                    = ' '
        jobcount                          = LOCAL_JOB-JOBCOUNT
        jobname                           = LOCAL_JOB-JOBNAME
      LASTSTRTDT                        = NO_DATE
      LASTSTRTTM                        = NO_TIME
      PRDDAYS                           = 0
      PRDHOURS                          = 0
      PRDMINS                           = 0
      PRDMONTHS                         = 0
      PRDWEEKS                          = 0
      PREDJOB_CHECKSTAT                 = ' '
      PRED_JOBCOUNT                     = ' '
      PRED_JOBNAME                      = ' '
      SDLSTRTDT                         = NO_DATE
      SDLSTRTTM                         = NO_TIME
      STARTDATE_RESTRICTION             = BTC_PROCESS_ALWAYS
        STRTIMMED                         = 'X'
      TARGETSYSTEM                      = ' '
      START_ON_WORKDAY_NOT_BEFORE       = SY-DATUM
      START_ON_WORKDAY_NR               = 0
      WORKDAY_COUNT_DIRECTION           = 0
        RECIPIENT_OBJ                     = RECIPIENT_OBJ
      TARGETSERVER                      = ' '
      DONT_RELEASE                      = ' '
    IMPORTING
      JOB_WAS_RELEASED                  = 'X'
      EXCEPTIONS
        CANT_START_IMMEDIATE              = 1
        INVALID_STARTDATE                 = 2
        JOBNAME_MISSING                   = 3
        JOB_CLOSE_FAILED                  = 4
        JOB_NOSTEPS                       = 5
        JOB_NOTEX                         = 6
        LOCK_FAILED                       = 7
        OTHERS                            = 8
    IF ( SY-SUBRC <> 0 ).
      WRITE: / 'Job_Close Problem:', ABAPNAME, SY-SUBRC.
    ELSE.
      WRITE: / 'Job_Close done'.
    ENDIF.
    ELSE. "no empfname
    ENDIF.
    Cheers,
    Vijay Raheja

  • Problem to send a report to an Email address

    Hi All,
    I am using 10g forms and reports.I want to send a report to an email address using web.show_document();
    code is:WEB.SHOW_DOCUMENT('http://localhost:post/reports/rwservlet?userid=ur/ps@db&report='report_name&destype=mail&desformat=RTF&from=[email protected]&desname=[email protected]&paramform=no&_blank') ;
    this code generates an error message:
    REP-50159: Executed successfully but there were some errors when distribute the output
    I already configure my rwbuilder.conf and report_server.conf file.
    Although I am able to send this mail from report builder from FILE->mail menu.
    plz help me ASAP.
    thanks in advance.
    Sanjit

    Ok, did you add your smtp server to your <reports>.conf file is located at the end of the file.
    Because if it has been working for other destype it's probably security smtp related.
    so check if the correct smtp server is written there and that you can access it too because otherwise it would be impossible to send e-mail, if you're not the e-mail admin contact him and ask hin if he sees an attempt to send on the smtp engine log for your from user
    Erwin

  • Need to send ALV Report as an Excel sheet via Email

    Well , I need to Email an ALV Report as an Excel Sheet using my program. What do I need to do and how?
    Answers will be rewarded with points.
    Thanks

    Hi Manu,
    You can copy and paste the following codes and try to execute..
    Hope this will help you..
    note: dont forget to change 'SAPUSER' to your SAP user id.
    REPORT  yhn_test8                               .
    TYPE-POOLS: slis, slist, truxs.
    DATA t5         LIKE t005t OCCURS 0 WITH HEADER LINE.
    DATA fcat       TYPE slis_t_fieldcat_alv.
    DATA listobject LIKE abaplist OCCURS 0 WITH HEADER LINE.
    DATA stack      TYPE slist_listlevel_stack WITH HEADER LINE.
    DATA ttxt       LIKE solisti1 OCCURS 0 WITH HEADER LINE.
    PARAMETER p_alv   RADIOBUTTON GROUP a.
    PARAMETER p_excel RADIOBUTTON GROUP a.
    START-OF-SELECTION.
      SELECT * INTO TABLE t5
               FROM t005t
              WHERE spras = sy-langu.
      CLEAR : fcat, fcat[].
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name       = 'T005T'
        CHANGING
          ct_fieldcat            = fcat
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 2
          OTHERS                 = 3.
      IF p_alv = 'X'.
        CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
          EXPORTING
            it_fieldcat   = fcat
          TABLES
            t_outtab      = t5
          EXCEPTIONS
            program_error = 1
            OTHERS        = 2.
        IF sy-subrc <> 0.
        ENDIF.
      ELSEIF p_excel = 'X'.
        CALL FUNCTION 'LIST_FREE_MEMORY'.
        SUBMIT yhn_test8 EXPORTING LIST TO MEMORY AND RETURN.
        CALL FUNCTION 'LIST_FROM_MEMORY'
          TABLES
            listobject = listobject
          EXCEPTIONS
            not_found  = 1
            OTHERS     = 2.
        IF sy-subrc = 0.
        Generate LIST for excel file
          CALL FUNCTION 'LIST_TO_TXT'
            TABLES
              listtxt            = ttxt
              listobject         = listobject
            EXCEPTIONS
              empty_list         = 1
              list_index_invalid = 2
              OTHERS             = 3.
          IF sy-subrc = 0.
            LOOP AT ttxt.
              REPLACE ALL OCCURRENCES OF '|' IN ttxt-line
                      WITH cl_abap_char_utilities=>horizontal_tab.
              MODIFY ttxt.
            ENDLOOP.
            PERFORM send_email.
          ENDIF.
        ENDIF.
      ENDIF.
    *&      Form  send_email
    FORM send_email .
      DATA docs LIKE docs OCCURS 0 WITH HEADER LINE.
      DATA excelsize TYPE i.
      DATA excel LIKE solisti1   OCCURS 0 WITH HEADER LINE.
      DATA doc LIKE sodocchgi1.
      DATA excelln TYPE i.
      DATA int_objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
      DATA int_objhead LIKE solisti1   OCCURS 2 WITH HEADER LINE.
      DATA int_objtext LIKE solisti1   OCCURS 0 WITH HEADER LINE.
      DATA int_reclist LIKE somlreci1  OCCURS 1 WITH HEADER LINE.
      DATA bodyln LIKE sy-tabix.
      DATA output_data TYPE ssfcrescl.
      excel[] = ttxt[].
    excel table sizes
      DESCRIBE TABLE excel LINES excelln.
    Body Email
      int_objtext-line = 'Test Body'.
      APPEND int_objtext.
      DESCRIBE TABLE int_objtext LINES bodyln.
      READ     TABLE int_objtext INDEX bodyln.
      CLEAR doc.
      doc-doc_size   = ( bodyln - 1 ) * 255 + STRLEN( int_objtext ).
      doc-obj_name   = ' '.
      doc-sensitivty = 'P'.
      doc-proc_syst  = sy-sysid.
      doc-proc_clint = sy-mandt.
      CLEAR: int_objpack, int_objpack[].
      int_objpack-transf_bin = ' '.
      int_objpack-head_start = 1.
      int_objpack-head_num   = 0.
      int_objpack-body_start = 1.
      int_objpack-body_num   = bodyln.
      int_objpack-doc_type   = 'RAW'.
      int_objpack-obj_descr  = 'Test'.
      APPEND int_objpack.
      CLEAR: int_objhead, int_objhead[].
      int_objhead            = 'Attachment'.
      APPEND int_objhead.
      int_objpack-transf_bin = 'X'.
      int_objpack-head_start = 1.
      int_objpack-head_num   = 0.
      int_objpack-body_start = 1.
      int_objpack-body_num   = excelln.
      int_objpack-doc_size   = excelsize.
      int_objpack-doc_type   = 'XLS'.
      int_objpack-obj_name   = 'excel'.
      int_objpack-obj_descr  = 'test.xls'. "File name
      APPEND int_objpack.
      Set Receiver
      int_reclist-receiver   = 'SAPUSER'.
      int_reclist-rec_type   = 'B'.
      int_reclist-notif_del  = 'X'.
      int_reclist-notif_read = 'X'.
      int_reclist-notif_ndel = 'X'.
      int_reclist-express    = 'X'.
      APPEND int_reclist.
      doc-obj_descr = 'Report in Excel'.
      Sending Email
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = doc
          put_in_outbox              = 'X'
          commit_work                = 'X'
        TABLES
          packing_list               = int_objpack
          object_header              = int_objhead
          contents_bin               = excel
          contents_txt               = int_objtext   "Body
          receivers                  = int_reclist
        EXCEPTIONS
          too_many_receivers         = 1
          document_not_sent          = 2
          document_type_not_exist    = 3
          operation_no_authorization = 4
          parameter_error            = 5
          x_error                    = 6
          enqueue_error              = 7
          OTHERS                     = 8.
    ENDFORM.                    " send_email

  • How to send ALV report by email, in the body of the email?

    Hello friends,
    I need to send a report ALV by email. First, the user wanted it attached as PDF file, but now he wants it in the body of the email.
    Does anybody have any solution?
    P.S.: I am using methods to send the email.
    Thanks in advance.
    Karla.

    Thank you Jan,
    I used the following solution to get the report in HTML code:
    I use submit to export the list to memory
    SUBMIT zsdr006_alv EXPORTING LIST TO MEMORY AND RETURN.
    Them I get the list from memory
      CALL FUNCTION 'LIST_FROM_MEMORY'
    Finaly I convert the list to HTML code
      CALL FUNCTION 'WWW_HTML_FROM_LISTOBJECT'
    The problem is when I send the email, it is still not going on the body of the email.
    I tried taking off the attach method, but the email goes blank in the body.
    Actually to SOST the message goes with the HMTL report in the body, just like I need, but when send to any e-mail address, it does not go on the body of the message.
    Does any body could check this out?
      TRY.
        -------- create persistent send request ------------------------
          send_request = cl_bcs=>create_persistent( ).
        -------- create and set document with attachment ---------------
        create document from internal table with text
          IF p_pdf EQ 'X'.
            l_type = 'RAW'.
            APPEND text-t01 TO text.
            IF NOT s_erdat-low IS INITIAL.
              CONCATENATE s_erdat-low6(2) '.' s_erdat-low4(2) '.' s_erdat-low(4) INTO ls_text-line.
              IF NOT s_erdat-high IS INITIAL.
                CONCATENATE ls_text-line 'a' INTO ls_text-line SEPARATED BY space.
                CONCATENATE ls_text-line s_erdat-high+6(2) INTO ls_text-line SEPARATED BY space.
                CONCATENATE ls_text-line '.' s_erdat-high+4(2) '.' s_erdat-high(4) INTO ls_text-line.
              ENDIF.
              CONCATENATE 'Período:' ls_text-line INTO ls_text-line SEPARATED BY space.
              APPEND ls_text TO text.
            ENDIF.
          ELSEIF p_htm EQ 'X'.
            l_type = 'HTM'.
            LOOP AT gt_ascdata INTO ls_ascdata.
              ls_text = ls_ascdata-line.
              APPEND ls_text TO text.
            ENDLOOP.
          ENDIF.
          subject = text-t01.
          document = cl_document_bcs=>create_document(
                          i_type    = l_type
                          i_text    = text
                          i_length  = '12'
                          i_subject = subject ).
        add attachment to document
        BCS expects document content here e.g. from document upload
        binary_content = ...
          IF p_pdf EQ 'X'.
            CALL METHOD document->add_attachment
              EXPORTING
                i_attachment_type    = 'PDF'
                i_attachment_subject = g_filename
                i_att_content_hex    = binary_content.
          ELSEIF p_htm EQ 'X'.
            CALL METHOD document->add_attachment
              EXPORTING
                i_attachment_type    = 'HTM'
                i_attachment_subject = g_filename
                i_att_content_text   = gt_ascdata.
          ENDIF.
        add document to send request
          CALL METHOD send_request->set_document( document ).
        --------- set sender -------------------------------------------
        note: this is necessary only if you want to set the sender
              different from actual user (SY-UNAME). Otherwise sender is
              set automatically with actual user.
         sender = cl_sapuser_bcs=>create( sy-uname ).
          lv_email = g_email.
          sender = cl_cam_address_bcs=>create_internet_address( lv_email ).
          CALL METHOD send_request->set_sender
            EXPORTING
              i_sender = sender.
        --------- add recipient (e-mail address) -----------------------
        create recipient - please replace e-mail address !!!
          LOOP AT s_email.
            lv_email = s_email-low.
            recipient = cl_cam_address_bcs=>create_internet_address( lv_email ).
        add recipient with its respective attributes to send request
            CALL METHOD send_request->add_recipient
              EXPORTING
                i_recipient = recipient
                i_express   = 'X'.
          ENDLOOP.
        ---------- send document ---------------------------------------
          CALL METHOD send_request->send(
            EXPORTING
              i_with_error_screen = 'X'
            RECEIVING
              result              = sent_to_all ).

  • How to send ALV report by Email

    Hi.
    we have developed a block ALV report which has 3 reports i.e Detail report , summary report and Error report. Currently user run the report in background.However there is need to send this report by Email . I can use FM:SO_OBJECT_SEND . I want how to pass this report to FM and how to handle if there are multiple email ids. I think we can create a group of the user with email id in business workplace and pass the group to FM.
    I need help in how to assign the report and user group to this FM

    Hi,
    You may use the code given by Amit in this link -
    MAil Attachment.
    It is perfect to handle any type of email requirement.
    Regards,
    Amit
    Reward all helpful replies.

  • Send ALV report as email attachment but in background scheduling mode

    Hi All,
           I have ALV report which runs fine in  the foreground.
    But i need to display it in the spool that is by scheduling in the background.
    can i send an excel attachement as e-mail in the background scheduling?  my report contains
    10 columns and i need them in proper format on excel sheet attachment? plz help me out?if possible
    give me abap code..

    HI,
    Use the below link
    Sending Mail to the schedular of Background Job
    Thanks

  • How to send ALV Report in excel format from SAP

    Hi Gurus,
    We are using SAP 4.7 and using different SAP reports.Now I want to send SAP ALV report in excel format directly from SAP in background.Now we send these reports in background weekly by using autimetic scheduling but this is PDF format.Now I want to change this pdf format to excel format.In SCOT T.Code I am able to find any excel format.Please help me out.
    I am waiting for your reply.
    Advance Thanks
    Nirmal

    Hi Nirmal,
    I have done the same in my previous organisation.For this particular solution you need to ask your basis guys to upgrade the support package so that BCS classes could be available in the system.
    API interafces five some problem with attachemnts and SAP has recommended to use BCS classes.
    Currently BCS classes won't be availbale in 4.7.
    Once the BCS classes are available
    use below code
       CONSTANTS:
        lc_tab          TYPE c VALUE cl_bcs_convert=>gc_tab,
        lc_crlf         TYPE c VALUE cl_bcs_convert=>gc_crlf,
       lc_codepage     TYPE abap_encod VALUE '4103',
    data :
       lv_string      TYPE string,
       binary_content TYPE solix_tab,
       size           TYPE so_obj_len,
       *" Set Heading of Excel File
      CONCATENATE 'Employee DATA'
                   lc_crlf lc_crlf
                   INTO lv_string.
       *" Set Header for Excel Fields
      CONCATENATE lv_string
                  lc_header1 lc_tab
                  lc_header2 lc_tab
                  lc_header3 lc_tab
                  lc_header4 lc_tab
                  lc_header5 lc_tab
                  lc_header6 lc_tab
                  lc_header7 lc_tab
                  lc_header8 lc_tab
                  lc_header9 lc_tab
                  lc_header10 lc_crlf
                  INTO lv_string.
    "lc_header1 to 10 could be your field headers
       "Move Internal table data
      LOOP AT gt_final1 INTO gwa_final1.
        CONCATENATE lv_string
                    gwa_final1-field1     lc_tab
                    gwa_final1-field2      lc_tab
                    gwa_final1-field3    lc_crlf
                    INTO lv_string.
      ENDLOOP.
       *" convert the text string into UTF-16LE binary data including
    *" byte-order-mark. Mircosoft Excel prefers these settings
    *" all this is done by new class cl_bcs_convert (see note 1151257)
      TRY.
          cl_bcs_convert=>string_to_solix(
            EXPORTING
              iv_string   = lv_string
              iv_codepage = lc_codepage  "suitable for MS Excel, leave empty
              iv_add_bom  = abap_true     "for other doc types
            IMPORTING
              et_solix  = binary_content
              ev_size   = size ).
        CATCH cx_bcs.
          MESSAGE e445(so).
      ENDTRY.
      TRY.
    *" create persistent send request
          send_request = cl_bcs=>create_persistent( ).
          document = cl_document_bcs=>create_document(
            i_type    = lc_doc
            i_text    = main_text
            i_subject = lc_sub  ).     
          document->add_attachment(
            i_attachment_type    = lc_attach                    "#EC NOTEXT
            i_attachment_subject = lc_sub                       "#EC NOTEXT
            i_attachment_size    = size
            i_att_content_hex    = binary_content ).
       send_request->set_document( document ).
       recipient = cl_cam_address_bcs=>create_internet_address( email ).
       CALL METHOD send_request->add_recipient
              EXPORTING
                i_recipient = recipient.
       IF recipient IS NOT INITIAL.
            sent_to_all = send_request->send( i_with_error_screen = abap_true ).
            COMMIT WORK.
    *        MESSAGE text-014 TYPE gc_succ  .
          ENDIF.
        CATCH cx_bcs INTO bcs_exception.
          MESSAGE i865(so) WITH bcs_exception->error_type.
      ENDTRY.
    For BCS decalartion u can go to se 38 and see program BCS_EXAMPLE_1 to BCS_EXAMPLE_7.
    Rewrads if helpful.
    Cheers
    Ramesh Bhatt

  • How to send ALV report Output through mail in background !

    Hi ,
    I had an ALV Report. I want to send this report output to patricular email id every day ! Presenty i do this manually. I run the report and send the output to the particular email address. Now i want to schecule the report daily in background and the out put of the report should be mailed to particular email ids in background itself. How can i do this ?
    Is there and method or setting through which we can do this ?
    Regards

    Hi Nau,
    For this requirement you will have to write another program.
    This program will convert the spool requests into PDF document and sends an email  to the recipients that you specify.
    These are the threads which are already posted in The SDN.
    *http://wiki.sdn.sap.com/wiki/display/Snippets/Converts+spool+request+into+PDF+document+and+emails*
    *<a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="353650"></a>*
    *<a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="902985"></a>*
    You need to use the Function module :
    -- Sending the document
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    I will provide you with the code to get this functionality.
    *&      Form  SEND_EMAIL
    form SEND_EMAIL .
    DATA:   t_mailpack   TYPE sopcklsti1 OCCURS 0 WITH HEADER LINE,
              t_mailhead   TYPE solisti1   OCCURS 0 WITH HEADER LINE,
              t_mailbin    TYPE solisti1   OCCURS 0 WITH HEADER LINE,
              t_mailtxt    TYPE solisti1   OCCURS 0 WITH HEADER LINE,
              t_mailrec    TYPE somlreci1  OCCURS 0 WITH HEADER LINE.
      DATA: wa_maildata    TYPE sodocchgi1,
            l_filename(50) TYPE c,
            l_fldname(30)  TYPE c,
            l_fldval(100)  TYPE c,
            l_lines        TYPE i,
            l_text         TYPE text128 .
      DATA: w_email_subrc  TYPE i.
      DATA: w_ship like vbfa-vbeln.
      CLEAR: wa_maildata,
             t_mailtxt,
             t_mailbin,
             t_mailpack,
             t_mailhead,
             t_mailrec.
      REFRESH: t_mailtxt,
               t_mailbin,
               t_mailpack,
               t_mailhead,
               t_mailrec.
    *-- Fill output file
    *- Fill header
      CLEAR: t_mailbin.
    *  t_mailbin[] = pdf_tab[].
      t_mailbin[] = it_att[].     "Uthaman
    *This line is added to get the shipment no in Subject Line
    SELECT SINGLE * FROM vbfa WHERE vbelv EQ nast-objky
                                AND vbtyp_v EQ c_vbtyp_v_j
                                AND vbtyp_n EQ c_vbtyp_n_8.
    w_ship = vbfa-vbeln.
    shift w_ship left deleting leading '0'.
    *-- File name
    if nast-kschl EQ 'ZFPL'.
      CLEAR l_filename.
      CONCATENATE 'Packing List -'
                  sy-datum+4(2) sy-datum+6(2) sy-datum(4) '.PDF' INTO l_filename.
    *-- Creation of the document to be sent File Name
      wa_maildata-obj_name = 'Packing List'.
    *-- Mail Subject
      CONCATENATE l_filename '-' 'Shipment No -' w_ship INTO wa_maildata-obj_descr SEPARATED BY space.
    *-- Mail Contents
      t_mailtxt-line = 'Packing List'.
      APPEND t_mailtxt.
    ENDIF.
    if nast-kschl EQ 'ZFBA'.
      CLEAR l_filename.
      CONCATENATE 'Booking Advice -'
                  sy-datum+4(2) sy-datum+6(2) sy-datum(4) '.PDF'
                  INTO l_filename.
    *-- Creation of the document to be sent File Name
      wa_maildata-obj_name = 'Booking Advice'.
    *-- Mail Subject
      CONCATENATE l_filename '-' 'Shipment No -' w_ship INTO wa_maildata-obj_descr SEPARATED BY space.
    *-- Mail Contents
      t_mailtxt-line = 'Packing List'.
      APPEND t_mailtxt.
    ENDIF.
    *-- Prepare Packing List
    *-- Write Packing List (Main Subject)
      CLEAR: l_lines, t_mailpack.
      DESCRIBE TABLE t_mailtxt LINES l_lines.
    *  READ TABLE t_mailtxt INDEX l_lines.
      t_mailpack-doc_size = ( l_lines - 1 ) * 255 + STRLEN( t_mailtxt ).
    *  CLEAR t_mailpack-transf_bin.
      t_mailpack-transf_bin = ' '.
      t_mailpack-head_start = 1.
      t_mailpack-head_num = 0.
      t_mailpack-body_start = 1.
      t_mailpack-body_num = l_lines.
      t_mailpack-doc_type = 'RAW'.
      APPEND t_mailpack.
      t_mailhead = l_filename.
      APPEND t_mailhead.
    *-- Write Packing List (Attachment)
      CLEAR: l_lines, t_mailpack.
      DESCRIBE TABLE pdf_tab[] LINES l_lines.
    *  READ TABLE pdf_tab INDEX l_lines.
      t_mailpack-doc_size = ( l_lines - 1 ) * 255 + STRLEN( t_mailbin ).
      t_mailpack-transf_bin = 'X'.
      t_mailpack-head_start = 1.
      t_mailpack-head_num = 1.
      t_mailpack-body_start = 1.
      t_mailpack-body_num = l_lines.
      t_mailpack-doc_type = 'PDF'.
      t_mailpack-obj_name = l_filename.
      t_mailpack-obj_descr = l_filename.
      t_mailpack-obj_langu = 'E'.
      APPEND t_mailpack.
    *-- Set recipients
    tables :  ztotcemail.
    SELECT SINGLE * FROM vbfa WHERE vbelv EQ nast-objky
                                AND vbtyp_v EQ c_vbtyp_v_j
                                AND vbtyp_n EQ c_vbtyp_n_8.
    CLEAR vttk.
    SELECT SINGLE * FROM vttk WHERE tknum EQ vbfa-vbeln.
    SELECT SINGLE * FROM ztotcemail WHERE tplst = vttk-tplst
                                      AND lifnr = vttk-tdlnr.
    IF SY-SUBRC EQ 0.
      t_mailrec-receiver = ztotcemail-smtp_addr. "'Here you will give the email address'.
      t_mailrec-rec_type  = 'U'.
      APPEND t_mailrec.
    ENDIF.
    **-- Sending the document
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = wa_maildata
          put_in_outbox              = 'X'
    *      commit_work                = 'X'  " N-16
        TABLES
          packing_list               = t_mailpack
          object_header              = t_mailhead
          contents_bin               = t_mailbin[]
          contents_txt               = t_mailtxt[]
          receivers                  = t_mailrec
        EXCEPTIONS
          too_many_receivers         = 1
          document_not_sent          = 2
          operation_no_authorization = 4
          OTHERS                     = 99.
      w_email_subrc = sy-subrc.
      IF sy-subrc EQ 0.
        MESSAGE s000(zotc) WITH 'Email output sent successfully'.
      ELSE.
        MESSAGE s000(zotc) WITH 'Can not send email output'.
      ENDIF.
    endform.                    " SEND_EMAIL
    Hope the above information will be helpful.
    Regards,
    Kittu

  • Send ALV report as attachment in EXCEL format

    Hi SAP Guru,
    I had a report output as ALV format.
    Currently, when the background job ended, it would be send out to the recipent thru SAPconnect as PDF format using internet mailing address.
    I tried to search for a configuraiton for EXCEL output but there don;t seems to be any option availble.
    I can only choose from PDF/TEXT/HTM/PS in the output document type selection in SOST.
    How can I configure to allow the system to send out the ALV report to my recipent in EXCEL format instead of PDF or HTML?
    Thanks

    Hi,
    By Using OOPS Concept you can send ALV Output as Excel Format by using Class Interface: CL_BCS.
    Do some search on CL_BCS.
    There are some demo Program, sreach for BCS* on SE38.
    Thanks & Regards
    M Nair

  • How to send the Report output thru email

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

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

  • Need to send the report output in email body.

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

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

  • How to send ALV report by mail

    Hi everybody,
    I would like to know how i can donwload the ALV report to an internal table so i can send it by mail?
    the fact of sending by mail it's already solved.. i tried sending the internal table of the ALV and it was OK, but what i need is to send all the display of the report..i mean..titles..columns,..totals... as i see on the screen.
    for a normal report i used the %_list to send the report to an internal table but for an ALV it doesn't work.
    Regards,
    Vanessa

    Hi Vanessa,
    If you have used Method (Container /Classes) for your ALV.
    You can find "SEND" when you drop down the "Download(UCOMM = %PC)" button at Container. Select "SEND" Option this will bring you Create Document and Send screen.
    Please enter reciepient and send the report.
    Hope this may help you.
    Lanka
    Message was edited by: Lanka Murthy

  • Send the Report output to email from spool

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

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

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

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

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

Maybe you are looking for

  • Illustrator CC don't works

    I've installed Photoshp CC, Indesign CC and Illustrator CC. Only illustrator CC don't works. When I click on the apps , I've this message : Adobe Illustrator CC left in a unforeseen way Please, help... the report: Process:         Adobe Illustrator [

  • How do I transfer a Movie from my windows itune account to my Mac itunes account?

    How would I transfer a movie, which was downloaded to my itunes account on my Windows computer, to my Mac I tunes account that has all my other movies on it?

  • Same query takes different time to fetch result from Database

    Hi all, I am having a scenario in which a query is taking different time keeping other environmental variables constant. When that query runs for 1 user it takes just 2 minutes to fetch result and the DB connection becomes inactive after fetching the

  • Disk Permissions not repaired

    I run Disk Utility>First Aid>Repair Disk Permission every couple of weeks. Until recently running this utility has cleared all repairs. But now I am getting a list of repairs that doesn't "clear" (meaning that the next time I run Repair Disk Permissi

  • Re : stock removal from warehouse to production

    Hi    While creating good issue to production from warehouse using MB1A with movement typw 261 the stock from storage bin is not removed. While using T-code MMBE t-code the stock is nil. If i use t-code LS24 its shows the stock. I want to remove the