Skip to Content
avatar image
Former Member

Using FM "SO_DOCUMENT_SEND_API1" to send mail without attachment

Hi,

What are the parameters to be passed and their values

to send a mail using SO_DOCUMENT_SEND_API1

EXPORT PARAMETERS :

document_data = ?

sender_address = sy-userid

sender_address_type = 'INT'

commit_work = 'X'

TABLES :

packing_list = ?

contents_bin = ?

The content of the mail is not being displayed in the mail.

Thanks in advance.

Regards,Harika

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    May 16, 2008 at 10:24 AM

    Hi Harika,

    Check below piece of code.

    *&---------------------------------------------------------------------*
    *&      Form  mail_body
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM mail_body.
      DATA:  l_l1 TYPE i.
      CONSTANTS: lc_0 VALUE '0',
                 lc_1 VALUE '1',
                 lc_raw(3) TYPE c VALUE 'RAW'.
      REFRESH: i_objtxt[],
               i_objpack[].
      CLEAR: wa_objtxt.
      SORT i_fail BY type.
    * MAIL BODY
    * Customer Number
      CONCATENATE text-t18
                  w_kunnr
                  INTO wa_objtxt
                  SEPARATED BY space.
      APPEND wa_objtxt TO i_objtxt.
      CLEAR wa_objtxt.                        "blank line
      APPEND wa_objtxt TO i_objtxt.
    *  Complete Payment Doc Nos
      READ TABLE i_fail WITH KEY type = c_comp
                        TRANSPORTING NO FIELDS
                        BINARY SEARCH.
      IF sy-subrc EQ 0.
        wa_objtxt = text-t16.
        APPEND wa_objtxt TO i_objtxt.
        CLEAR: wa_fail, wa_objtxt.
        APPEND wa_objtxt TO i_objtxt.
        MOVE: text-t23   TO wa_objtxt,
              text-t24   TO wa_objtxt+17(5),
              text-t25   TO wa_objtxt+22(6),
              text-t26   TO wa_objtxt+40(18).
        APPEND wa_objtxt TO i_objtxt.
        CLEAR wa_objtxt.
    
        LOOP AT i_fail INTO wa_fail WHERE type EQ c_comp.
          DIVIDE wa_fail-disper BY 100.
          MOVE: wa_fail-belnr   TO wa_objtxt,
                wa_fail-buzei   TO wa_objtxt+17(5),
                wa_fail-wrbtr   TO wa_objtxt+22(16),
                wa_fail-disper  TO wa_objtxt+40(18).
          APPEND wa_objtxt TO i_objtxt.
          CLEAR: wa_fail, wa_objtxt.
        ENDLOOP.
      ENDIF.
    
    *  Partial Payment Doc Nos
      READ TABLE i_fail WITH KEY type = c_part
                        TRANSPORTING NO FIELDS
                        BINARY SEARCH.
      IF sy-subrc EQ 0.
        wa_objtxt = text-t17.
        APPEND wa_objtxt TO i_objtxt.
        CLEAR wa_fail.
        CLEAR: wa_objtxt.
        APPEND wa_objtxt TO i_objtxt.
        MOVE: text-t23   TO wa_objtxt,
              text-t24   TO wa_objtxt+17(5),
              text-t25   TO wa_objtxt+22(6),
              text-t26   TO wa_objtxt+40(18).
        APPEND wa_objtxt TO i_objtxt.
        CLEAR wa_objtxt.
        LOOP AT i_fail INTO wa_fail WHERE type EQ c_part.
          DIVIDE wa_fail-disper BY 100.
          MOVE: wa_fail-belnr   TO wa_objtxt,
                wa_fail-buzei   TO wa_objtxt+17(5),
                wa_fail-wrbtr   TO wa_objtxt+22(16),
                wa_fail-disper  TO wa_objtxt+40(18).
          APPEND wa_objtxt TO i_objtxt.
          CLEAR: wa_fail, wa_objtxt.
        ENDLOOP.
      ENDIF.
    
    * MAIL BODY-LENGTH
      DESCRIBE TABLE i_objtxt LINES l_l1.
      CLEAR wa_objpack-transf_bin.
      wa_objpack-head_start = lc_1.
      wa_objpack-head_num = lc_0.
      wa_objpack-body_start = lc_1.
      wa_objpack-body_num = l_l1.
      wa_objpack-doc_type = lc_raw.
      APPEND wa_objpack TO i_objpack.
    
    *SUBJECT
      CLEAR wa_doc_chng.
      wa_doc_chng-obj_name  = text-t15.
      wa_doc_chng-obj_descr = text-t15.
    ENDFORM.                    " mail_body
    
    *&---------------------------------------------------------------------*
    *&      Form  send_mail
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    FORM send_mail.
      CONSTANTS: lc_c       TYPE so_escape VALUE 'C',
                 lc_mode(3) TYPE c         VALUE 'INT'.
      CLEAR: wa_reclist, i_reclist[].
    *Recipient list
      wa_reclist-receiver = text-t14.       "DL
      wa_reclist-rec_type = lc_c.
      APPEND wa_reclist TO i_reclist.
    
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
          EXPORTING
            document_data                    = wa_doc_chng
            put_in_outbox                    = c_x
    *     IMPORTING
    *       SENT_TO_ALL                      =
    *       NEW_OBJECT_ID                    =
          TABLES
            packing_list                     = i_objpack
    *       OBJECT_HEADER                    =
    *       CONTENTS_BIN                     =
            contents_txt                     = i_objtxt
    *       CONTENTS_HEX                     =
    *       OBJECT_PARA                      =
    *       OBJECT_PARB                      =
            receivers                        = i_reclist
         EXCEPTIONS
           too_many_receivers               = 1
           document_not_sent                = 2
           document_type_not_exist          = 3
           operation_no_authorization       = 4
           parameter_error                  = 5
           x_error                          = 6
           enqueue_error                    = 7
           OTHERS                           = 8.
    *    IF SY-SUBRC <> 0.
    *    ENDIF.
      IF sy-subrc IS INITIAL.
    *Send mail immediately
        SUBMIT rsconn01 USING SELECTION-SET lc_mode AND RETURN.
        CALL FUNCTION 'SO_DEQUEUE_UPDATE_LOCKS'.
      ELSE.
        RAISE mail_not_sent.
      ENDIF.
    ENDFORM.                    " send_mail
    

    Thanks,

    Vinod.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 16, 2008 at 10:18 AM

    data: maildata type sodocchgi1.

    data: mailtxt type table of solisti1 with header line.

    data: mailrec type table of somlrec90 with header line.

    start-of-selection.

    clear: maildata, mailtxt, mailrec.

    refresh: mailtxt, mailrec.

    maildata-obj_name = 'TEST'.

    maildata-obj_descr = 'Test'.

    maildata-obj_langu = sy-langu.

    mailtxt-line = 'This is a test'.

    append mailtxt.

    mailrec-receiver = 'xyz at mail.com'.

    mailrec-rec_type = 'U'.

    append mailrec.

    call function 'SO_NEW_DOCUMENT_SEND_API1'

    exporting

    document_data = maildata

    document_type = 'RAW'

    put_in_outbox = 'X'

    tables

    object_header = mailtxt

    object_content = mailtxt

    receivers = mailrec

    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 : 'mail sent'.

    endif.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 16, 2008 at 10:21 AM

    Hi,

    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.

    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.

    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[] = it_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.

    Regards,

    Shiva Kumar

    Add comment
    10|10000 characters needed characters exceeded