‎2006 Aug 10 5:15 AM
Hello everybody !
I wrote a function-module which picks up user-ids on the basis of usergroups (which is its import parameter and fetched at runtime) and sends e-mails to the respective users (I used the function module SO_OBJECT_SEND to send mails).
But after executing the code normally I discovered it failed to pick up the usergroups. While executing it in debugging mode it did run successfully.
Can anyone help me ? I guess there might be some synchronization problem because when I put a 'wait for 20 seconds' command in between, code started running but now again it is showing inconsistency (sometimes it gives the result and sometimes it does not).
Thank you.
‎2006 Aug 10 7:40 PM
For sending the mail to the user, use the below code:
FUNCTION zb_mail_user.
*"----
""Local interface:
*" IMPORTING
*" REFERENCE(X_USNAM) TYPE USNAM
*" REFERENCE(X_MAIL_HEADER) TYPE SO_OBJ_DES
*" TABLES
*" MAIL_CONTENT STRUCTURE SOLISTI1
*" EXCEPTIONS
*" INVALID_PARAM
*" USER_NOT_FOUND
*"----
DATA:docdata LIKE sodocchgi1,
objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objhex LIKE solix OCCURS 10 WITH HEADER LINE,
reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE,
tab_lines TYPE i,
doc_size TYPE i.
IF x_usnam IS INITIAL .
RAISE invalid_param.
ENDIF.
Fill Mail Contents
objbin = space.
APPEND objbin.
docdata-obj_name = x_mail_header.
docdata-obj_descr = x_mail_header.
Main Text
objtxt[] = mail_content[].
Write Packing List (Main)
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'RAW'.
APPEND objpack.
Add sales manager User Id
reclist-receiver = x_usnam.
reclist-rec_type = 'B'.
APPEND reclist.
Send Message
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = docdata
put_in_outbox = ''
commit_work = 'X'
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
CONTENTS_HEX = objhex
OBJECT_PARA =
OBJECT_PARB =
receivers = 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.
MESSAGE ID 'SO' TYPE 'S' NUMBER '023' WITH docdata-obj_name.
RAISE invalid_param.
ENDIF.
ENDFUNCTION.
Regards,
Prakash.
‎2006 Aug 11 4:23 AM
hi prakash !
i thank you first of all for the prompt reply. i will modify the code accordingly and check and get back to you soon.
thank you once again.
‎2006 Aug 11 4:54 AM
hi !
actually the import parameter commit_work is not there in SO_NEW_DOCUMENT_ATT_SEND_API1 in version 4.6c.
now do i need to do commit work after the function call ?
thanks a lot.