Regarding FM SO_NEW_DOCUMENT_ATT_SEND_API1

Hi all, Currently i am using the following code. But still mails are not going to receipient. Can anybody suggest me what is going wrong with code.
  DATA:
   tab_lines TYPE i,
   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,
   msgtbl  TYPE ehsww_text   OCCURS 0 WITH HEADER LINE,
   reclist LIKE somlreci1    OCCURS 0 WITH HEADER LINE.
  SORT it_message BY dlist.
  DATA : l_subject(50) TYPE c,
         l_dlist(50)   TYPE c.
  LOOP AT it_message.
  l_subject = it_message-subject .
    AT NEW dlist.
      REFRESH:
       objpack, objhead, objtxt, reclist.
      CLEAR:
       docdata, objpack, objhead, objtxt, reclist.
Title and Description
      docdata-obj_name =  'Status report'(034).
      docdata-obj_descr = l_subject . "'Movement Status Report'.
    ENDAT.
FM which wraps the 512 length string contents to 255 characters
    CALL FUNCTION 'EHS00_WORDWRAP02'
      EXPORTING
        im_string = it_message-message
        im_len    = 255
      TABLES
        ex_ftext  = msgtbl.
Main Text
    LOOP AT msgtbl.
      objtxt = msgtbl.
      APPEND objtxt.
    ENDLOOP.
l_dlist =  it_message-dlist.
    AT END OF dlist.
      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 = 'RAW'.
      APPEND objpack.
Create receiver list
      reclist-receiver = l_dlist.
      reclist-rec_type = 'U'.    "C  " ADDED BY CAGK932834 SP76477
      reclist-copy     = true.
      APPEND reclist.
Send Message
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data = docdata
          put_in_outbox = 'X'
          COMMIT_EORK   = 'X'
        TABLES
          packing_list  = objpack
          object_header = objhead
          contents_txt  = objtxt
          receivers     = reclist.
Thanks for all your help in advance.
Sidds.

Hi
these are the types you can use
P     Private distribution list
C     Shared distribution list
O     SAPoffice user
B     SAP user
<b>U     Internet address</b>
X     X.400 address
R     SAP user in another SAP System
F     Fax number
D     X.500 Address
L     Telex number
H     Organizational unit/position
J     SAP object
G     Organization object/ID
K     Pager/SMS
But i am not sure why your mails were not sent
Regards,
siva chalasani

Similar Messages

  • Regarding Sending an email by using SO_NEW_DOCUMENT_ATT_SEND_API1

    Hi Experts,
    I have tow internal tables like ...ITAB1 AND ITAB2.
    Is it possible to send an email with these two internal tables as attachments..like Attachment1...Itab1 and Attachment2...Itab2..
    Is it possible by using the FM SO_NEW_DOCUMENT_ATT_SEND_API1??
    Rgds,
    Sruthi.

    Hi Shruthi,
    You can use FM SO_NEW_DOCUMENT_ATT_SEND_API1 to send internal tables as attachment in mail.
    Plz check this link:
    https://wiki.sdn.sap.com/wiki/display/ABAP/Tosend2inttablesdataastwoattachmentstomailidoutsidesapsystem
    It will guide you in solving your problem.
    Thanks & regards,
    Sarita Singh

  • Regarding EMAIL in inbox using SO_NEW_DOCUMENT_ATT_SEND_API1

    HI all,
    I am using SO_NEW_DOCUMENT_ATT_SEND_API1 module to sent emails on external email IDs.Can anyone guide me if this function module also sends email to SAP inbox correspoding to email addrees on which email is sent?
    Also guide me how to send doc to sap inbox of these email adrees using SO_NEW_DOCUMENT_ATT_SEND_API1.
    Thanks.

    Hi,
    Yes you can even send mails to the SAp inbox, by simply setting the receiver type as B in the RECEIVERS tables parameter.
    Regards
    Pavan

  • Regarding  the function module 'SO_NEW_DOCUMENT_ATT_SEND_API1'

    Hi
    I am using the function module 'SO_NEW_DOCUMENT_ATT_SEND_API1' to send an email with tab delimited text file as an attachment. while doing this i'm facing the folloing issues.
    1. a) Here the subject line field is char 50. My subject line is more than 50 characters. Is there any other way to do so?
    1.b) I am facing the data alignment problem in attached file if it is the case of Text file.
    can you please let me know how to resolve these issues and also let me if there are any other function modules to do so.

    Hi!
    1. You will have to manage with a subject of 50 char. In any case a longer subject would not be visible in your mailbox.
    2. For TAB delimited contents: Concatenate the fields of your internal table separated by HEX 09 (TAB). For every new line add HEX 0D at the end of the string.
    Cheers!

  • Regarding SO_NEW_DOCUMENT_ATT_SEND_API1 function module

    Hi Friends,
    Please help me. I want to send data through email with a .txt format by using SO_NEW_DOCUMENT_ATT_SEND_API1 function module. Anybody plz help me by sending an example program with function module.Plz help me.....

    Hi,
    Try this code
    REPORT ZMAIL1 .
    *& Report  ZSENDEMAIL                                                  *
    *& Example of sending external email via SAPCONNECT                    *
    *REPORT  zsendemail                    .
    PARAMETERS: psubject(40) type c default  'Hello',
                p_email(40)   type c .
    data:   it_packing_list like sopcklsti1 occurs 0 with header line,
            it_contents like solisti1 occurs 0 with header line,
            it_receivers like somlreci1 occurs 0 with header line,
            it_attachment like solisti1 occurs 0 with header line,
            gd_cnt type i,
            gd_sent_all(1) type c,
            gd_doc_data like sodocchgi1,
            gd_error type sy-subrc.
    data:   it_message type standard table of SOLISTI1 initial size 0
                    with header line.
    *START-OF-SELECTION.
    START-OF-SELECTION.
    Perform populate_message_table.
    *Send email message, although is not sent from SAP until mail send
    *program has been executed(rsconn01)
    PERFORM send_email_message.
    *Instructs mail send program for SAPCONNECT to send email(rsconn01)
    perform initiate_mail_execute_program.
    *&      Form  POPULATE_MESSAGE_TABLE
    *       Adds text to email text table
    form populate_message_table.
      Append 'Email line 1' to it_message.
      Append 'Email line 2' to it_message.
      Append 'Email line 3' to it_message.
      Append 'Email line 4' to it_message.
    endform.                    " POPULATE_MESSAGE_TABLE
    *&      Form  SEND_EMAIL_MESSAGE
    *       Send email message
    form send_email_message.
    * Fill the document data.
      gd_doc_data-doc_size = 1.
    * Populate the subject/generic message attributes
      gd_doc_data-obj_langu = sy-langu.
      gd_doc_data-obj_name  = 'SAPRPT'.
      gd_doc_data-obj_descr = psubject.
      gd_doc_data-sensitivty = 'F'.
    * Describe the body of the message
      clear it_packing_list.
      refresh it_packing_list.
      it_packing_list-transf_bin = space.
      it_packing_list-head_start = 1.
      it_packing_list-head_num = 0.
      it_packing_list-body_start = 1.
      describe table it_message lines it_packing_list-body_num.
      it_packing_list-doc_type = 'RAW'.
      append it_packing_list.
    * Add the recipients email address
      clear it_receivers.
      refresh it_receivers.
      it_receivers-receiver = p_email.
      it_receivers-rec_type = 'U'.
      it_receivers-com_type = 'INT'.
      it_receivers-notif_del = 'X'.
      it_receivers-notif_ndel = 'X'.
      append it_receivers.
    * Call the FM to post the message to SAPMAIL
      call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           exporting
                document_data              = gd_doc_data
                put_in_outbox              = 'X'
           importing
                sent_to_all                = gd_sent_all
           tables
                packing_list               = it_packing_list
                contents_txt               = it_message
                receivers                  = it_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.
    * Store function module return code
      gd_error = sy-subrc.
    * Get it_receivers return code
      loop at it_receivers.
      endloop.
    endform.                    " SEND_EMAIL_MESSAGE
    *&      Form  INITIATE_MAIL_EXECUTE_PROGRAM
    *       Instructs mail send program for SAPCONNECT to send email.
    form initiate_mail_execute_program.
      wait up to 2 seconds.
      if gd_error eq 0.
          submit rsconn01 with mode = 'INT'
                        with output = 'X'
                        and return.
      endif.
    endform.                    " INITIATE_MAIL_EXECUTE_PROGRAM

  • Regarding 'SO_NEW_DOCUMENT_ATT_SEND_API1'

    Hi gurus,
    im using the fm 'SO_NEW_DOCUMENT_ATT_SEND_API1' for sending mail.
    my problem is that im not able to get my mail on one id while in the same execution cycle im able to get the mail on other ID. but in the scst tcode the status of both the ids is sent. but yet im not able to get my mail in one id ever.
    please help me out.
    what would be the probable error

    my code is
    REPORT YBACKGROUND .
    ************************initialization of data********************
    tables: vbap, vbep.
    TYPES: BEGIN OF ty_rep,
             v_group(2) TYPE n,          "Selection Flag (Grouping items)
             vbeln     LIKE vbak-vbeln,  "Order Number
             auart     LIKE vbak-auart,  "Order Type
             erdat     LIKE vbak-erdat,  "Order Date
             kunnr     LIKE vbak-kunnr,  "Sold-to
             ekgrp     LIKE marc-ekgrp,  "Purchase group
             posnr     LIKE vbap-posnr,  "Item Number
             matnr     LIKE vbap-matnr,  "Material
             kwmeng    LIKE vbap-kwmeng, "Ordered Qty
             lfimg     LIKE lips-lfimg,  "Delivered Qty
             v_undeliv LIKE vbap-kwmeng, "Undelivered Qty
             v_open    LIKE vbap-kwmeng,                        "Open A001
             v_pr_qty  LIKE vbap-kwmeng, "Suggested PR Qty
           Fields type char for display in table control -Begin
             v_kwmeng_char(16)  TYPE c,  "Ordered Qty
             v_lfimg_char(16)   TYPE c,  "Delivered Qty
             v_undeliv_char(16) TYPE c,  "Undelivered Qty
             v_open_char(16)    TYPE c,                         "Open A001
             v_pr_qty_char(16)  TYPE c,  "Suggested PR Qty
           Fields type char for display in table control -End
             v_user_inp(7) TYPE n, "User Input Qty
             v_number  LIKE eban-banfn,  "Purchase Requisition number
             vrkme  LIKE vbap-vrkme,     "Currency/Quan
           END OF ty_rep.
    mail sending itab********************
    data: begin of ierr_mail_tab occurs 0,
            zzdatetime(14)  type c,
            kunnr(14) type c,
           kunwe(14) type c,
           bukrs(8) type c,
            vkorg(11) type c,
            vtweg(13) type c,
            vbeln(12) type c,
            matnr(18) type c,
           wmengc(9) type c,
            werks(6) type c,
            cycle_count(12) type c,
            message(220) type c,
          end of ierr_mail_tab.
    data: date like  vbap-erdat, date1 like vbap-erdat,
          date2 like vbap-erdat.
    data: flag type n value '0', count type n value '0'.
    data: inp_qty like vbap-kwmeng.
    DATA: t_repc TYPE TABLE OF ty_rep WITH HEADER LINE.
    data: t_rep_mail type table of ty_rep with header line.
    data: itab type table of vbap with header line.
    **************data for bapi change*************
    data: sales_doc_num like BAPIVBELN-VBELN,
          sim_flag like BAPIFLAG-BAPIFLAG,
          order_head_ch like BAPISDH1,
          order_head_chx like BAPISDH1X,
          order_item_schdl like BAPISCHDL occurs 0 with header line,
          order_item_schdlx like BAPISCHDLX occurs 0 with header line,
          order_ch_ret like BAPIRET2 occurs 0 with header line,
          order_item_in_rej like bapisditm occurs 0 with header line,
          order_item_in_rejx like bapisditmx occurs 0 with header line.
    *data: schd_linex type table of schd_linex with header line.
    ***********************data for the bapi_create****************
    **********data to be taken from the selection screen***********
    data: p_purch type bstkd.
    data: p_date type bstdk.
    data: p_auart TYPE auart.
    data: p_vkorg TYPE vkorg.
    data: p_vtweg TYPE vtweg.
    data: p_spart TYPE vtweg.
    *******************data from the t_repc***********************
    data: p_sold TYPE kunnr.
    data: p_ship TYPE kunnr.
    *ITEM
    data: p_matnr TYPE matnr.
    data: p_menge TYPE kwmeng.
    data: p_plant TYPE werks_d ."check these data
    data: p_itcat TYPE pstyv. "check these data..
    DATA DECLARATIONS.
    DATA: v_vbeln LIKE vbak-vbeln.
    DATA: header LIKE bapisdhead1.
    DATA: headerx LIKE bapisdhead1x.
    DATA: item    LIKE bapisditem OCCURS 0 WITH HEADER LINE.
    DATA: itemx   LIKE bapisditemx OCCURS 0 WITH HEADER LINE.
    DATA: partner LIKE bapipartnr  OCCURS 0 WITH HEADER LINE.
    DATA: return  LIKE bapiret2    OCCURS 0 WITH HEADER LINE.
    DATA: lt_schedules_inx   TYPE STANDARD TABLE OF bapischdlx
                             WITH HEADER LINE.
    DATA: lt_schedules_in    TYPE STANDARD TABLE OF bapischdl
                             WITH HEADER LINE.
    ***************end of the data for the bapi_create********************
    start-of-selection.
    IMPORT t_repc FROM MEMORY ID 'ABCD1'.
    perform delete.
    TABLES INDX.
    DATA: INDXKEY LIKE INDX-SRTFD VALUE 'KEYVALUE1'.
    WRITE : / 'BEFORE IMPORT'.
    IMPORT t_repc = t_repc FROM DATABASE INDX(ST) ID INDXKEY.
    WRITE : / 'AFTER IMPORT'.
      LOOP AT t_repc.
        WRITE: / t_repc-vbeln .
      ENDLOOP.
      perform order_change.
    end-of-selection.
          FORM delete                                                   *
    *form delete.
       delete t_repc where v_user_inp eq 0.
       select etenr from vbep into schd_linex where etenr =
    *endform.
    *&      Form  bapi
          text
    -->  p1        text
    <--  p2        text
    FORM order_change.
      date = sy-datum+0(4).
      date1 = sy-datum+4(2).
      date2 = sy-datum+6(2).
      concatenate date2 date1 date into date separated by '.'.
    write: 'madhvi5'.
      loop at t_repc.
    *t_repc-v_user_inp = 33.
        sales_doc_num = t_repc-vbeln.
        order_head_chx-UPDATEFLAG = 'U'.
    *write: 'madhvi4'.
    *to check the order quantity is same or not
        if t_repc-v_user_inp eq t_repc-kwmeng.
    **************to move the content of the imported*****
    **********file in the mail internal table formail issue*******
          move-corresponding t_repc to t_rep_mail.
          order_item_in_rej-ITM_NUMBER = t_repc-posnr.
          order_item_in_rej-REASON_REJ = 'Z4'.
          append order_item_in_rej.
          order_item_in_rejx-ITM_NUMBER = t_repc-posnr.
          order_item_in_rejx-REASON_REJ = 'X'.
          order_item_in_rejx-UPDATEFLAG = 'U'.
          append order_item_in_rejx.
        endif.
    *to check if the order quantity is less
        if t_repc-v_user_inp < t_repc-kwmeng.
          inp_qty = t_repc-kwmeng - t_repc-v_user_inp.
         order_item_in_rej-ITM_NUMBER = t_repc-posnr.
         append order_item_in_rej.
         clear order_item_in_rej.
         order_item_in_rejx-ITM_NUMBER = t_repc-posnr.
         order_item_in_rejx-UPDATEFLAG = 'U'.
         append order_item_in_rejx.
         clear order_item_in_rejx.
    First Changing the existing sales Order Line item
          order_item_schdl-ITM_NUMBER = t_repc-posnr.
          order_item_schdl-req_qty = inp_qty.
          order_item_schdl-SCHED_LINE = '1'.
          append order_item_schdl.
          clear order_item_schdl.
          order_item_schdlx-ITM_NUMBER = t_repc-posnr.
          order_item_schdlx-req_qty = 'X'.
          order_item_schdlx-SCHED_LINE = '1'.
          order_item_schdlx-UPDATEFLAG = 'U'.
          append order_item_schdlx.
          clear order_item_schdlx.
    Creating a new line item with User Input Qty and rejecting it
          order_item_in_rej-MATERIAL = t_repc-matnr.
          order_item_in_rej-REASON_REJ = 'Z4'.
          append order_item_in_rej.
          clear order_item_in_rej.
          order_item_in_rejx-MATERIAL = 'X'.
          order_item_in_rejx-REASON_REJ = 'X'.
          order_item_in_rejx-UPDATEFLAG = 'I'.
          append order_item_in_rejx.
          clear order_item_in_rejx.
          order_item_schdl-req_qty = t_repc-v_user_inp.
          order_item_schdl-SCHED_LINE = '1'.
          append order_item_schdl.
          clear order_item_schdl.
          order_item_schdlx-req_qty = 'X'.
          order_item_schdlx-SCHED_LINE = '1'.
          order_item_schdlx-UPDATEFLAG = 'I'.
          append order_item_schdlx.
          clear order_item_schdlx.
          flag = 1.
    *write: 'madhvi1'.
    *perform bapi_create using t_repc.
    *write: 'madhvi3'.
        endif.
    *write: 'madhvi3'.
       CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
         EXPORTING
          SALESDOCUMENT               = sales_doc_num
          ORDER_HEADER_IN             = order_head_ch
          ORDER_HEADER_INX            = order_head_chx
      SIMULATION                  = sim_flag
      BEHAVE_WHEN_ERROR           = ' '
      INT_NUMBER_ASSIGNMENT       = ' '
      LOGIC_SWITCH                =
      NO_STATUS_BUF_INIT          = ' '
         TABLES
           RETURN                      = order_ch_ret
          ORDER_ITEM_IN                = order_item_in_rej
          ORDER_ITEM_INX               =  order_item_in_rejx
      PARTNERS                    =
      PARTNERCHANGES              =
      PARTNERADDRESSES            =
      ORDER_CFGS_REF              =
      ORDER_CFGS_INST             =
      ORDER_CFGS_PART_OF          =
      ORDER_CFGS_VALUE            =
      ORDER_CFGS_BLOB             =
      ORDER_CFGS_VK               =
      ORDER_CFGS_REFINST          =
          SCHEDULE_LINES              = order_item_schdl
          SCHEDULE_LINESX             = order_item_schdlx
      ORDER_TEXT                  =
      ORDER_KEYS                  =
      CONDITIONS_IN               =
      CONDITIONS_INX              =
      EXTENSIONIN                 =
       CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      WAIT          =
    IMPORTING
      RETURN        =
    **************querry to select the line from the data****************
    ***************base table where the old order is reject***************
        if flag eq 1. "if the line item is created and blocked
          select * from vbap into itab where vbeln = t_repc-vbeln
          and abgru = 'Z4' and erdat = sy-datum.
          endselect.
          append itab.
    *if itab-erdat eq sy-datum.
    write: 'ji'.
    *endif.
          move-corresponding t_repc to t_rep_mail.
          t_rep_mail-posnr = itab-posnr.
          modify t_rep_mail index sy-tabix transporting posnr.
          append t_rep_mail.
        endif.
      endloop.
       perform mail_send using t_rep_mail.
       ENDFORM." bapi
    *&      Form  mail_send
          text
    -->  p1        text
    <--  p2        text
    FORM mail_send using rep_mail like t_rep_mail.
      data: ierr_tab like YME1SD131 occurs 0 with header line.
      data: begin of ierr_mail_tab occurs 0,
              zzdatetime(14)  type c,
              kunnr(14) type c,
              auart(8) type c,
              posnr(10) type c,
              ekgrp(5) type c,
              userid(10) type c,
              vbeln(12) type c,
              matnr(18) type c,
              user_inp(12) type c,
              message(220) type c,
            end of ierr_mail_tab.
      CLEAR ierr_mail_tab.
      ierr_mail_tab-vbeln         = rep_mail-vbeln.
      ierr_mail_tab-userid        = sy-uname.
      ierr_mail_tab-zzdatetime    = sy-datum.
      ierr_mail_tab-posnr         = rep_mail-posnr.
      ierr_mail_tab-kunnr         = rep_mail-kunnr.
      ierr_mail_tab-matnr         = rep_mail-matnr.
      ierr_mail_tab-message       = 'channel 2 order rejected'.
      ierr_mail_tab-auart         = rep_mail-auart.
      ierr_mail_tab-ekgrp         = rep_mail-ekgrp.
      ierr_mail_tab-user_inp      = rep_mail-v_user_inp.
      DATA: zeroes(1) TYPE c VALUE '0'.
      DATA : tab_lines(3) TYPE n.
      DATA : email_id(30) TYPE c.
      data: email_idc(30) type c.
      data: P_FILE LIKE FILENAME-FILEEXTERN.
      DATA: docdata    LIKE sodocchgi1,
            objpack    LIKE sopcklsti1 OCCURS  1 WITH HEADER LINE,
            objhead    LIKE solisti1   OCCURS  1 WITH HEADER LINE,
            objtxt     LIKE solisti1   OCCURS 10 WITH HEADER LINE,
            objbin     LIKE solisti1   OCCURS 10 WITH HEADER LINE,
         objbin1    LIKE solisti1   OCCURS 10 WITH HEADER LINE,
            objhex     LIKE solix      OCCURS 10 WITH HEADER LINE,
            reclist    LIKE somlreci1  OCCURS  1 WITH HEADER LINE.
      DATA: subject(100) TYPE c.
      DATA : att_type     LIKE soodk-objtp.
      DATA: count TYPE i.
      data: ernam like vbak-ernam.
      TRANSLATE ierr_mail_tab-message TO UPPER CASE.
      SHIFT ierr_mail_tab-matnr LEFT DELETING LEADING zeroes.
      append ierr_mail_tab.
      docdata-obj_name  = text-n22."cool.
      CONCATENATE docdata-obj_name
                  ierr_mail_tab-vbeln
             INTO docdata-obj_descr.
      count     = 0.
      LOOP AT ierr_mail_tab.
        count   = count + 1.
        INSERT ierr_mail_tab INTO objbin INDEX count.
        APPEND objbin.
      ENDLOOP.
    objtxt    = '    '. " NEW-LINE
    APPEND objtxt.
    objtxt    = text-n12. "Hi,
    APPEND objtxt.
    objtxt    = text-n04.
    *Thank you for using the SAP Dealer Communication System
    APPEND objtxt.
    objtxt    = '    '.
    APPEND objtxt.
    objpack-head_start   = 1.
    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     = 'RAW'.
    APPEND objpack.
    att_type = 'RAW'.
    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    = 'ORDER LOG'.
    APPEND objpack.
    **********to find the email id**************
    *to get the user number who has created the order
    SELECT SINGLE ernam  FROM vbak INTO ernam WHERE
                vbeln  = rep_mail-vbeln.
    email_idc = '[email protected]'.
    IF sy-subrc <> 0.
      write: 'not send email'.
    else.
    *to get the email of the person who has generated the vbeln
    select single email
    from zusuarios
    into email_id
    where uname = ernam.
    CONDENSE  email_id.
      Condense email_idc.
      IF NOT email_id IS INITIAL.
        reclist-receiver = email_id.
       reclist-PROXY_ID = email_idc.
        reclist-rec_type = 'U'.
        APPEND reclist.
        endif.
    IF NOT email_idc IS INITIAL.
        reclist-receiver = email_idc.
       reclist-PROXY_ID = email_idc.
        reclist-rec_type = 'U'.
        reclist-copy = 'X'.
        APPEND reclist.
      ENDIF.
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
            EXPORTING
              document_data                 = docdata
              put_in_outbox                 = 'X'
    IMPORTING
      SENT_TO_ALL                     =
      NEW_OBJECT_ID                   =
            TABLES
              packing_list                  = objpack
              object_header                 = objhead
              contents_bin                  = objbin
              contents_txt                  = objtxt
      CONTENTS_HEX                    =
      OBJECT_PARA                     =
      OBJECT_PARB                     =
              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.
        write: 'email_id not configured for the person'.
      endif.
      WAIT UP TO 2 SECONDS.
      SUBMIT rsconn01 WITH mode = 'INT'
                    WITH output = ' '
                    AND RETURN.
    endif.
    upload the file in the application server****************
    p_file = '/TEMPO/dealers/AE/recibidos/ymvp'.
      OPEN DATASET p_file FOR OUTPUT IN TEXT MODE.
      LOOP AT objbin.
        TRANSFER objbin TO p_file.
      ENDLOOP.
      CLOSE DATASET p_file.
    ENDFORM."mail_send.
    *&      Form  bapi_create
          text
    -->  p1        text
    <--  p2        text
    FORM bapi_create using t_repc_create like t_repc.
    fro creating new order number by bapi*****************
    **************select query for purchase order.****************
    data: w_len type i.
    data: string1(3) type c, string11(2) type c.
    data: t_len type i.
    data: integer type i.
    data: req type banfn.
    data: z_table like yme1sd134 occurs 0 with header line.
    ***********internal table for the spool purpose***************
    write: 'madhvi2'.
    SELECT bstkd
            bstdk
       FROM vbkd
       INTO (p_purch, p_date)
      WHERE vbeln = t_repc_create-vbeln .
    ENDSELECT.
    SELECT *
      FROM yme1sd134
       INTO z_table
      WHERE vbeln = t_repc_create-vbeln .
    ENDSELECT.
    append z_table.
    SELECT vkorg
            vtweg
            spart
       FROM vbak
       INTO (p_vkorg, p_vtweg, p_spart)
      WHERE vbeln = t_repc_create-vbeln.
    ENDSELECT.
    SELECT werks
            pstyv
       FROM vbap
       INTO (p_plant, p_itcat)
      WHERE vbeln = t_repc_create-vbeln   AND
            posnr = t_repc_create-posnr.
    ENDSELECT.
    p_purch = z_table-bstkd.
    w_len   = STRLEN( p_Purch ).
    t_len   = w_len - 6.
    string1 = P_purch+t_len(3).
    if the ch4 po is already inserted then check the last digit
    *"to check if the z_table has same vbeln
    if z_table-vbeln = t_repc_create-vbeln.
    IF string1 = 'ch4'.
      t_len = w_len - 2.
      MOVE P_purch+t_len(2) TO string11.
      integer = string11.
      if integer eq 999.
      exit.
      endif.
      integer = integer + 1.
      string11 = integer.
      if integer <= 9.
      concatenate '0' string11 into string11.
      endif.
      move string11 to p_purch+t_len(2).
    ENDIF.
    endif."if the the z_table condition
    if string1 <> 'ch4'.
      data: str(7) type c.
      str = '/ch4-01'.
      concatenate p_purch str into p_purch.
    endif.
    HEADER DATA
    header-doc_type = 'YMV4'.
    headerx-doc_type = 'X'.
    header-sales_org = p_vkorg.
    headerx-sales_org = 'X'.
    header-distr_chan  = p_vtweg.
    headerx-distr_chan = 'X'.
    header-division = p_spart.
    headerx-division = 'X'.
    header-PURCH_NO_C = p_purch.
    headerx-PURCH_NO_C = 'X'.
    header-PURCH_DATE = p_date.
    headerx-PURCH_DATE = 'X'.
    headerx-updateflag = 'I'.
    PARTNER DATA
    partner-partn_role = 'AG'.
    partner-partn_numb = t_repc_create-kunnr.
    APPEND partner.
    partner-partn_role = 'WE'.
    partner-partn_numb = t_repc_create-kunnr.
    APPEND partner.
    ITEM DATA
    itemx-updateflag = 'I'.
    item-itm_number = '000010'.
    itemx-itm_number = 'X'.
    item-material = t_repc_create-matnr.
    itemx-material = 'X'.
    item-plant    = 'AE99'.
    itemx-plant   = 'X'.
    item-target_qty = t_repc_create-v_user_inp.
    itemx-target_qty = 'X'.
    item-item_categ = 'TAS4'.
    itemx-item_categ = 'X'.
    APPEND item.
    APPEND itemx.
      Fill schedule lines
    lt_schedules_in-itm_number = '000010'.
    lt_schedules_in-sched_line = '0001'.
    lt_schedules_in-req_qty    = t_repc_create-v_user_inp.
    APPEND lt_schedules_in.
      Fill schedule line flags
    lt_schedules_inx-itm_number  = '000010'.
    lt_schedules_inx-sched_line  = '0001'.
    lt_schedules_inx-updateflag  = 'X'.
    lt_schedules_inx-req_qty     = 'X'.
    APPEND lt_schedules_inx.
    **************end of data entry for the bapi create******************
    Call the BAPI
    CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
         EXPORTING
              sales_header_in     = header
              sales_header_inx    = headerx
         IMPORTING
              salesdocument_ex    = v_vbeln
         TABLES
              return              = return
              sales_items_in      = item
              sales_items_inx     = itemx
              sales_schedules_in  = lt_schedules_in
              sales_schedules_inx = lt_schedules_inx
              sales_partners      = partner.
    Check the return table.
    LOOP AT return WHERE type = 'E' OR type = 'A'.
      EXIT.
    ENDLOOP.
    IF sy-subrc = 0.
      WRITE: / 'Error in creating document'.
    ELSE.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      WAIT          =
    IMPORTING
      RETURN        =
    ENDIF.
    TABLES yme1sd134.
    yme1sd134-vbeln       = t_repc_create-vbeln.
    yme1sd134-mandt       = '100'.
    *yme1sd134-matnr       = t_repc_create-matnr.
    yme1sd134-bstdk       = p_date.
    yme1sd134-bstkd       = p_purch.
    INSERT INTO yme1sd134 VALUES yme1sd134.
    COMMIT WORK AND WAIT.
    perform spool_print using v_vbeln t_repc.
    ENDFORM.                    " bapi_create
    *&      Form  spool_print
          text
    -->  p1        text
    <--  p2        text
    FORM spool_print using v_vbelns
    t_repc_create_spool STRUCTURE t_repc.
    *internal table for the  spool
    *data: itab11 like vbep occurs 0 with header line.
    data: begin of i_spool occurs 0,
          vbeln1 type vbap-vbeln,
          vbeln4 type vbap-vbeln,
          p_req type vbep-banfn,
          p_pur type vbkd-bstkd,
          end of i_spool.
    write: /0(71) sy-uline.
    write: /1 sy-vline, 2(15) 'SalesOrder-Ch1', sy-vline , 19(15)
    'SalesOrder-Ch4',
    sy-vline, 37(15) 'Purch_order', sy-vline, 55(15)'purcu_req', sy-vline.
    select single * from vbep into vbep
    where vbeln = v_vbelns." and posnr = '000010' and ETENR = '0001' .
    *v_vbelns
    *select banfn
    *from vbep
    *into req
    *where vbeln = v_vbeln and posnr = 10 and ETENR = 1 .
    *endselect.
    i_spool-vbeln1 = t_repc_create_spool-vbeln.
    i_spool-vbeln4 = v_vbeln.
    i_spool-p_pur  = p_purch.
    i_spool-p_req  = vbep-banfn.
    append i_spool.
    loop at i_spool.
    write: /0(71) sy-uline.
    write: /1 sy-vline, 2 i_spool-vbeln1,18 sy-vline, i_spool-vbeln4,
    35 sy-vline, i_spool-p_pur,
    53 sy-vline, i_spool-p_req, 71 sy-vline.
    write: /0(71) sy-uline.
    endloop.
    ENDFORM.                    " spool_print
    this is my complete code.

  • Text File in SO_NEW_DOCUMENT_ATT_SEND_API1

    Hello!
    We're using SO_NEW_DOCUMENT_ATT_SEND_API1 to send txt files attached to an e-mail.
    My problem is that whenever a text file with less than 500 characters is attached to e-mail, the last line of this text file is filled with many blank characters (spaces)
    I can only see this if I open the file by the e-mail, and I'm not able to see this blank line in debug.
    I think this is related to table CONTENTS_BIN, due to it's line size of char255, but i'm not 100% sure.
    Does any one knows how to solve this? We don't want that blank line at the end of the file.
    Mauricio

    Hi Mauricio,
    Did you pass xs_gd_doc_data and xt_packing_list in your FM
    Constant : lc_name    TYPE string VALUE 'Test Mail',
                 lc_descr   TYPE string VALUE 'Test Mail',
                 lc_f       TYPE c      VALUE 'F',
                 lc_zero    TYPE c      VALUE '0',
                 lc_one     TYPE c      VALUE '1',
                 lc_doctype TYPE string VALUE 'RAW'.
      CLEAR: lv_cnt.
    xy_message-line = lc_string.
      APPEND xyt_message.
      CONCATENATE lc_text_01 xv_premise INTO lv_message_premise SEPARATED BY space.
      xt_message-line = lv_message_premise.
      APPEND xt_message.
      CONCATENATE lc_text_02 xv_address INTO lv_message_address SEPARATED BY space.
      xt_message-line = lv_message_address.
      APPEND xt_message.
      CONCATENATE lc_text_03 xv_auszdat INTO lv_message_auszdat SEPARATED BY space.
      xt_message-line = lv_message_auszdat.
      APPEND xt_message.
      DESCRIBE TABLE xt_message LINES lv_cnt.
      xys_gd_doc_data-doc_size =
         ( lv_cnt - 1 ) * 255 + STRLEN( xt_message ).
      xys_gd_doc_data-obj_langu = sy-langu.
      xys_gd_doc_data-obj_name  = lc_name.
      xys_gd_doc_data-obj_descr = lc_descr.
      xys_gd_doc_data-sensitivty = lc_f.
      CLEAR xyt_packing_list.
      REFRESH xyt_packing_list.
      xyt_packing_list-transf_bin = space.
      xyt_packing_list-head_start = lc_one.
      xyt_packing_list-head_num = lc_zero.
      xyt_packing_list-body_start = lc_one.
      DESCRIBE TABLE xt_message LINES xyt_packing_list-body_num.
      xyt_packing_list-doc_type = lc_doctype.
      APPEND xyt_packing_list.
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = xs_gd_doc_data
          put_in_outbox              = lc_true
          commit_work                = lc_true
        IMPORTING
          sent_to_all                = lv_sent_all
        TABLES
          packing_list               = xt_packing_list
          contents_txt               = xt_message
          receivers                  = xt_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.
      IF sy-subrc <> 0.
    *Do Nothing
      ENDIF.
    Hope this resolve your query.
    Regards,
    Manish

  • Regarding email generation with attachment

    Hi Experts,
    1)   Iam sending an email with excel attachment by using the FM "SO_NEW_DOCUMENT_ATT_SEND_API1".
       My problem is for example if i have 5 lines in the email table then these 5 lines are showing in single in the excel.
    How can i rectify this?
    2)  i need to submit the report in the back ground with variant and with out selection screen.How to do this?  
    Rgds,
    Krishna.

    Hi,
      Append each line of ur text seperately in an internal table for eg.  
       objtxt = text-007.
      APPEND objtxt.
      CLEAR objtxt.
      APPEND objtxt.
      objtxt = text-008.
      APPEND objtxt.
      CLEAR objtxt.
      APPEND objtxt.
    *Function module to send email with an attachment
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = docdata
          put_in_outbox              = 'X'
          commit_work                = 'X'
        TABLES
          packing_list               = objpack
          object_header              = objhead
          contents_bin               = objbin
          contents_txt               = objtxt
          receivers                  = reclist
        EXCEPTIONS
          too_many_receivers         = 1
          document_not_sent          = 2
          document_type_not_exist    = 3
          operation_no_authorization = 4
          parameter_error            = 5
          x_error                    = 6
          enqueue_error              = 7
          OTHERS                     = 8.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ELSE.
        MESSAGE s899(m3) WITH 'Mail sent successfully!'.
      ENDIF.
    Then u  ll get the mail the way u designed.
    The answer of ur 2nd question is........
    Specify the selection screen in ur program
    and use FMs 'JOB_OPEN' ,  'JOB_CLOSE' & 'JOB_SUBMT' to schedule the job in the background..
    regards,
    ajit.

  • So_new_document_att_send_api1....please give me test data

    Hi Experts,
    i am using so_new_document_att_send_api1 FM for send a mail to users with out any attachment,
    plz give me test data , why i am using so_new_document_att_send_api1    instead of so_new_document_send_api1 , due to i need text in BOLD.  i can send data in HTML format.
    plz help me on this issue.
    Thanks.

    Hi,
    I have mentioned the use of u r FM's are
    SO_NEW_DOCUMENT_ATT_SEND_API1 - Sends emails with texts and attachments
    SO_NEW_DOCUMENT_SEND_API1 - Sends emails with texts.
    check the follwing example..
    It will be useful to u....
    CONSTANTS : C_HIGH TYPE SODOCCHGI1-PRIORITY VALUE '1' .
    DATA : I_CONTENT TYPE TABLE OF SOLISTI1  ,
    I_REC TYPE TABLE OF SOMLRECI1 .
    DATA : WA_DOCDATA TYPE SODOCCHGI1 ,
    WA_CONTENT TYPE SOLISTI1   ,
    WA_REC     TYPE SOMLRECI1  .
    FILL DOCUMENT DATAWA_DOCDATA-OBJ_NAME    = 'MESSAGE' .
    WA_DOCDATA-OBJ_DESCR   = 'test'    .
    WA_DOCDATA-OBJ_LANGU   = 'E'       .
    WA_DOCDATA-SENSITIVTY  = 'F'       .
    WA_DOCDATA-OBJ_PRIO    = C_HIGH    .
    WA_DOCDATA-NO_CHANGE   = 'X'       .
    WA_DOCDATA-PRIORITY    = C_HIGH    .
    FILL OBJECT CONTENTCLEAR WA_CONTENT .
    WA_CONTENT-LINE = 'test mail' .
    APPEND WA_CONTENT TO I_CONTENT .
    FILL RECEIVERSCLEAR WA_REC .
    WA_REC-RECEIVER = SY-UNAME .
    WA_REC-REC_TYPE = 'B'.
    APPEND WA_REC TO I_REC .
    CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
      EXPORTING
        DOCUMENT_DATA              = WA_DOCDATA
      TABLES
        OBJECT_CONTENT             = I_CONTENT
        RECEIVERS                  = I_REC
      EXCEPTIONS
        TOO_MANY_RECEIVERS         = 1
        DOCUMENT_NOT_SENT          = 2
        DOCUMENT_TYPE_NOT_EXIST    = 3
        OPERATION_NO_AUTHORIZATION = 4
        PARAMETER_ERROR            = 5
        X_ERROR                    = 6
        ENQUEUE_ERROR              = 7
        OTHERS                     = 8.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
      WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Regards
    Kiran

  • SO_NEW_DOCUMENT_ATT_SEND_API1, how to save a copy of send item if i use thi

    I  am using SO_NEW_DOCUMENT_ATT_SEND_API1 , this FM to send employ details through mail as pdf, but i want a copy of all send details in my computer also, can any one help me for this , to achieve

    Hi Kiran,
        You can use transaction 'SOST' to view the sent items.
        Enter your mail id in the 'Sender Tab', Enter the Dates 
        under period tab. Use 'Send status' tab aptly to view the sent
        mails.
        Alternatively, Why dont you give the 'user' email id in the
        mailing list along with other recipients so that the user can
        have the mail in his Inbox. For getting the User email id,
        read PERSNUMBER and ADDRNUMBER from USR21table
        by passing BNAME = Sy-uname.
        Go to ADR6 table, pass the USR21-PERSNUMBER and  
        USR21-ADDRNUMBER and read the SMTP_ADDR which
        will be the users email id. Include this Email id alongwith the
        email recipient list to recieve the same copy into your inbox.
    <REMOVED BY MODERATOR>
    Regards
    Nanda
    Edited by: Alvaro Tejada Galindo on Feb 22, 2008 3:50 PM

  • Using the FM SO_NEW_DOCUMENT_ATT_SEND_API1

    Hi Gurus,
    I am using the FM SO_NEW_DOCUMENT_ATT_SEND_API1.
    My requirement needs me to email an attachment.
    Why is it that when I input
    A
    B
    C
    in my table, the value I am getting is
    A                         B                        C
    wherein I should get an attachment that should look like this one
    A
    B
    C
    My output file is a TXT file. I understand that this is using the CONTENT_BIN that uses the binary format.
    What I need is an attachment that is using the ASCII format. But when I use the ASCII format, I am getting an error: "error occurred during sending !".
    Do I need to make enhacements on the FM?
    Thanks in advance.
    Benedict

    Hi Benedict,
    Please refer to the below code.
    Program:  ZRAT                 Creation Date: 12.04.2007 *
    Program Title :  Retirement Age Trigger                  *
    Program Author:  Puneet Jhari                            *
    Program Type  :   Executable                             *
    Object ID     :                                          *
    Technical Specification Version:                         *
    Technical Specification Author:                          *
    Code Quality Reviewer     :                              *
    Transport No.          :  SRDK906499                     *
    Program Description:                                     *
    Inputs                                                   *
       Tables:                                               *
       Parameters                                            *
       External files:                                       *
    Outputs                                                  *
       Reports:                                              *
       Tables:                                               *
       Databases:                                            *
       Screens:                                              *
       Parameters                                            *
       External files:                                       *
       Other objects:                                        *
    Return codes set by ABAP:                                *
    Modification Informaion                                  *
    Program Version:                                         *
    Date         : DD-MMM-YYYY                               *
    Author       :                                           *
    Description  :                                           *
    Transport No.:                                           *
    REPORT  zrat NO STANDARD PAGE HEADING.
    *DATA DECLARATION
    DATA : BEGIN OF wa_ccode,
            bukrs TYPE t001-bukrs,
           END OF wa_ccode.
    DATA : itab_ccode LIKE TABLE OF wa_ccode.
    DATA : BEGIN OF wa_emp,
            pernr TYPE pa0001-pernr,
            sachp TYPE pa0001-sachp,
            sname TYPE pa0001-sname,
           END OF wa_emp.
    DATA : itab_emp LIKE TABLE OF wa_emp.
    DATA : BEGIN OF wa_bdate,
            nachn LIKE pa0002-nachn,
            vorna LIKE pa0002-vorna,
            pernr TYPE pa0002-pernr,
            gbdat TYPE pa0002-gbdat,
           END OF wa_bdate.
    DATA : itab_bdate LIKE TABLE OF wa_bdate.
    DATA : new_date LIKE sy-datum.
    DATA : diff TYPE i.
    DATA : years LIKE p0347-scryy,
           months LIKE p0347-scrmm,
           days LIKE p0347-scrdd.
    DATA : sup_code LIKE pa0001-sachp,
           itab_usrid LIKE t526-usrid,
           sup_pernr LIKE pa0105-pernr.
    DATA : BEGIN OF wa_email,
           usrid_long LIKE pa0105-usrid_long,
           END OF wa_email.
    DATA : sup_email LIKE TABLE OF wa_email.
    DATA : gwa_document_data LIKE sodocchgi1,
           gc_name  TYPE so_obj_nam VALUE 'RETIREMENT',
           gc_senst TYPE so_obj_sns VALUE 'P',
           gc_size  TYPE so_doc_siz VALUE '510',
           gi_obj_cnt LIKE TABLE OF solisti1 WITH HEADER LINE,
           gi_recievers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
           gwa_obj_cnt LIKE LINE OF gi_obj_cnt.
    DATA : smtp_addr LIKE adr6-smtp_addr.
    DATA : wa_date LIKE sy-datum,
           entries LIKE sy-tabix,
           name(15),
           line1(18) TYPE c,
           line2(20) TYPE c,
           line3(20) TYPE c,
           line4(23) TYPE c,
           line5(10) TYPE c,
           line6(45) type c,
           date(2) TYPE c,
           month(2) TYPE c,
           year(4) TYPE c.
    *START OF SELECTION
    SELECT bukrs
    FROM t001
    INTO TABLE itab_ccode
    WHERE land1 EQ 'GB'.
    SORT itab_ccode.
    DELETE ADJACENT DUPLICATES FROM itab_ccode.
    SELECT pernr sachp sname
    FROM pa0001
    INTO TABLE itab_emp
    FOR ALL ENTRIES IN itab_ccode
    WHERE bukrs EQ itab_ccode-bukrs AND begda LE sy-datum AND
    endda GE sy-datum and persg eq '1'.
    SELECT nachn vorna pernr gbdat
    FROM pa0002
    INTO TABLE itab_bdate
    FOR ALL ENTRIES IN itab_emp
    WHERE pernr EQ itab_emp-pernr.
    *TO CHECK EMPLOYEES WHOSE AGE IS NEAR 75 YEARS.
    LOOP AT itab_bdate INTO wa_bdate.
      new_date = wa_bdate-gbdat.
    *TO CALCULATE THE AGE TILL DATE
      CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
        EXPORTING
          date1                         = sy-datum
          date2                         = new_date
         output_format                 = '05'
       IMPORTING
         years                         = years
         months                        = months
         days                          = days
      IF sy-subrc <> 0.
      ENDIF.
      IF years EQ 64 AND months EQ 4.
        IF days GE 23 AND days LE 31.
    *FETCH THE DATA IF THE AGE IS NEARING 75 YEARS
          SELECT SINGLE sachp FROM pa0001 INTO sup_code WHERE pernr EQ
          wa_bdate-pernr AND begda LE sy-datum AND endda GE sy-datum.
          SELECT SINGLE usrid FROM t526 INTO itab_usrid WHERE sachx EQ
          sup_code.
          SELECT SINGLE pernr FROM pa0105 INTO sup_pernr WHERE usrid EQ
          itab_usrid AND subty EQ '0001'.
          clear sup_email[].
          SELECT usrid_long FROM pa0105 INTO TABLE sup_email WHERE pernr EQ
          sup_pernr AND subty EQ '0010'.
    *EMAIL ADDRESS OF THE SUPERVISOR TO BE NOTIFIED
          CLEAR gi_obj_cnt.
          CLEAR gi_recievers.
          CLEAR gwa_document_data.
          Loop at sup_email into wa_email.
          write sy-uline+0(5).
          write sy-uline+10(5).
          write sy-uline+20(5).
          write sy-uline+30(5).
          write sy-uline+40(5).
          write sy-uline+50(5).
          write sy-uline+60(5).
          write sy-uline+70(5).
          smtp_addr = wa_email-usrid_long.
          gi_recievers-receiver = smtp_addr.
          gi_recievers-rec_type = 'U'.
          gi_recievers-com_type = 'INT'.
          APPEND gi_recievers.
          Endloop.
          smtp_addr = '[email protected]'.
          gi_recievers-receiver = smtp_addr.
          gi_recievers-rec_type = 'U'.
          gi_recievers-com_type = 'INT'.
          APPEND gi_recievers.
          gwa_document_data-obj_name    = gc_name.
          gwa_document_data-obj_descr   = 'RETIRE'.
          gwa_document_data-sensitivty  = gc_senst.
          gwa_document_data-obj_langu = sy-langu.
    *CONTENT OF THE EMAIL TO BE SENT
          line1 = 'Please note that  '.
          line2 = wa_bdate-vorna.
          line3 = wa_bdate-nachn.
          line4 = ' will be 65 years on  '.
          line50(4) = wa_bdate-gbdat4(4).
          date = line5+2(2).
          month = line5+0(2).
          year = wa_bdate-gbdat+0(4) + 65.
          CONCATENATE date month year INTO line5 SEPARATED BY '.'.
          line6 = '.Please complete the Retirement Procedure.'.
          CONCATENATE line1 line2 line3 line4 line5 line6 INTO gwa_obj_cnt
          SEPARATED BY space.
          APPEND gwa_obj_cnt TO gi_obj_cnt.
          CLEAR gwa_obj_cnt.
          DESCRIBE TABLE gi_obj_cnt LINES entries.
          READ TABLE gi_obj_cnt INDEX entries.
    gwa_document_data-doc_size = ( entries - 1 ) * 255 + STRLEN( gi_obj_cnt
    *FUNCTION MODULE TO SEND THE EMAIL TO THE CONCERNED PERSONS
    CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
      EXPORTING
        document_data                    = gwa_document_data
        document_type                    = 'RAW'
             commit_work                      = 'X'
            TABLES
             object_content                   = gi_obj_cnt
              receivers                        = gi_recievers
      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
    *MESSAGE TO BE DISPLAYED AFTER THE EXECUTION
         endif.
          CASE sy-subrc.
            WHEN 0.
              LOOP AT gi_recievers.
                IF gi_recievers-receiver = space.
                  name = gi_recievers-rec_id.
                ELSE.
                  name = gi_recievers-receiver.
                ENDIF.
                IF gi_recievers-retrn_code = 0.
                  WRITE: / name, ': succesfully sent'.
                ELSE.
                  WRITE: / name, ': error occured'.
                ENDIF.
              ENDLOOP.
            WHEN 1.
              WRITE: / 'Too many receivers specified !'.
            WHEN 2.
              WRITE: / 'No receiver got the document !'.
            WHEN 4.
              WRITE: / 'Missing send authority !'.
            WHEN OTHERS.
              WRITE: / 'Unexpected error occurred !'.
          ENDCASE.
        ENDIF.
      ENDIF.
    ENDLOOP.
    In case you have any further clarifications,do let me know.
    Regards,
    Puneet Jhari.

  • Send email to external user using fm 'SO_NEW_DOCUMENT_ATT_SEND_API1'

    Hi friends,
    I wrote this code to send mail to external user from sap.
    It did not work properly can anyone help me to send email to extenal user.
    The return code after executing the function module is 2.
    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.
    Creating the document to be sent
    DOC_CHNG-OBJ_NAME = 'OFFER'.
    DOC_CHNG-OBJ_DESCR = 'abcd'.
    OBJTXT = 'aaaaaaaaaaa:'.
    APPEND OBJTXT.
    OBJTXT = 'bbbbbbbbbb'.
    APPEND OBJTXT.
    OBJTXT = 'ccccccccccccc.'.
    APPEND OBJTXT.
    DESCRIBE TABLE OBJTXT LINES TAB_LINES.
    READ TABLE OBJTXT INDEX TAB_LINES.
    DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
    RECLIST-RECEIVER = mail address.
    RECLIST-REC_TYPE = 'U'.
    RECLIST-COM_TYPE = 'INT'.
    RECLIST-NOTIF_DEL = 'X'.
    RECLIST-NOIF_NDEL = 'X'.
    APPEND RECLIST.
    Creating 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.
    Creating the document attachment
    (Assume the data in OBJBIN are given in BMP format)
    OBJBIN = ' \O/ '. APPEND OBJBIN.
    OBJBIN = '     '. APPEND OBJBIN.
    OBJBIN = ' / \ '. APPEND OBJBIN.
    DESCRIBE TABLE OBJBIN LINES TAB_LINES.
    OBJHEAD = 'picasso.bmp'. APPEND OBJHEAD.
    Creating 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   = 'BMP'.
    OBJPACK-OBJ_NAME   = 'ATTACHMENT'.
    OBJPACK-OBJ_DESCR = 'Reproduction object 138'.
    OBJPACK-DOC_SIZE   = TAB_LINES * 255.
      APPEND OBJPACK..
    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.
    IF SY-SUBRC NE 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

    Hi,
    Check in SCOT t-code whether it has been properly configred to send the mails
    Regards,
    siva chalasani.

  • Send attachment though mail using FM SO_NEW_DOCUMENT_ATT_SEND_API1

    Hello Gurus,
    Please help me with the mail sending attachment(excel file) using FM SO_NEW_DOCUMENT_ATT_SEND_API1.
    Here is the actual problem.
    I am using the FM SO_NEW_DOCUMENT_ATT_SEND_API1 in my prog.
    My attachment(excel sheet which is taken from internal table) contains the 10 records with one header description and data related to that description.
    I am able to send the attachment but the records in the attachment has more than 255 characters nearly 700 character length.
    So I spilt up each internal table record(with structure type solisti1) into 3 internal table records and populated it.
    It is showing the entire record in the attached file but I am not able to see some fields which are embeded deeply inside the cells.
    And they are not having any proper allignment.
    Please do help me.
    Promise to reward points.
    Mac

    Here is the sample code....
    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.
    Creating the document to be sent
    DOC_CHNG-OBJ_NAME = 'OFFER'.
    DOC_CHNG-OBJ_DESCR = 'Auction of a Picasso jr'.
    OBJTXT = 'Reserve price : $250000'.
    APPEND OBJTXT.
    OBJTXT = 'A reproduction of the painting to be auctioned'.
    APPEND OBJTXT.
    OBJTXT = 'is enclosed as an 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 ).
    Creating 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.
    Creating the document attachment
    (Assume the data in OBJBIN are given in BMP format)
    OBJBIN = ' \O/ '. APPEND OBJBIN.
    OBJBIN = '     '. APPEND OBJBIN.
    OBJBIN = ' / \ '. APPEND OBJBIN.
    DESCRIBE TABLE OBJBIN LINES TAB_LINES.
    OBJHEAD = 'picasso.bmp'. APPEND OBJHEAD.
    Creating 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   = 'BMP'.
    OBJPACK-OBJ_NAME   = 'ATTACHMENT'.
    OBJPACK-OBJ_DESCR = 'Reproduction object 138'.
    OBJPACK-DOC_SIZE   = TAB_LINES * 255.
    APPEND OBJPACK..
    Entering names in the distribution list
    RECLIST-RECEIVER = '<name>@yahoo.com'.
    RECLIST-REC_TYPE = 'U'.
    APPEND RECLIST.
    RECLIST-RECEIVER = 'DLI-NEUREICH'.
    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'
             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.
         CASE SY-SUBRC.
           WHEN 0.
             WRITE: / 'Result of the send process:'.
             LOOP AT RECLIST.
               WRITE: / RECLIST-RECEIVER(48), ':'.
               IF RECLIST-RETRN_CODE = 0.
                 WRITE 'sent successfully'.
               ELSE.
                 WRITE 'not sent'.
               ENDIF.
             ENDLOOP.
           WHEN 1.
         WRITE:
         / 'no authorization to send to the specified number recipients!'.
           WHEN 2.
             WRITE: / 'document could not be sent to any of the recipient'.
           WHEN 4.
             WRITE: / 'no authorization to send !'.
           WHEN OTHERS.
             WRITE: / 'error occurred during sending !'.
         ENDCASE.
    Regards,
    Pavan.

  • Send excel attachment using FM SO_NEW_DOCUMENT_ATT_SEND_API1

    Hi ABAPers,
    I managed to send excel attachment using FM SO_NEW_DOCUMENT_ATT_SEND_API1.
    Let say I send it to my own email account.
    But, when try to open the excel document, from lotus notes, there is warning message produced by the microsoft excel saying:
    "The file is not in a recognizable format.
    and so on....."
    Anyway, when I click button 'OK', excel sheet will be opened and no information lost.
    How can we code the abap program so that the message will not come each time I open the attachment from my lotus notes?
    Or this is just the tab delimited issue?
    Thank you.
    Regards,
    Edward.

    Hi Shan,
    Thank you for replying.
    I have the same as follows:
      DESCRIBE TABLE lt_contents_hex LINES lv_lines.
      lt_packing_list-transf_bin = 'X'.
      lt_packing_list-head_start = 1.
      lt_packing_list-head_num   = 1.
      lt_packing_list-body_start = 1.
      lt_packing_list-body_num   = lv_lines.
      lt_packing_list-doc_type   = 'XLS'.
      lt_packing_list-obj_name   = 'ATTACHMENT'.
      lt_packing_list-obj_descr  = 'Attachment'.
      lt_packing_list-doc_size   = lv_lines * 255.
      APPEND lt_packing_list.
    I'm using lt_contents_hex instead of lt_contents_bin.
    Still the problem is there.
    Is there any other way to calculate the doc size correctly?
    Regards,
    Edward.

  • SO_NEW_DOCUMENT_ATT_SEND_API1- problem in mail text

    Hi All,
    I am using FM SO_NEW_DOCUMENT_ATT_SEND_API1 to send emails.
    I have taken the reference program from the documentation of this function module given by SAP.
    I want to send two attachments in text format using this FM and I am able to send the same.
    The problem I am facing is that every character of text is seprated by one space. i.e. between any two characters one space is inserted in the attachement.
    e.g. if I need to display :::
    "This is test mail" -->
    I am gettting the output as
    "T h i s  i s  t e s t  m a i l".
    Is there any parameter which I need to set to avoid this problem.
    Any input would be highly appreciated.
    regards,
    Lalit

    Hi,
    I tried the solutions given to me but I am sorry to say that still my problem persists.
    I am pasting my test code below. Request your help.
    Regards,
    Lalit
    REPORT  ZTEST_LALIT2.
    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: OBJBIN1  type soli_tab. "   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.
    Creating the document to be sent
    DOC_CHNG-OBJ_NAME = 'OFFER'.
    DOC_CHNG-OBJ_DESCR = 'Auction of a Picasso jr'.
    OBJTXT = 'Reserve price : $250000'.
    APPEND OBJTXT.
    OBJTXT = 'A reproduction of the painting to be auctioned'.
    APPEND OBJTXT.
    OBJTXT = 'is enclosed as an 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 ).
    Creating the entry for the compressed document
    CLEAR OBJPACK-TRANSF_BIN.
    OBJPACK-HEAD_START = 1.
    OBJPACK-HEAD_NUM   = 0.
    OBJPACK-BODY_START = 0.
    OBJPACK-BODY_NUM   = TAB_LINES.
    OBJPACK-DOC_TYPE   = 'RAW'.
    APPEND OBJPACK.
    Creating the document attachment
    (Assume the data in OBJBIN are given in BMP format)
    OBJBIN = 'This is a test mail'. condense objbin. APPEND OBJBIN.
    OBJBIN = '  |  '. APPEND OBJBIN.
    OBJBIN = 'test '. APPEND OBJBIN.
    DESCRIBE TABLE OBJBIN LINES TAB_LINES.
    OBJHEAD = 'picasso.txt'. APPEND OBJHEAD.
    Creating 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   = 'TXT'.
    OBJPACK-OBJ_NAME   = 'ATTACHMENT'.
    OBJPACK-OBJ_DESCR = 'Reproduction object 138'.
    OBJPACK-DOC_SIZE   = TAB_LINES * 132.
    APPEND OBJPACK..
    CALL FUNCTION 'QCE1_CONVERT'
            TABLES
              t_source_tab         = OBJBIN
              t_target_tab         = OBJBIN1[]
            EXCEPTIONS
              convert_not_possible = 1
              OTHERS               = 2.
    Entering names in the distribution list
    RECLIST-RECEIVER = 'LALITK'.
    RECLIST-REC_TYPE = 'B'.
    APPEND RECLIST.
    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  = OBJBIN1[]
              CONTENTS_TXT  = OBJTXT
              RECEIVERS     = RECLIST
         EXCEPTIONS
              TOO_MANY_RECEIVERS = 1
              DOCUMENT_NOT_SENT  = 2
              OPERATION_NO_AUTHORIZATION = 4
              OTHERS = 99.

Maybe you are looking for

  • Problem with printing sapscript on new HP P2015 printers ?

    A brand new printer is installed the HP P2015 at a customer. suddenly all sapscripts are printed in courier. we have already updated the drivers but somehow it doesn't seem to work ? Is there something else that needs to be changed on the SAP side or

  • Lightroom watermarks not showing up in Windows explorer.

    Quick question for everybody. I imagine there's an easy solution for it, I just haven't been able to figure it out. The company I work for needs to manage and watermark many different types of photos (perfect for Lightroom.)  The only problem is, whe

  • Meta data not included upon export - Please confirm

    Hello everyone. I'm looking to confirm with several people the following: After updating to the most recent version of Aperture and Tiger (Leopard is not tame enough yet), exported images do not include meta data (yes, I know how to click the little

  • An error occurred creating the form (task 1202, form 0). (ALC-WKS-007-040)

    hi guys, I got an error occurred creating the form (task 1202, form 0). (ALC-WKS-007-040). i am using XDP form. so what can i do now? I am very new person working on LiveCycle. I read earlier topic on same error but cant undersand anything. so please

  • Encore DVD's are shakey/jumpy after burning...

    I'm very new to video but I've learned just enough to be dangerous, so any constructive help is appreciated. Projects were shot on a Nikon D300s and D90(720p, 24fps), cut up in Premiere Pro CS5 and Dynamic Linked into Encore.  Using the standard NTSC