To Add attachment to the Mail

Hi Gurus,
I am using the folwing program to sent mail to sapusers.
In that i want to add Attachments. i dont know how to do?
Can anyone Help me.
*& Report  ZMAIL1                                                      *
report yvenkatesh_send_express_mail .
Internal Tables                                                     *
For Sending the express mail
data: itab_objhead          like soli       occurs 0 with header line,
      itab_objcont          like soli       occurs 0 with header line,
      itab_objpara          like selc       occurs 0 with header line,
      itab_objparb          like soop1      occurs 0 with header line,
      itab_receivers        like soos1      occurs 0 with header line.
Work Areas                                                          *
For Sending the express mail
data: w_object_hd_change   like sood1.
counters
data: w_ok_count(10)       type n.
data: w_err_count(10)      type n.
data: w_tot_count(10)      type n.
start-of-selection                                                  *
start-of-selection.
  w_ok_count = 200.
  w_err_count = 300.
  w_tot_count = 500.
End-of-selection                                                    *
end-of-selection.
Initialize the fields
  clear: w_object_hd_change.
  clear: itab_objcont, itab_objhead, itab_objpara,
         itab_objparb, itab_receivers.
  refresh: itab_objcont, itab_objhead, itab_objpara,
           itab_objparb, itab_receivers.
Fill the message text
  concatenate 'Number of records processed:' w_tot_count
         into itab_objcont-line separated by space.
  append itab_objcont.
  concatenate 'Number of records processed Correctly:' w_ok_count
         into itab_objcont-line separated by space.
  append itab_objcont.
  concatenate 'Number of records Errored Out:' w_err_count
         into itab_objcont-line separated by space.
  append itab_objcont.
Fill w_object_hd_change structure
  w_object_hd_change-objla   = sy-langu.
  w_object_hd_change-objnam  = sy-repid.
  w_object_hd_change-objdes  = 'Job ABC results'.
  w_object_hd_change-objsns  = 'F'.
  w_object_hd_change-vmtyp   = 'T'.
  w_object_hd_change-skips   = 'X'.
  w_object_hd_change-acnam   = 'SP01'. "Transaction to execute Special-Code
  w_object_hd_change-objcp   = 'X'.
Specify the receivers
  itab_receivers-rcdat = sy-datum.
  itab_receivers-rctim = sy-uzeit.
  itab_receivers-recnam = sy-uname.    "Send to UserId"
  itab_receivers-rtunam = sy-uname.
  itab_receivers-sndex  = 'X'.         "Express mail message.
  append itab_receivers.
Specify the spool info.     "Special-Code
  itab_objpara-name = 'SPI'.  "Special-Code
  itab_objpara-low  = sy-spono. "Special-Code
  append itab_objpara. "Special-Code
  call function 'SO_OBJECT_SEND'
       exporting
            object_hd_change = w_object_hd_change
            object_type      = 'RAW'
            owner            = sy-uname
       tables
            objcont          = itab_objcont
            objhead          = itab_objhead
            objpara          = itab_objpara
            objparb          = itab_objparb
            receivers        = itab_receivers
       exceptions
            others           = 01.
Regards,
Bhuvana.

Hello,
Check this sample code.
REPORT ZV_SEND_MAIL .
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
Cheers,
Vasanth

Similar Messages

  • Adapter Module Error-Sending excel file as an attachment of the mail

    Hi ,
    My scenario is as follows
    1)I am sending an excel file as an attachment of the mail.I need to read that excel attachment as a payload.
    So mail adapter is used in sender side.
      To configure this, have used standard PayloadSwapBean  module with proper module key.
      Next to convert excel to XML another custom adapter module is being used.
    Both this adapter module , I configured into the CC of sender mail adapter.
    The order in which adapter modules are being used in the sender CC are as follows
    1)localejbs/AF_Modules/PayloadSwapBean
    2)localejbs/MDPExcelToXMLConversion
    3)sap.com/com.sap.aii.adapter.mail.app/XIMailAdapterBean
    MDPExcelToXMLConversion-Custom adapter module written to convert excel to xml.
    I am getting the following error
    exception caught during processing mail message [4899]com.sap.aii.af.lib.mp.module.ModuleException
    And also,
    no messages in coming MONI of PI.
    Pls suggest what to do.
    Thanks
    Ayan

    Shabarish,
    Will the ordering in which the adapter modules(In this case there are two-PayloadSwapBean & MDPExcelToXML) are appearing into Module tab of sender adapter matter?
    Firstly, what is happenning
    1)If I take out the custom  adapter module MDPExcelToXML and put only PayloadSwapBean  then it is successfully converting mail attachment into the main Payload i.e PayloadSwapBean   module is working.
    2)Nextly, my local code( i.e java code without including standard Module specific method like ejbActivate(),ejbPassivate(),process()  etc etc.)) for MDPExcelToXML is successfuly converting the excel file into the XML file.Then I am making the local code into adapter module specific code and deploying that.
    A few question arises here,
    Do I need to do any specific configurations here in PI for this particular things.Maybe both the adapter module is clashing with each other.
    And also using tracing and logging into my custom adapter module code.Getting the following error,
    java.io.IOException: Unable to read entire header; 116 bytes read; expected 512 bytes#
    Thanks
    Ayan

  • ADD ATTACHMENT TO AUTO MAIL SENT DURING BIDDER CREATION

    HOW TO ADD ATTACHMENT TO AUTO MAIL SENT DURING BIDDER CREATION (CREATE CONTACT PERSON) IN SRM PORTAL..

    HOW TO ADD ATTACHMENT TO AUTO MAIL SENT DURING BIDDER CREATION (CREATE CONTACT PERSON) IN SRM PORTAL..

  • How can we add attachment in the PO using BAPI

    How can we add attachment in the PO? I am using the BAPI_PO_CREATE1 function module to create the PO. I am getting a file from legacy system, this I need to add as an attachment into the particular PO through programming.
    Note: After creation of PO the attachment should be available in ME23n transaction.

    REPORT  ZBAPI_PO_CRATE.
    data : PO_HEADER like BAPIEKKOC.
    data : PO_HEADER_ADD_DATA like BAPIEKKOA.
    data : PO_ITEMS like BAPIEKPOC occurs 0 with header
    line.
    data : PO_ITEM_SCHEDULES like BAPIEKET occurs 0 with
    header line.
    data : RETURN like BAPIRETURN occurs 0 with header
    line.
    DATA : BEGIN OF TAB OCCURS 0,
           PO_NUMBER like BAPIEKKOC-PO_NUMBER,
           DOC_DATE(10),
           DOC_TYPE like BAPIEKKOC-DOC_TYPE,
           CO_CODE like BAPIEKKOC-CO_CODE,
           PURCH_ORG like BAPIEKKOC-PURCH_ORG,
           PUR_GROUP like BAPIEKKOC-PUR_GROUP,
           VENDOR like BAPIEKKOC-VENDOR,
           PMNTTRMS like BAPIEKKOA-PMNTTRMS,
           INCOTERMS1 like BAPIEKKOA-INCOTERMS1,
           INCOTERMS2 like BAPIEKKOA-INCOTERMS2,
           PO_ITEM like  BAPIEKPOC-PO_ITEM,
           MATERIAL like BAPIEKPOC-MATERIAL,
           PUR_MAT like BAPIEKPOC-PUR_MAT,
           ITEM_CAT like BAPIEKPOC-ITEM_CAT,
           PLANT like BAPIEKPOC-PLANT,
           NET_PRICE like BAPIEKPOC-NET_PRICE,
           TAX_CODE like BAPIEKPOC-TAX_CODE,
           DELIV_DATE(10),
           QUANTITY like BAPIEKET-QUANTITY,
         end of tab.
    data: itab1 like alsmex_tabline occurs 0 with header
    line.
    DATA: gd_currentrow type i.
    data : PURCHASEORDER like ekko-ebeln.
    Data: tot_rec type i,     "Total Records
         gd_update type i,   "Main Table Increement
    Counter
         gd_lines type i,    "Success Table increement
    Counter
         w_textout like t100-text. "VARIABLE TO GET ERROR
    LOG
    data : begin of it_success occurs 0,
            PURCHASEORDER LIKE ekko-ebeln,  "PROJECT
          end of it_success.
    data : begin of it_error occurs 0,
            pono like  ekko-ebeln,
            err_msg(73) TYPE c,    "TO RETREIVE ERROR
    MESSAGES
         end of it_error.
    data : pono like  ekko-ebeln.
    selection-screen begin of block b1 with frame.
    skip 3.
    parameter:p_infile like rlgrap-filename obligatory.
    skip 3.
    selection-screen end  of block b1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_infile.
      PERFORM value_help.
    start-of-selection.
      call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          filename                = p_infile
          i_begin_col             = '1'
          i_begin_row             = '2' "Do not require
    headings
          i_end_col               = '22'
          i_end_row               = '10000'
        TABLES
          intern                  = itab1
        EXCEPTIONS
          inconsistent_parameters = 1
          upload_ole              = 2
          others                  = 3.
      if sy-subrc <> 0.
        message e010(zz) with text-001. "Problem uploading
    Excel Spreadsheet
      endif.
    *perform open_group.
      sort itab1 by row col.
    * Get first row retrieved
      read table itab1 index 1.
    * Set first row retrieved to current row
      gd_currentrow = itab1-row.
      loop at itab1.
    * Reset values for next row
        if itab1-row ne gd_currentrow.
          append tab .
          clear tab.
          gd_currentrow = itab1-row.
        endif.
        case itab1-col.
          when '0001'. "PGNAM
            TAB-PO_NUMBER = itab1-value.
          when '0002'. "RONAM
            TAB-DOC_DATE = itab1-value.
          when '0003'. "JVLEVEL
            TAB-DOC_TYPE = itab1-value.
          when '0004'. "FTTYPE
            TAB-CO_CODE = itab1-value.
          when '0005'. "LANG
            TAB-PURCH_ORG =  itab1-value.
          when '0006'. "LTEXT
            TAB-PUR_GROUP = itab1-value.
          when '0007'. "LTEXT
            TAB-VENDOR = itab1-value.
          when '0008'. "LTEXT
            TAB-PMNTTRMS = itab1-value.
          when '0009'. "LTEXT
            TAB-INCOTERMS1 = itab1-value.
          when '0010'. "FTTYPE
            TAB-INCOTERMS2 = itab1-value.
          when '0011'. "FTTYPE
            TAB-PO_ITEM = itab1-value.
          when '0012'. "FTTYPE
            TAB-MATERIAL = itab1-value.
          when '0013'. "FTTYPE
            TAB-PUR_MAT = itab1-value.
          when '0014'. "FTTYPE
            TAB-ITEM_CAT = itab1-value.
          when '0015'. "FTTYPE
            shift itab1-value left deleting leading space.
            TAB-PLANT = itab1-value.
          when '0016'. "FTTYPE
            TAB-NET_PRICE = itab1-value.
          when '0017'. "FTTYPE
            TAB-TAX_CODE = itab1-value.
          when '0018'. "FTTYPE
            TAB-DELIV_DATE = itab1-value.
          when '0019'. "FTTYPE
            TAB-QUANTITY = itab1-value.
        endcase.
      endloop.
      append tab.
      clear tab.
      sort tab by PO_NUMBER.
      DELETE TAB WHERE PO_NUMBER = SPACE.
      loop at tab.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            INPUT  = tab-material
          IMPORTING
            OUTPUT = tab-material.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            INPUT  = tab-PUR_MAT
          IMPORTING
            OUTPUT = tab-PUR_MAT.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            INPUT  = tab-vendor
          IMPORTING
            OUTPUT = tab-vendor.
        concatenate tab-doc_DATE+4(4) tab-doc_DATE+2(2)
    tab-doc_DATE+0(2)
    into tab-doc_DATE.
        concatenate tab-DELIV_DATE+4(4)
    tab-DELIV_DATE+2(2)
    tab-DELIV_DATE+0(2) into tab-DELIV_DATE.
        pono = tab-PO_NUMBER.
        if tab-po_number = pono.
          PO_HEADER-DOC_DATE = tab-DOC_DATE.
          PO_HEADER-DOC_TYPE = tab-DOC_TYPE.
          PO_HEADER-CO_CODE  = tab-CO_CODE.
          PO_HEADER-PURCH_ORG = tab-PURCH_ORG.
          PO_HEADER-PUR_GROUP = tab-PUR_GROUP.
          PO_HEADER-VENDOR = tab-VENDOR.
          PO_HEADER-PO_NUMBER = tab-PO_NUMBER.
          PO_HEADER_ADD_DATA-PMNTTRMS = tab-PMNTTRMS.
          PO_HEADER_ADD_DATA-INCOTERMS1 = tab-INCOTERMS1.
          PO_HEADER_ADD_DATA-INCOTERMS2 = tab-INCOTERMS2.
          PO_ITEMS-PO_ITEM = tab-PO_ITEM.
          PO_ITEMS-MATERIAL = tab-MATERIAL.
          PO_ITEMS-PUR_MAT = tab-PUR_MAT.
          PO_ITEMS-ITEM_CAT = tab-ITEM_CAT.
          PO_ITEMS-PLANT = tab-PLANT.
          PO_ITEMS-NET_PRICE = tab-NET_PRICE.
          PO_ITEMS-TAX_CODE = tab-TAX_CODE.
          append po_items.
          PO_ITEM_SCHEDULES-PO_ITEM = tab-PO_ITEM.
          PO_ITEM_SCHEDULES-DELIV_DATE = tab-DELIV_DATE.
          PO_ITEM_SCHEDULES-QUANTITY =  tab-QUANTITY.
          append PO_ITEM_SCHEDULES.
        endif.
        at end of PO_NUMBER.
          CALL FUNCTION 'BAPI_PO_CREATE'
            EXPORTING
              PO_HEADER                        = PO_HEADER
             PO_HEADER_ADD_DATA               =
    PO_HEADER_ADD_DATA
    *           HEADER_ADD_DATA_RELEVANT         =
    *           PO_ADDRESS                       =
    *           SKIP_ITEMS_WITH_ERROR            = 'X'
    *           ITEM_ADD_DATA_RELEVANT           =
    *           HEADER_TECH_FIELDS               =
           IMPORTING
             PURCHASEORDER                    =
    PURCHASEORDER
            TABLES
              PO_ITEMS                         = PO_ITEMS
    *           PO_ITEM_ADD_DATA                 =
              PO_ITEM_SCHEDULES                =
    PO_ITEM_SCHEDULES
    *           PO_ITEM_ACCOUNT_ASSIGNMENT       =
    *           PO_ITEM_TEXT                     =
             RETURN                            = RETURN
    *           PO_LIMITS                        =
    *           PO_CONTRACT_LIMITS               =
    *           PO_SERVICES                      =
    *           PO_SRV_ACCASS_VALUES             =
    *           PO_SERVICES_TEXT                 =
    *           PO_BUSINESS_PARTNER              =
    *           EXTENSIONIN                      =
    *           POADDRDELIVERY                   =
          if PURCHASEORDER <> space.
            commit work.
            ADD 1 TO gd_update.
            it_success-PURCHASEORDER = PURCHASEORDER.
            append it_success.
    clear:PO_HEADER,PO_HEADER_ADD_DATA,PURCHASEORDER.
            refresh : PO_ITEMS,PO_ITEM_SCHEDULES,RETURN.
          ELSE.
            loop at return.
              it_error-pono = tab-PO_NUMBER.
              it_error-err_msg = return-MESSAGE .
              Append it_error.
            ENDLOOP.
    clear:PO_HEADER,PO_HEADER_ADD_DATA,PURCHASEORDER.
            refresh : PO_ITEMS,PO_ITEM_SCHEDULES,RETURN.
          endif.
        endat.
      endloop.
      DESCRIBE TABLE it_success LINES gd_lines.
      IF gd_lines GT 0.
    *     Display result report column headings
        PERFORM display_column_headings.
    *     Display result report
        PERFORM DISPLAY_SUCESS.
      ENDIF.
    * IF SUCESS FAILS Display Error Report
      DESCRIBE TABLE it_error LINES gd_lines.
      IF gd_lines GT 0.
        PERFORM errorheadings.
        PERFORM errorreport.
      ENDIF.
    *&      Form  display_column_headings
    *       text
    FORM display_column_headings.
      WRITE:2 ' Success Report '(014) COLOR COL_POSITIVE.
      SKIP.
      WRITE:2 'The following records inserted
    successfully:'(013).
      WRITE:/ sy-uline(15).
      FORMAT COLOR COL_HEADING.
      WRITE:/      sy-vline,
               (10) 'Purchase order'(004), sy-vline.
      WRITE:/ sy-uline(15).
    ENDFORM.                    "display_column_headings
    *Subroutine to display SUCESS REPORT
    FORM DISPLAY_SUCESS.
      FORMAT COLOR COL_NORMAL.
      LOOP AT it_success.
        WRITE:/      sy-vline,
            (10)  it_success-PURCHASEORDER, sy-vline.
        CLEAR it_success.
      ENDLOOP.
      WRITE:/ sy-uline(15).
      REFRESH: it_success.
      FORMAT COLOR COL_BACKGROUND.
    ENDFORM.                               "
    DISPLAY_REPORT
    *&      Form  errorreport
    *       text
    FORM errorreport.
      LOOP AT it_error.
        WRITE:/      sy-vline,
                (10) it_error-pono, sy-vline,
                 (40) it_error-err_msg, sy-vline.
      ENDLOOP.
      WRITE:/ sy-uline(104).
      REFRESH: it_error.
    endform.                    "errorreport
    *&      Form  ERRORHEADINGS
    *       text
    FORM ERRORHEADINGS.
      SKIP.
      WRITE:2 ' Error Report '(007) COLOR COL_NEGATIVE.
      SKIP.
      WRITE:2 'The following records failed during
    update:'(008).
      WRITE:/ sy-uline(104).
      FORMAT COLOR COL_HEADING.
      WRITE:/      sy-vline,
              (10) 'ERROR.'(009), sy-vline.
      WRITE:/ sy-uline(104).
      FORMAT COLOR COL_NORMAL.
    ENDFORM.                    "ERRORHEADINGS
    **&      Form  value_help
    **       text
    **  -->  p1        text
    **  <--  p2        text
    FORM value_help .
      CALL FUNCTION 'DSVAS_DOC_WS_FILENAME_GET_50'
        EXPORTING
          DEF_FILENAME     = ' '
          DEF_PATH         = ' '
          MASK             = ',*.*,*.*.'
          MODE             = 'O'
          TITLE            = ' '
        IMPORTING
          FILENAME         = p_infile
        EXCEPTIONS
          INV_WINSYS       = 1
          NO_BATCH         = 2
          SELECTION_CANCEL = 3
          SELECTION_ERROR  = 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.
    endform.                    "value_help

  • Add link in the Mail body

    Hi
    i am doing file to mail scenario. i need to add link in the mail how can we do this. i tried TransformBean. but it's not working could u please help me
    Thank you
    Regards
    Sundher

    Hi Sundher,
    Web Blogs on File Scenario:
    /people/prasad.ulagappan2/blog/2005/06/07/mail-adapter-scenarios-150-sap-exchange-infrastructure
    /people/michal.krawczyk2/blog/2005/03/07/mail-adapter-xi--how-to-implement-dynamic-mail-address
    /people/community.user/blog/2006/09/07/email-reporting
    Check the following links:
    these links should help you clear your doubts regarding Configuring a Receiver Mail Adapter and possibly find the cause for your error.
    http://help.sap.com/saphelp_nw04/helpdata/en/6b/4493404f673028e10000000a1550b0/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/8c/607fe4756b654ab9f420097c29f6e9/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/5d/112d20f6ce6c46ba66afb98d278fbd/frameset.htm
    Ignore the Image part and use this for your file to mail:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/6d967fbc-0a01-0010-4fb4-91c6d38c5816
    Hope it will work for you
    Amaresh

  • I can't use the add attachment options in mail

    Hi all,
    Im having a little bit of trouble here. Everything was working fine. but all of a sudden I can't add attachments to an email in Mac mail by using the add attachments shortcut button or by file add attachments.
    All that happens is after aproximatley 30 secs the button or 'file' is depressed and i can continue using mail but no attachments window ever appears.
    Its not the end of the world as i can still drag and drop files into the email but it can become a pain when having to scroll through the network to find the attachments i require in finder.
    Please Help.
    Ben

    Please follow these instructions to delete the Mail "sandbox" folder.
    Back up all data.
    Triple-click the line below to select it, then copy it to the Clipboard (command-C):
    ~/Library/Containers/com.apple.mail
    Quit Mail.
    In the Finder, select
    Go ▹ Go to Folder
    from the menu bar. Paste (command-V) into the box that opens, then press return. A Finder window should open with a folder named "com.apple.mail" selected. If it does, move the selected folder — not just its contents — to the Desktop. Leave the Finder window open for now.
    Relaunch Mail and test. If the problem is resolved, you'll have to recreate some of your Mail settings. You can then delete the folder you moved and close the Finder window. If you still have the problem, quit Mail again and put the folder back where it was, overwriting the one that may have been created in its place. Post your results.
    Caution: If you change any of the contents of the sandbox, but leave the folder itself in place, Mail may crash or not launch at all. Deleting the whole sandbox will cause it to be rebuilt automatically.

  • Mail from RVADOR01 need to add body of the mail

    Hi Experts,
    How to add mail body for the below case?please look
    I am using output tupe Zmail attached to Program ZRVADOR01 and script form ZRVORDER01.
    The Program ZRVADOR01 and the script ZRVORDER01are copied from standard prog RVADOR01  and standard script RVORDER01.
    And this output type is attached to VA02.
    In the Zprogram i could able to give mail subject in OPEN_FORM function module in OPTIONS parameter.
    And i am sending to the exterid which is outlook.
    For giving the email id i have added some code from the note .357137 before calling the OPEN_FORM function module in the program..
    mail is coming with subject line and attachment of script document .
    But the only thing needed is , add body text for the mail.
    How can i do this?
    Regards
    Ramakrishna

    Hi Rama, I am trying to do the same and noticed that your comments/question appears as "ANSWERED" at the top of the thread.
    Were you able to accomplish this?
    Jacob

  • How to add subject in the mail while choosing option i.e. "Send a copy of the entire PDF file as an

    I need to update the subject in the mail while choosing option i.e. "Send a copy of the entire PDF file as an attachment"?
    How I can add my own subject in the mail while attaching pdf file, currently it shows as "do" subject name which is default every time?

    the normal FILE FTP adapter will do or do we have to use any special Adapter
    File adapter with a bit of modification will do. See this
    XI: Read data from PDF file in Sender Adapter
    Once ur pdf is converted to xml, u can use the java or xsl mapping to map the comlpete xml structure into one field
    The specified item was not found.
    Regards,
    Prateek

  • Excel sheet as an attachment to the mail box

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

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

  • Create pdf attachment to the mail

    Hi folks,
    My requirement is to attach pdf document to the mail step in workflow programatically and document is on presentation server.
         i have tried with SOFM object type, but it is asking for document number , but i could not  provide it because it is not in SAP system.
       how to acheive this.
    Thanks, 
    janakiram.

    try this  copy and paste is and make changes as required
    Enjoy.............
    To create pdf from internal table.
    Two steps
    1. get spool no.
    2. create pdf.
    1. get spool no.
    SELECT *
      FROM zwftrack
      INTO TABLE it_zwftrack
    WHERE wf_id = p_wf_id
       AND action = 'FYA'.
      CALL FUNCTION 'GET_PRINT_PARAMETERS'
        EXPORTING destination            = 'LP01'               " 'LT50'
                  copies                 =  1
                  list_name              = g_rq2name
                  list_text              = 'COMM-PDF NEW-PAGE PRINT ON'
                  immediately            = ' '
                  release                = ' '
                  new_list_id            = 'X'
                  expiration             = g_days
                  line_size              = g_ln_size              " 255 ZTG12
                  line_count             = g_ln_count             " 65 ZTG12
                  layout                 = g_layout " 'X_PAPER'ZTG12
                 SAP_COVER_PAGE         = 'X'
                 RECEIVER               = 'SAP*'
                 DEPARTMENT             = 'System'
                 SAP_OBJECT             = 'RS'
                 AR_OBJECT              = 'TEST'
                 ARCHIVE_ID             = 'XX'
                 ARCHIVE_INFO           = 'III'
                 ARCHIVE_TEXT           = 'Description'
                  no_dialog              = 'X'
        IMPORTING out_parameters         = g_params
                  out_archive_parameters = g_arparams
                  valid                  = g_valid.
    "end of get
      NEW-PAGE PRINT ON
                        NEW-SECTION
                        NO-TITLE
                        PARAMETERS g_params
                        ARCHIVE PARAMETERS g_arparams
                  NO DIALOG.
    ***add at top of comments list
    WRITE:/ 'Contract Analysis Worksheet', 150 'Current Data ( ', l_date, ' ', l_time, ' )'.
    WRITE:/150 'Run # :', wa_zzbedsheet-bdshnum.
    WRITE:/ 'Project ID      :',g_object_no.
    WRITE:/ 'Project         :',g_psr_desc.
    WRITE:/ 'Profit Center   :',g_prctr.
    WRITE:/ 'Project Manager :',g_final_abb_contact.
    WRITE:/ 'RA key          :',g_abgsl.
    WRITE:/ 'Customer        :',l_cust.
    WRITE:/ 'Project Start   :',l_proj_start.
    SKIP 3.
    SORT it_zwftrack BY approver_level.
      LOOP AT it_zwftrack INTO wa_zwftrack.
        AT FIRST.
    WRITE:/ 'Approvers Comments:'.
    SKIP 1.
    WRITE:/1 'Role', 35 'Approved By', 50 'Signature', 75 'Comments'.
    ULINE.
    ENDAT.
        IF wa_zwftrack IS INITIAL.
          SKIP.
        ELSE.
    PERFORM f_get_name USING    wa_zwftrack-approved_by
                       CHANGING g_final_abb_contact.
          WRITE :/ wa_zwftrack-role UNDER 'Role',
                   g_final_abb_contact UNDER 'Approved By',
                   wa_zwftrack-signature UNDER 'Signature',
                   wa_zwftrack-comments UNDER 'Comments'.
        ENDIF.
        CLEAR: g_final_abb_contact.
    insert page break
        IF sy-tabix = w_lines  .
          NEW-PAGE .
        w_lines = 2 * w_lines.
        ENDIF.
      ENDLOOP.
        NEW-PAGE PRINT OFF .
    CLEAR w_tsp01.
    SELECT SINGLE *
      FROM tsp01
      INTO w_tsp01
    WHERE rqowner = sy-uname
       AND rq2name = g_rq2name.        "'COMM-PDF' .
    g_spool_comm = w_tsp01-rqident.
    2. create pdf
        CLEAR g_lines .
        REFRESH it_tab1 .
    ****get comments page from spool
        CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'
          EXPORTING
            rqident              = g_spool_comm                      "spool1
          TABLES
            buffer               = it_tab1
          EXCEPTIONS
            no_such_job          = 1
            job_contains_no_data = 2
            selection_empty      = 3
            no_permission        = 4
            can_not_access       = 5
            read_error           = 6
            OTHERS               = 8.
        IF sy-subrc = 0.
        ENDIF.
    to record line no  for page break .
        DESCRIBE TABLE it_tab1 LINES g_lines.
        MOVE g_lines TO wa_eof-line .
        APPEND  wa_eof TO it_eof .
        CLEAR g_lines .
        APPEND LINES OF it_tab1 TO it_tab.
        REFRESH it_tab1 .
    SELECT SINGLE spld INTO w_spld FROM usr01 WHERE bname = sy-uname.
    SHIFT g_wf_id LEFT DELETING LEADING '0'.
    CONCATENATE g_wf_id '-ONEPDF' INTO g_list_name.
    CALL FUNCTION 'GET_PRINT_PARAMETERS'
        EXPORTING destination            = w_spld               " 'LT50'
                  copies                 =  1
                  list_name              = g_list_name
                  list_text              = 'PM-PDF NEW-PAGE PRINT ON'
                  immediately            = ' '
                  release                = ' '
                  new_list_id            = 'X'
                  expiration             = g_days
                  line_size              = g_ln_size              " 255 ZTG12
                  line_count             = g_ln_count             " 65 ZTG12
                  layout                 = g_layout " 'X_PAPER'ZTG12
                 SAP_COVER_PAGE         = 'X'
                 RECEIVER               = 'SAP*'
                 DEPARTMENT             = 'System'
                 SAP_OBJECT             = 'RS'
                 AR_OBJECT              = 'TEST'
                 ARCHIVE_ID             = 'XX'
                 ARCHIVE_INFO           = 'III'
                 ARCHIVE_TEXT           = 'Description'
                  no_dialog              = 'X'
        IMPORTING out_parameters         = g_params
                  out_archive_parameters = g_arparams
                  valid                  = g_valid.
      NEW-PAGE PRINT ON
                      NEW-SECTION
                      NO-TITLE
                      PARAMETERS g_params
                      ARCHIVE PARAMETERS g_arparams
               NO DIALOG.
      w_idx =  1 . " for reading EOF line no .
      w_tabix  = 0  .
      READ TABLE it_eof INTO wa_eof INDEX w_idx .
      MOVE  wa_eof-line TO g_lines .
      w_lines = w_tabix + g_lines .
      DATA: w_linestr LIKE sy-tabix .                           "#EC NEEDED
      LOOP AT it_tab INTO wa_tab.
        IF wa_tab-line CP   'Current Budget'  .
          w_linestr  =  sy-tabix .
        ENDIF .
        IF wa_tab IS INITIAL OR wa_tab-line CA '?' .        " ZTG15
          SKIP  .                                               " ZTG15
        ELSE .   " ZTXX
          WRITE /  wa_tab  .
        ENDIF .                                                 " ZTG15
    insert page break
        IF sy-tabix = w_lines  .
          NEW-PAGE .
          w_idx = w_idx + 1 .
          w_tabix =  sy-tabix + w_tabix .
          READ TABLE it_eof INTO wa_eof INDEX w_idx .
          MOVE  wa_eof-line TO g_lines .
          w_lines = w_tabix + g_lines .
          CLEAR: w_tabix.
        ENDIF .
      ENDLOOP .
      NEW-PAGE PRINT OFF .
      CLEAR w_tsp01.
    SELECT * INTO TABLE t_tsp01 FROM tsp01
      WHERE rqowner = sy-uname
      AND rq2name = g_list_name .
    IF sy-subrc = 0  .
       SORT t_tsp01 BY rqcretime DESCENDING . "RBE24 rqident DESCENDING .
    ENDIF .
    READ TABLE t_tsp01 INTO W_TSP01 INDEX 1 .
    CLEAR w_tsp01.
    SELECT SINGLE *
      FROM tsp01
      INTO w_tsp01
    WHERE rqowner = sy-uname
       AND rq2name = g_list_name.        "'COMM-PDF' .
      WHILE  g_numbytes  = 0 .
        CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
            EXPORTING
              src_spoolid                    = w_tsp01-rqident  "spoolno
              no_dialog                      = ' '
          DST_DEVICE                     =
          PDF_DESTINATION                =
            IMPORTING
              pdf_bytecount                  = g_numbytes
              pdf_spoolid                    = g_pdfspoolid
          LIST_PAGECOUNT                 =
              btc_jobname                    = g_jobname
              btc_jobcount                   = g_jobcount
            TABLES
              pdf                            = it_pdf
            EXCEPTIONS
              err_no_abap_spooljob           = 1
              err_no_spooljob                = 2
              err_no_permission              = 3
              err_conv_not_possible          = 4
              err_bad_destdevice             = 5
              user_cancelled                 = 6
              err_spoolerror                 = 7
              err_temseerror                 = 8
              err_btcjob_open_failed         = 9
              err_btcjob_submit_failed       = 10
              err_btcjob_close_failed        = 11.
      ENDWHILE.
    **DATA : DATA_TAB TYPE TABLE.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
         bin_filesize                    = g_numbytes
          filename                        = g_lv_file
         filetype                        = 'BIN'
       IMPORTING
         filelength                      = g_numbytes
        TABLES
          data_tab                        = it_pdf
      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.
    report ZTEST12345678.
    tables:
    tsp01.
    *STRUCTURES
    parameters:
    p_repid like sy-repid, " Report to execute
    p_linsz like sy-linsz default 255, " Line size
    p_paart like sy-paart default 'X_65_132'. " Paper Format
    data:
    mstr_print_parms like pri_params,
    mc_valid(1) type c,
    mi_bytecount type i,
    mi_length type i,
    mi_rqident like tsp01-rqident.
    *INTERNAL TABLES
    data:
    mtab_pdf like tline occurs 0 with header line,
    mc_filename TYPE string.
    *----Data for Mail
    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.
    DATA: V_MAILID(241) TYPE C .
    DATA: BEGIN OF DATA_TAB OCCURS 20,
    LINE(255),
    END OF DATA_TAB.
    start-of-selection.
    concatenate 'c:\abap\'
    p_repid
    '.pdf'
    into mc_filename.
    *Setup the Print Parmaters
    call function 'GET_PRINT_PARAMETERS'
    exporting
    authority = space
    copies = '1'
    cover_page = space
    data_set = space
    department = space
    destination = space
    expiration = '1'
    immediately = space
    *in_archive_parameters = space
    *in_parameters = space
    layout = space
    mode = space
    new_list_id = 'X'
    no_dialog = 'X'
    user = sy-uname
    importing
    out_parameters = mstr_print_parms
    valid = mc_valid
    exceptions
    archive_info_not_found = 1
    invalid_print_params = 2
    invalid_archive_params = 3
    others = 4.
    *Make sure that a printer destination has been set up
    *If this is not done the PDF function module ABENDS
    if mstr_print_parms-pdest = space.
    mstr_print_parms-pdest = 'LP01'.
    endif.
    *Explicitly set line width, and output format so that
    *the PDF conversion comes out OK
    mstr_print_parms-linsz = p_linsz.
    mstr_print_parms-paart = p_paart.
    submit (p_repid) to sap-spool without spool dynpro
    spool parameters mstr_print_parms
    via selection-screen
    and return.
    CALL FUNCTION 'ENQUE_SLEEP'
    EXPORTING
    seconds = 2.
    *Find out what the spool number is that was just created
    P_REPID = SY-REPID.
    perform get_spool_number using p_repid sy-uname
    changing mi_rqident.
    *Convert Spool to PDF
    call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
    exporting
    src_spoolid = mi_rqident
    no_dialog = space
    dst_device = mstr_print_parms-pdest
    importing
    pdf_bytecount = mi_bytecount
    tables
    pdf = mtab_pdf
    exceptions
    err_no_abap_spooljob = 1
    err_no_spooljob = 2
    err_no_permission = 3
    err_conv_not_possible = 4
    err_bad_destdevice = 5
    user_cancelled = 6
    err_spoolerror = 7
    err_temseerror = 8
    err_btcjob_open_failed = 9
    err_btcjob_submit_failed = 10
    err_btcjob_close_failed = 11
    others = 12.
    perform create_mail_data.
    PERFORM SEND_MAIL.
    *FORM get_spool_number
    *Get the most recent spool created by user/report *
    *--> F_REPID *
    *--> F_UNAME *
    *--> F_RQIDENT *
    form get_spool_number using f_repid
    f_uname changing f_rqident.
    data: lc_rq2name like tsp01-rq2name.
    concatenate f_repid+0(8)
    f_uname+0(3)
    into lc_rq2name separated by '_'.
    concatenate f_repid+0(9)
    f_uname+0(3)
    into lc_rq2name.
    select * from tsp01 where rq2name = lc_rq2name
    order by rqcretime descending.
    f_rqident = tsp01-rqident.
    exit.
    endselect.
    if sy-subrc ne 0.
    clear f_rqident.
    endif.
    endform." get_spool_number
    **& Form create_mail_data
    form create_mail_data.
    *Creation of the document to be sent
    DOC_CHNG-OBJ_NAME = 'TEST MAIL ATTACHMENTS'.
    DOC_CHNG-OBJ_DESCR = 'Test for PDF'.
    OBJTXT = 'Contents of mail'.
    APPEND OBJTXT.
    OBJTXT = 'PDF'.
    APPEND OBJTXT.
    OBJTXT = 'PDF'.
    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.
    *-DOWNLOADING AND AGAIN UPLOADINGIN BIN FORMAT TO TRANSFER TO OBJBIN
    *MC_FILENAME = 'c:\test.doc' .
    *--pdf--
    *MC_FILENAME = 'c:\test.pdf'.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
       BIN_FILESIZE                    = MI_BYTECOUNT
        filename                        = MC_FILENAME
       FILETYPE                        = 'BIN'
      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                        = MTAB_PDF[]
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    *CALL FUNCTION 'GUI_DOWNLOAD'
    *EXPORTING
    *BIN_FILESIZE = MI_BYTECOUNT
    *FILENAME = MC_FILENAME
    *FILETYPE = 'BIN'
    *TABLES
    *DATA_TAB = MTAB_PDF
    *EXCEPTIONS
    *FILE_OPEN_ERROR = 1
    *FILE_WRITE_ERROR = 2
    *INVALID_FILESIZE = 3
    *INVALID_TYPE = 4
    *NO_BATCH = 5
    *UNKNOWN_ERROR = 6
    *INVALID_TABLE_WIDTH = 7
    *GUI_REFUSE_FILETRANSFER = 8
    *CUSTOMER_ERROR = 9
    *OTHERS = 10.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        filename                      = MC_FILENAME
       FILETYPE                      = 'BIN'
      HAS_FIELD_SEPARATOR           = ' '
      HEADER_LENGTH                 = 0
      READ_BY_LINE                  = 'X'
      DAT_MODE                      = ' '
      CODEPAGE                      = ' '
      IGNORE_CERR                   = ABAP_TRUE
      REPLACEMENT                   = '#'
      CHECK_BOM                     = ' '
      VIRUS_SCAN_PROFILE            =
      NO_AUTH_CHECK                 = ' '
    IMPORTING
      FILELENGTH                    =
      HEADER                        =
      tables
        data_tab                      = OBJBIN
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    *CALL FUNCTION 'GUI_UPLOAD'
    *EXPORTING
    *FILENAME = MC_FILENAME
    *FILETYPE = 'BIN'
    *TABLES
    *DATA_TAB = OBJBIN.
    *--uncommnet this for pdf--
    DESCRIBE TABLE OBJBIN LINES TAB_LINES.
    OBJHEAD = 'TEST.pdf'. 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 = 'Testing PDF Attachment'.
    OBJPACK-OBJ_DESCR = 'Customes Ageing report PDF Output Attachment'.
    OBJPACK-DOC_SIZE = TAB_LINES * 255.
    APPEND OBJPACK.
    CLEAR V_MAILID.
    V_MAILID = <mail id>.
    RECLIST-RECEIVER = V_MAILID.
    RECLIST-REC_TYPE = 'U'.  "B for SAP Inbox
    APPEND RECLIST.
    endform. " create_mail_data
    **& Form SEND_MAIL
    form SEND_MAIL.
    Sending the document
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    DOCUMENT_DATA = DOC_CHNG
    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
    OPERATION_NO_AUTHORIZATION = 4
    OTHERS = 99.
    *EXCEPTION HANDLING
    CASE SY-SUBRC.
    WHEN 0.
    WRITE: / 'Mail sent with attachment'.
    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.
    endform. " SEND_MAIL

  • Cannot add attachment to e-mail since updating firefox

    when trying to add attachment to yahoo e-mail, no window comes up to allow me to select the attachment. When I click attachment nothing happens.

    Can anyone help me, please??? I check'd all possible settings but i can't solve this be my self.

  • Problem in Attachment of the Mail

    Hi, I want to send the data in Internal Table as a text attachment to the SAP User Inbox. Problem I am facing is that, the records should go Line by Line i.e. each record should start from a new line but problem I am having is that, the next record starts in the same line where previous record has ended.
    E.g. records should appear like this in file :
    1. AAA XXX YYY ZZZ
    2. XXX YYY ZZZ AAA
    rather it is appearing like :
    1. AAA XXX YYY ZZZ2. XXX YYY ZZZ AAA
    I am giving the Code here to generate attachment and Mail I have used. Please help.
    Data Declaration
    data : begin of itab occurs 0,
             ws_line(600) type c,
           end of itab.
    DATA : file_name TYPE string.
    data : path like PCFILE-PATH.
    data : extension(5) type c.
    data : name(100) type c.
    DATA : receiver TYPE somlreci1-receiver VALUE 'AHUJR0'.
    DATA : BEGIN OF itab_str,
               text(290) TYPE c,
           END OF itab_str.
    DATA: docdata LIKE sodocchgi1,
          objpack LIKE sopcklsti1  OCCURS 0 WITH HEADER LINE,
          objhead LIKE solisti1    OCCURS 0 WITH HEADER LINE,
          objtxt  LIKE solisti1    OCCURS 0 WITH HEADER LINE,
          objbin  LIKE itab_str    OCCURS 0 WITH HEADER LINE,
          objhex  LIKE solix       OCCURS 0 WITH HEADER LINE,
          reclist LIKE somlreci1   OCCURS 0 WITH HEADER LINE.
    DATA: tab_lines TYPE i,
          doc_size TYPE i,
          att_type LIKE soodk-objtp.
    DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
    Function Called to Prepare & send mail
    PERFORM ml_addrecp USING receiver 'B'.     "receiver contains SAP User Id
    PERFORM doconv TABLES itab objbin.          "itab is the table containing Data
    PERFORM ml_prepare USING 'X' 'txt' grn_file.  "grn_file is the name of attachment file
    PERFORM ml_dosend.
    Form ml_addrecp
    FORM ml_addrecp USING preceiver prec_type.
    CLEAR reclist.
    reclist-receiver = preceiver.
    reclist-rec_type = prec_type.
    APPEND reclist.
    ENDFORM. "ml_addrecp
    Form doconv
    FORM doconv TABLES mypdf STRUCTURE itab_str
                       outbin STRUCTURE itab_str.
    Loop And Put Data
          LOOP AT mypdf.
              outbin = mypdf.
              APPEND outbin.
             CLEAR: outbin.
          ENDLOOP.
    ENDFORM. "doconv
    Form ml_prepare
    FORM ml_prepare USING bypassmemory whatatt_type whatname.
    IF bypassmemory = ''.
    Fetch List From Memory
        CALL FUNCTION 'LIST_FROM_MEMORY'
          TABLES
            listobject = listobject
          EXCEPTIONS
            OTHERS = 1.
    IF sy-subrc <> 0.
        MESSAGE ID '61' TYPE 'E' NUMBER '731'
        WITH 'LIST_FROM_MEMORY'.
    ENDIF.
    ENDIF.
    DESCRIBE TABLE objtxt LINES tab_lines.
    READ TABLE objtxt INDEX tab_lines.
    docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
    CLEAR objpack-transf_bin.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = 'TXT'.
    APPEND objpack.
    Packing Info Attachment
    att_type = whatatt_type..
    DESCRIBE TABLE objbin LINES tab_lines.
    READ TABLE objbin INDEX tab_lines.
    objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
    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 = whatname.
    APPEND objpack.
    ENDFORM. "ml_prepare
    Form ml_dosend.
    FORM ml_dosend.
    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 = 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 'SO' TYPE 'S' NUMBER '023'
        WITH docdata-obj_name.
    ENDIF.
    ENDFORM. "ml_dosend

    Hi Ravi,
    I also had the same problem, the solution to this is....  Instead of giving the TXT type to the attachment give as 'RAW' it will work...  it is working for me... note the place for the comment CHANGE I HAVE DONE in the code given by you...
    objpack-doc_type = 'RAW'.  '' for the attachment instead of TXT...
    Eg...
    Packing Info Attachment
    *att_type = whatatt_type..                          '" CHANGE I HAVE DONE
    DESCRIBE TABLE objbin LINES tab_lines.
    READ TABLE objbin INDEX tab_lines.
    objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
    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.  " CHANGE I HAVE DONE
    objpack-doc_type = 'RAW'.      " CHANGE I HAVE DONE
    objpack-obj_name = 'ATTACHMENT'.
    objpack-obj_descr = whatname.
    APPEND objpack.
    ENDFORM. "ml_prepare

  • Problems with txt attachment in the mail

    Hi,
    I noticed a big problem for the mail in mac os x. Every time I received my txt format data file in attachment with email, it automatically displayed at the end of my email in the Mail instead of remaining as a txt attachment file ready for download. How can I set it to stay as an attachment instead of being forced to show up as plain text in the end of my received email? Thanks.

    Hi,
    I noticed a big problem for the mail in mac os x. Every time I received my txt format data file in attachment with email, it automatically displayed at the end of my email in the Mail instead of remaining as a txt attachment file ready for download. How can I set it to stay as an attachment instead of being forced to show up as plain text in the end of my received email? Thanks.

  • Picking up the attachment from the Mail...

    Hi to All,
    I am trying one scenario in which i want to pick the Mail from mail server which contains an attachment in XML format and i want to Access this Attachment (i dont have to do anything with the main Body of mail)  and want to put the Data of the attachment in RFC.
    Can body please help me.
    Its very urgent.
    Thanks
    Regards
    Vikas

    hi vikas,
    u can use the following links to develop ur scenario.
    /people/sravya.talanki2/blog/2005/08/18/triggering-e-mails-to-shared-folders-of-sap-is-u - Triggering Email from folder
    /people/prasad.ulagappan2/blog/2005/06/07/mail-adapter-scenarios-150-sap-exchange-infrastructure - Mail Adaptor options , mail attatchment
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6d967fbc-0a01-0010-4fb4-91c6d38c5816
    /people/prasad.ulagappan2/blog/2005/06/07/mail-adapter-scenarios-150-sap-exchange-infrastructure
    /people/michal.krawczyk2/blog/2005/11/23/xi-html-e-mails-from-the-receiver-mail-adapter
    https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/1685 [original link is broken] [original link is broken] [original link is broken] [original link is broken]
    regards
    sreeni

  • Add Attachment to the course

    How to add Attachment (e.g. word document) to the course?

    There's a profile option called something like 'HR: Use standard attachments' (please try variations on this as I can't recall the exact name) which switches HRMS applications from the old 'comments style' attachments to be able to attach documents etc. Try changing the value of that profile and trying again. You are looking in the right place in OLM.

Maybe you are looking for