Skip to Content

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

code snipped SO_DOCUMENT_SEND_API1, send message to BWP

Hi guys!

I can't get my fm SO_DOCUMENT_SEND_API1 running to send "just" a text message to a sap office user.

Could someone provide me with a code snipped for this?

I always get the error mesage "Document not sent"

thanks!

Edited by: Thomas Roithmeier on Oct 2, 2008 11:23 AM

Tags:
replied

Hi,

Try this.

data: ls_body    type solisti1,
        ls_ctrl    type zzsd_return_ctrl,
        ls_doc     type sodocchgi1,
        ls_dtyp    type zzsd_dtyp,
        ls_pack    type sopcklsti1,
        ls_rec     type somlreci1,
        lt_body    type table of solisti1,
        lt_pack    type table of sopcklsti1,
        lt_pdf     type table of solisti1,
        lt_rec     type table of somlreci1,
        lv_adrnr   type lfa1-adrnr,
        lv_size    type i,
        lv_sender  type soextreci1-receiver.

*----------------------------------------------------------------------
* Set the receiver
*----------------------------------------------------------------------
  clear ls_rec.
  ls_rec-receiver = sy-uname.
  ls_rec-rec_type = 'B'.
  ls_rec-express  = 'X'.
  append ls_rec to lt_rec.

*----------------------------------------------------------------------
* Fill the email object details
*----------------------------------------------------------------------
  clear ls_doc.
  ls_doc-obj_descr = 'Test Descr'.

*----------------------------------------------------------------------
* Build the email body
*----------------------------------------------------------------------
  clear ls_body.
  ls_body = 'Test text'.
  append ls_body to lt_body.
  clear ls_body.
  append ls_body to lt_body.

*----------------------------------------------------------------------
* Declare the email body format
*----------------------------------------------------------------------
  describe table lt_body lines sy-tfill.
  clear ls_pack.
  ls_pack-head_start = 1.
  ls_pack-head_num   = 0.
  ls_pack-body_start = 1.
  ls_pack-body_num   = sy-tfill.
  ls_pack-doc_type   = 'RAW'.
  append ls_pack to lt_pack.

  lv_sender = sy-uname.

*----------------------------------------------------------------------
* Send the email
*----------------------------------------------------------------------
  call function 'SO_DOCUMENT_SEND_API1'
    exporting
      document_data              = ls_doc
      sender_address             = lv_sender
      sender_address_type        = 'B'
    tables
      packing_list               = lt_pack
      contents_txt               = lt_body
      receivers                  = lt_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 ).
    write: / 'Error', sy-subrc.
  else.
    write: 'Doc sent'.
  endif.

Cheers,

Darren

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question