How To Send Invoice List as attachment in User Decision Step?

HI All,
I have developed a workflow in which there is one ZMETHOD in which i will get the list of invoices.and that i want to send it as attachment to User Decision Step.
How to do this?
Regards,
Arpita

If your users will have access to MIR4, why not just bind the business object BUS2081 as an adhoc object into your decision step?  That would solve everything pretty nicely, I think. 
Regards,
Sue

Similar Messages

  • Adobe form as attachment to user decision step

    Hi,
    i need to add adobe form as attachement to user decision step in workflow.
    1. i created activity step which call business object method with parameters workitem id
         i am using FM  SAP_WAPI_ATTACHMENT_ADD’  which will return attribute id
         i am passing that attribute with document id to 'ZSOFM'
            ZSOFM <-----------------------------------ZSOFM (Method to task)
          Bindings 'Attach_objects'  <------------- ZSOFM(Task to Workflow).
    2. i created user decision step
        Bindings  'Attach_objects' --------------------> 'Attach_Objects'( Workflow to user decision task).
    but when we execute first activity step in background i am not getting any PDF output .but when we  execute same method from class i can see pdf data is coming is it due to user name WF-Batch.
    when i execute activity step in back ground which will have sy-uname as WF-Batch i am not getting any PDF output data.
    please help how to solve .
    Thanks,
    Phani

    In transaction SWO1 create a z-object lets say zmyobjpdf (you might want to use it as a sub object of your standard object without delegation since they will probably have the same key).
    create a method in that object calling the adobe form.
    set it as the default method in the object header.
    now create an instance of the zmyobjpdf in the workflow for example as an attribute of the original object) and transfer it to the decision task.
    It will be displayed as an attached object pressing it will call the default method - your adobe form.
    If your question was about how to create a function module to display the form see SAP Library - PDF-Based Forms

  • Smart form attachment in User decision step

    Hi,
    i have a requirement to display Smart form in user decision step along with Approce and reject buttons.
    Please guide how to attach a smart form in workflow.
    Thanks.
    Edited by: Sanjay_lnt on Jul 10, 2010 8:13 PM

    Here are some codelines may help you.
      CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'
        EXPORTING
          region                = 'B'
        IMPORTING
          folder_id             = lv_folder
        EXCEPTIONS
          communication_failure = 1
          owner_not_exist       = 2
          system_failure        = 3
          x_error               = 4
          OTHERS                = 5.
      lv_object-objla    = 'EN'.
      lv_object-objnam   = 'MESSAGE'.
      lv_object-objdes   = p_name.
      lv_object-file_ext = 'PDF'.
      CALL FUNCTION 'SO_DOCUMENT_INSERT'
        EXPORTING
          parent_id                        = lv_folder
          object_hd_change                 = lv_object
          document_type                    = 'EXT'
       IMPORTING
          document_id                      = lv_doc
       TABLES
         objcont_bin                     = it_objcont_bin " Your binary file data
       EXCEPTIONS
         active_user_not_exist            = 1
         dl_name_exist                    = 2
         folder_not_exist                 = 3
         folder_no_authorization          = 4
         object_type_not_exist            = 5
         operation_no_authorization       = 6
         owner_not_exist                  = 7
         parameter_error                  = 8
         substitute_not_active            = 9
         substitute_not_defined           = 10
         x_error                          = 11
         OTHERS                           = 12     .
    Now pass the folder details to AttachObjects of BO type SOFM
    Edited by: Saurabh Thalpati on Jul 14, 2010 12:20 PM

  • Send Invoice as PDF Attachment with variable Filename

    Hello!
    We got a requirement from one customer. We should send our invoices as PDF-Attachment via E-Mail but the attachment must have a variable filename. At the Moment we can send invoice as PDF-Attachment but only with a fix filename.
    How can we change the filename in our Adobe Forms?
    Best Regards
    Markus

    Hi Florian!
    Answer 1:
        The original Name is Druckdaten.pdf
    Answer 2:
         Our entry in NAST-NACHA = 1
    Answer 3:
         I can implement some ABAP-Code
    Here some Screenshots:
    Configuration  of printer E-MAIL:
    Best regards
    Markus

  • How to send SMARTFORMS output as attachment through?

    how to send SMARTFORMS output as attachment through e-mail?
    after executing SMARTFORMS how to send that output via e-mail.
    Help me.
    thanks
    surya.
    Moderator Message: Please search for available information first
    Edited by: kishan P on Nov 7, 2010 7:19 PM

    hi Vinod,
    Can you please tell me how you have zipped the file.
    I am having a text file in application server. I need to zip that file. Then the middleware moves it to Legacy system.
    I used the following code. With this I am having the data in Binary format which my midleware cannot understand.
    What I need on the whole is just to reduce the size of the file.
    form ZIP_FILE .
    DATA: lt_data TYPE TABLE OF x255,
          lt_textdata TYPE TABLE OF x255.
    DATA: ls_data LIKE LINE OF lt_data.
    DATA: lv_dsn1(100) VALUE '/ECD/120/GIS/FTP/IB/DNBPAYDEX.TXT'.
    DATA: lv_dsn3(100) VALUE '/ECD/120/GIS/FTP/IB/DNBPAYDEXZIP.zip'.
    *DATA: lv_dsn3(100) VALUE '/interfaces/SM5/test.zip'. " Contains sample1.xls and sample2.xls
    DATA: lv_file_length TYPE i.
    DATA: lv_content TYPE xstring.
    DATA: lo_zip TYPE REF TO cl_abap_zip.
    CREATE OBJECT lo_zip.
    Read the data as a string
    clear lv_content .
    OPEN DATASET lv_dsn1 FOR INPUT IN BINARY MODE.
    READ DATASET lv_dsn1 INTO lv_content .
    CLOSE DATASET lv_dsn1.
    lo_zip->add( name = 'sample.TXT' content = lv_content ).
    lv_content = lo_zip->save( ).
    *clear lv_content .
    Conver the xstring content to binary
    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
    buffer = lv_content
    IMPORTING
    output_length = lv_file_length
    TABLES
    binary_tab = lt_data.
    OPEN DATASET lv_dsn3 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    LOOP AT lt_textdata INTO ls_data.
    TRANSFER ls_data TO lv_dsn3.
    ENDLOOP.
    CLOSE DATASET lv_dsn3.
    IF sy-subrc EQ '0'.
        MESSAGE s999(zfi_ap_gl) WITH text-t10.
      ENDIF.
    Can you please help.
    Thanks Aravind

  • How to send txt file  as attachement in email

    Hi Experts ,
    How to send  txt file  as attachement in email .
    which function module i use

    Hi,
    Try to use this one
    CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
    Hope it can solve your problem!
    Good luck!
    Tao

  • How to create Invoice list??

    Hi guyz,
    could you please tell me how to create invoice list, i have created sales order, done the delivery,created billing.
    appreciate immediate reply.
    Thanks.
    Mohammed.

    Hi Mohammed,
    To create an invoice list:
    Select the Billing screen.
    Depending on the number of billing documents that you want to include, you can choose one of two ways to create the invoice list. You can either
    · Select Invoice list Create and enter each billing document separately
    · Create a list for all billing documents that are relevant for the invoice list. You can then process the work list for invoice lists.
    This procedure shows you how to create the work list.
    Select Invoice list Edit work list.
    Enter your selection criteria and press ENTER.
    The system displays a list of billing documents that meet your selection criteria.
    Select the billing documents that you want to include in the invoice list and select Invoice list Save.
    You can also simulate creation of invoice lists via the work list for invoice lists. This is useful as a test option. The simulation also allows you to carry out a split analysis, which shows you why billing documents are written to different invoice lists (e.g. due to different payers).
    Prerequisites
    You can only process invoice lists if the following prerequisite data is defined by your system administrator in Customizing for Sales:
    Condition type RL00 (factoring discount) must be maintained and, if required, also the condition type MW15.
    An invoice list type must be assigned to each billing type that you want to process in invoice lists. The standard version of the SAP R/3 System includes two types of invoice lists: LR for invoices and debit memos, LG for credit memos.
    Copying requirements must be defined (for example, the payer, terms of payment and other fields that must be identical in the documents to be included in the invoice list)
    In addition, before you process an invoice list, you must maintain the following master data:
    A customer calendar must be defined, specifying the time intervals or dates on which invoice lists are to be processed.
    The customer calendar must be entered in the Billing Sales Area view of the customer master record.
    Pricing condition records for the condition type RL00 and, if necessary, (e.g. in Germany) the condition type MW15 must be maintained.
    Output condition records for condition types LR00 and RD01 must be created.
    Hope with this info you can do it. Pl. reward if it helps.
    Thanks & Regards
    Sadhu Kishore

  • How to send more than 1 attachment thru email

    Hi All,
    Need to know how to send more than one attachment through email.  I need the coding part of it.
    Thanks in Advance.
    Balaji

    Hi Balaji,
    Check this thread
    Sending mail with 2 attachments
    Regards,
    Santosh

  • Maint. Order as Attachment in workflow decision step!!!!

    Hi All,
    I am making a workflow in which i want to attach the Maintenance Order in the Decision Step , is it possible or not.
    How can i do attachment in Send Mail Step is there any provision.
    Basically my requirement is like:-
    When the User create the Maintenance Order a workflow should trigger which will go the SAP Inbox of the recipient now he has to see the maint. Order created and should approve if it can be Released or not .
    When he does the approval the application should go for the another approval and when he approves the application is sent back to the workflow initiator.
    Please suggest me what is the best way to do this scenerio. As i m very new to workflow so have only basic knowledge
    Please help me out!!!!!
    Thanks

    Hi Rachit,
    Have a look at std WF like WS20000014, WS20000021 etc..
    It will give idea about maintenace order processing
    Regarding your question about attaching objet to User decision, yes, its possible. Just Bind the Maintenance Order Object related container element to AdhocObjects elemnet of user decision.
    Your overall process can be there will be 2 user decision steps.
    Once these two steps approve, then you can use a third step with background task which will actually release the maintenace order. e.g. For this step you can use BAPI.
    Hope this helps.
    Regds,
    Akshay

  • Creating attachment in User decision activity.

    I am running a background ABAP report and the output of report is to be attached to the WI for user. The user will receive the decision step with attachment which includes report output as excel.
    please suggest how can I achieve it. How can I attach report output to WF that will be going for user approval.

    Hi Verma,
                      To show Output in Excel Format use document form Template step type and immediately followed by User decision so that when the user executes he will first see the excel sheet then he can take a decision on it.
    If u want a display on the same user decision step type then make that method as default methos and bind it to the USER Decision container.
    Regards,
    Dheepak

  • 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

  • How to send current list item URL in email by using sharepoint 2010 workflow?

    Hi All,
    I had created sharepoint workflow usind SPD 2010. when new item is created it sends the email with link. But it sends current list link not the current item link.
    I tried to use Encoded Absolute URL but this like
    http://asdf.com/Lists/abc/10.00
    but i need something like this
    http://asdf.com/Lists/abc/DispForm.aspx?ID
    I have grow thorough some post and i found that,
    Statically i can write http://asdf.com/Lists/abc/DispForm.aspx?ID= and from Add lookup i can get ID by choosing current item.
    The link which i get is partially hyperlink like this
    http:aasdf.com/Lists/abc/DispForm.aspx?ID=10 (here 10 is not hyperlink)
    when i copy and paste this link it works fine but by clicking it i am not getting true result.
    Please help me to solve this issue.
    Thanks.

    Hi Raymond,
    It works for me. Thank you so much.
    I also have another issue related workflow. If you can help me, i really appreciate you.
    I already configured AAM. I have two Share Point Address which are:
    Default : http://default.com
    Internal : http://intranet.com
    I have List workflow using SharePoint Designer 2010. When new item get create, it sends email to person for approval. But when it sends email it sends Dafault zone URL.
    Dafault zone URL is only accessible through Virtual Machine. We cant access from local machine. So i need to send intranet zone URL in email so user can open through local machine.
    I tried it but i can only able to do for one list. I have to so this general for every list.
    How can i send intranet zone URL?
    Swapping the zone URL is not solution for this issue because after swapping situation is same.
    Thank You.

  • How to send a text file attachment through mail in ECC 6.0

    Hi Friends,
    As per the requirement, I need to send a ALV report result as text file attachment to user in ECC 6.0 . I know how to do in 4.6C version. But the same code is not working here in ECC 6.0.
    Generally to get the data in new row in the text file we use below code in 4.6c.
    data: c_value type x value ' 0D '.
    concatenate c_value itab-line into itab-line.
    By using above code, we get each row of the itab in a new line in text file.
    Same code is not working in ECC6.0 as it is not supporting  to concatenate bytes with characters. Getting the error like " field c_value should be diclared as type C or I or N or T or P"
    Even I have used function module NLS_STRING_CONVERT_TO_SYS to convert hexa to char. It is converting the value' 0D' to ' # '. But it is not working.
    Could you please suggest me that how can get each row of itab as a new line in text file in ECC 6.0.
    Itab value:
    abcdefdfldjfñlkdsjfñldsjfdsñljñla
    fdsljfñldskjfldsñkjfñldsjfñldsajñld
    vcxusfcxusfcusafcxusafcusafcdsauc
    Actual result currently coming in text file:
    abcdefdfldjfñlkdsjfñldsjfdsñljñlafdsljfñldskjfldsñkjfñldsjfñldsajñldvcxusfcxusfcusafcxusafcusafcdsauc
    Expected result in text file:
    abcdefdfldjfñlkdsjfñldsjfdsñljñla
    fdsljfñldskjfldsñkjfñldsjfñldsajñld
    vcxusfcxusfcusafcxusafcusafcdsauc
    Please do the needful.
    Thanks
    Kumar

    hi,
    Try this function Module
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1 '
    *example code
    ******* Create Message Body Title and Description****************
      i_objtxt = 'test with pdf-Attachment!'.
      append i_objtxt.
      describe table i_objtxt lines v_lines_txt.
      read table i_objtxt index v_lines_txt.
      wa_doc_chng-obj_name = 'smartform'.
      wa_doc_chng-expiry_dat = sy-datum + 10.
      wa_doc_chng-obj_descr = 'smartform'.
      wa_doc_chng-sensitivty = 'F'.
      wa_doc_chng-doc_size = v_lines_txt * 255.
    **** Main Text*****************************
      clear i_objpack-transf_bin.
      i_objpack-head_start = 1.
      i_objpack-head_num = 0.
      i_objpack-body_start = 1.
      i_objpack-body_num = v_lines_txt.
      i_objpack-doc_type = 'RAW'.
      append i_objpack.
    **** Attachment (pdf-Attachment)*************
      i_objpack-transf_bin = 'X'.
      i_objpack-head_start = 1.
      i_objpack-head_num = 1.
      i_objpack-body_start = 1.
      i_objpack-body_num = v_lines_bin.
      i_objpack-doc_type = 'PDF'.
      i_objpack-obj_name = 'smartform'.
      concatenate i_objpack-obj_name i_objpack-doc_type into
    i_objpack-obj_descr separated by '.'.
    *  I_OBJPACK-OBJ_DESCR = 'test'.
      i_objpack-doc_size =  v_lines_bin * 255 .
      append i_objpack.
    * Länge des Attachment ermitteln
      clear i_reclist.
      i_reclist-receiver = 'email address'.
      i_reclist-rec_type = 'U'.
      i_reclist-express = 'X'.
      data: tab_lines like sy-tabix.
      describe table i_objbin lines tab_lines.
      append i_reclist.
      call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        exporting
          document_data              = wa_doc_chng
          put_in_outbox              = 'X'
          commit_work                = 'X'
        tables
          packing_list               = i_objpack
          object_header              = wa_objhead
          contents_bin               = i_objbin
          contents_txt               = i_objtxt
          receivers                  = i_reclist
        exceptions
          too_many_receivers         = 1
          document_not_sent          = 2
          document_type_not_exist    = 3
          operation_no_authorization = 4
          parameter_error            = 5
          x_error                    = 6
          enqueue_error              = 7
          others                     = 8.
      if sy-subrc <> 0.
        write:/ 'Error When Sending the File', sy-subrc.
      else.
        write:/ 'Mail sent'.
      endif.

  • How to send mail with pdf attachment.

    hello,
    I want to know if I can send a pdf attachment via mail. My PDF file is somewhere in the server and its content doesn't need to be changed by the program. the program just needs to find the pdf in server, then it will just send pdf file as attachment to the mail. is it possible ? thanks in advance.

    Hi Friend,
    You can easily send the document by email as follows :
    REPORT ZSENDEXTERNAL.
    DATA: OBJPACK   LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
    DATA: OBJHEAD   LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
    DATA: OBJBIN    LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    DATA: OBJTXT    LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    DATA: RECLIST   LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
    DATA: DOC_CHNG  LIKE SODOCCHGI1.
    DATA: TAB_LINES LIKE SY-TABIX.
    Creation of the document to be sent
    File Name
    DOC_CHNG-OBJ_NAME = 'SENDFILE'.
    Mail Subject
    DOC_CHNG-OBJ_DESCR = 'Send External Mail'.
    Mail Contents
    OBJTXT = 'Minimum bid : $250000'.
    APPEND OBJTXT.
    OBJTXT = 'A representation of the pictures up for auction'.
    APPEND OBJTXT.
    OBJTXT = 'was included as attachment.'.
    APPEND OBJTXT.
    DESCRIBE TABLE OBJTXT LINES TAB_LINES.
    READ TABLE OBJTXT INDEX TAB_LINES.
    DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
    Creation of the entry for the compressed document
    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.
    Creation of the document attachment
    (Assume that the data in OBJBIN is in BMP format)
    *OBJBIN = ' \O/ '. APPEND OBJBIN.
    *OBJBIN = ' | '. APPEND OBJBIN.
    *OBJBIN = ' / \ '. APPEND OBJBIN.
    *DESCRIBE TABLE OBJBIN LINES TAB_LINES.
    *OBJHEAD = 'PICTURE.BMP'.
    *APPEND OBJHEAD.
    Creation of the entry for the compressed attachment
    *OBJPACK-TRANSF_BIN = 'X'.
    *OBJPACK-HEAD_START = 1.
    *OBJPACK-HEAD_NUM = 1.
    *OBJPACK-BODY_START = 1.
    *OBJPACK-BODY_NUM = TAB_LINES.
    *OBJPACK-DOC_TYPE = 'PDF'.
    *OBJPACK-OBJ_NAME = 'PICTURE'.
    *OBJPACK-OBJ_DESCR = 'Representation of object 138'.
    *OBJPACK-DOC_SIZE = TAB_LINES * 255.
    *APPEND OBJPACK.
    Completing the recipient list
    RECLIST-RECEIVER = <External Email id >.
    RECLIST-REC_TYPE = 'U'.
    APPEND RECLIST.
    *RECLIST-RECEIVER = 'SAPUSERNAME'.
    *RECLIST-REC_TYPE = 'P'.
    *APPEND RECLIST.
    Sending the document
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
       DOCUMENT_DATA = DOC_CHNG
       PUT_IN_OUTBOX = '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
       OPERATION_NO_AUTHORIZATION = 4
    OTHERS = 99.
    CASE SY-SUBRC.
       WHEN 0.
       WRITE: / 'Result of the send process:'.
    LOOP AT RECLIST.
       WRITE: / RECLIST-RECEIVER(48), ':'.
       IF RECLIST-RETRN_CODE = 0.
          WRITE 'The document was sent'.
       ELSE.
          WRITE 'The document could not be sent'.
    ENDIF.
    ENDLOOP.
    WHEN 1.
       WRITE: / 'No authorization for sending to the specified number',
                'of recipients'.
    WHEN 2.
       WRITE: / 'Document could not be sent to any recipient'.
    WHEN 4.
       WRITE: / 'No send authorization'.
    WHEN OTHERS.
       WRITE: / 'Error occurred while sending'.
    ENDCASE.
    Regards
    Dhirendra Pandit

  • How to send a mail with attaching a report

    hi gurus,
        my requirment is i have to send a mail with attaching the report of a program to the client.. is it possible? help me with sample code.
    Thanks in advance.
    Regards,
    Indira D

    Hi Indira,
    plz check out this code below,
    *& Report  ZATTACH                                               *
    REPORT  ZATTACH                   .
    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
    <b>
    Reward points if this helps,</b>
    Kiran

Maybe you are looking for

  • Firefox will not open old tabs

    My computer crashed last evening and on restarting firefox, it goes to a new page without any of the old tabs available. Going under history has all of the options regarding restoring recently closed windows greyed out. I did confirm that under prefe

  • Headers & Footers

    Hey guys, Im hoping someone can help me.....and please excuse my ignorance as I am very new to RoboHelp and not totally "Computer Savvy". I didnt even know it exsisted until I got this new job! I dont really have time to go searching to see if this h

  • T400 DVD drive stops spinning

    I just had to install my third hard drive in this lemon of a computer. I'm running XP SP3 with all current updates. The bios and dvd drivers that were installed by Thinkvantage Productivity Center are newer than what are listed on the Lenovo updates

  • OSB Console - Order by num messages not ordering correctly

    I am a consultant with experience in SOA Suite 11g, but I don't know much about OSB. I have a customer who is complaining that in OSB console he cannot sort by the number of messages received. There is a view with a table in the admin console webapp

  • Unable to open ichat

    I have an icon for ichat in my applications, but it is just a picture of paper with a pencil, paintbrush, and a ruler. When I click the link to open ichat, nothing happens. I tried reinstalling ilife, but to there was no change. any ideas what is goi