Skip to Content
author's profile photo Former Member
Former Member

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.....

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Posted on Sep 15, 2008 at 02:23 PM

    Read the Function module documentation , you get one example.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 15, 2008 at 05:15 PM

    Here you have a pretty detailed example by TJ including all the previous configuration needed...

    Sending E-Mail from ABAP - Version 46D and Lower - API Interface

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 15, 2008 at 05:40 PM

    Hi,

    Search forum with the keyword 'SO_NEW_DOCUMENT_ATT_SEND_API1 ' you will find many example's.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 16, 2008 at 08:15 AM

    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
    
    

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 12, 2009 at 12:36 PM

    Hi Friends,

    I have copied a report 'ZMULTIEXCEL' from www.sapdev.co.uk site.

    I would like to create an excel file with multiple sheets through an abap report and attach to an email and I have to send that excel file. But when I am going to run the report, excel has been created successfully and also dynamically excel file is opening. But I don't want to open excel file dynamically.

    I want to attach that excel file to an email id. Could you please help me?.

    Add a comment
    10|10000 characters needed characters exceeded

    • The ABAP code to send a sap mail is built around the FM SO_OBJECT_SEND which has the following pattern.

      call function 'SO_OBJECT_SEND'

      exporting

      • EXTERN_ADDRESS = ' '

      • FOLDER_ID = ' '

      • FORWARDER = ' '

      • OBJECT_FL_CHANGE = ' '

      • OBJECT_HD_CHANGE = ' '

      • OBJECT_ID = ' '

      • OBJECT_TYPE = ' '

      • OUTBOX_FLAG = ' '

      • OWNER = ' '

      • STORE_FLAG = ' '

      • DELETE_FLAG = ' '

      • SENDER = ' '

      • CHECK_ALREADY_SENT = ' '

      importing

      object_id_new =

      sent_to_all =

      tables

      • OBJCONT =

      • OBJHEAD =

      • OBJPARA =

      • OBJPARB =

      receivers =

      • PACKING_LIST =

      • ATT_CONT =

      • ATT_HEAD =

      • NOTE_TEXT =

      exceptions

      active_user_not_exist = 1

      communication_failure = 2

      component_not_available = 3

      folder_not_exist = 4

      folder_no_authorization = 5

      forwarder_not_exist = 6

      note_not_exist = 7

      object_not_exist = 8

      object_not_sent = 9

      object_no_authorization = 10

      object_type_not_exist = 11

      operation_no_authorization = 12

      owner_not_exist = 13

      parameter_error = 14

      substitute_not_active = 15

      substitute_not_defined = 16

      system_failure = 17

      too_much_receivers = 18

      user_not_exist = 19

      x_error = 20

      others = 21.

      In the next article we will understand the main parameters and table interfaces of the FM.

      And the parameter description is as follows::[http://www.thespot4sap.com/Articles/SAP_Mail_Understanding_SO_Object_Send.asp]

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.