Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

code snipped SO_DOCUMENT_SEND_API1, send message to BWP

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

2 REPLIES 2

Former Member
0 Kudos

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

Former Member
0 Kudos

Hello

Look at FM ZCSS_SEND_EMAIL

Or a this

CALL FUNCTION 'SO_DOCUMENT_SEND_API1' "#EC FB_OLDED

EXPORTING

document_data = document_data

  • PUT_IN_OUTBOX = ' '

sender_address = sender_address

sender_address_type = sender_address_type

  • IMPORTING

  • SENT_TO_ALL =

  • NEW_OBJECT_ID =

TABLES

packing_list = plist

object_header = object_header

contents_bin = so_ali

  • CONTENTS_TXT =

  • CONTENTS_HEX =

  • OBJECT_PARA =

  • OBJECT_PARB =

receivers = rec_tab

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

Chris