Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

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

Tags:
Former Member
Former Member replied

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.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question