12-27-2005 7:33 AM
Hi all,
I'd like to send a internal SAP(express)-mail
with a purchase order as business object (BO) attached. (here BO = BUS2012).
It's the same thing you can do with generic object services, GOS, to send a SAP business object as mail notification
attachment.
Can I use the function 'SO_DOCUMENT_SEND_API1' or
do I have to use the BCS-functions?
All the reports BCS_EXAMPLE* don't send a
business object.
Thanks in advance,
Markus
12-27-2005 9:54 AM
Hi Markus,
I have used GOS menu for some custom development and also tried attaching documents through code.
Try using the class CL_SO_SRV_SEND_OBJECT. This is a public class and hence can be used. Instantiate it using CREATE OBJECT, and also use set object. You can use the borident(IS_OBJECT) parameter for it to point to the exact document or BP and then call Execute.
I have not done this but I feel this must be a good node to start from. I really doubt if you could use the standard FM for the emailing. But I am not sure.
Regards,
Srikanth
12-27-2005 10:12 AM
Hi Markus,
Execute seems to internally call this FM
CALL FUNCTION 'SO_DYNP_DOCUMENT_TRANSFER_API1'
STARTING NEW TASK 'GOS_SERV'
EXPORTING
document_data = ls_object_data
document_type = 'OBJ'
method = 'SNDA'
starting_at_x = 2
starting_at_y = 1
TABLES
object_header = lt_object_header
object_content = lt_object_content
application_object = lt_app_objects
exclude_fcode = lt_exclude_fcode
EXCEPTIONS
document_type_not_exist = 1
operation_no_authorization = 2
parameter_error = 3
document_not_sent = 4
x_error = 5
communication_failure = 7
system_failure = 8
OTHERS = 6.
For Values, see below
ls_object_data-obj_name = 'OBJECT'
ls_object_data-obj_descr = <object key(purc. no>
ls_object_data-sensitivity = 'P'
lt_object_header[1]-LINE = ' BUS2012 4500010913'
lt_app_objects[1]-objtype = 'BUS2012'
lt_app_objects[1]-objkey = <purc no.>
lt_object_header[] = lt_object_contents[]
lt_exclude_fcode
Exclude Fcodes
EINB
EOUT
EFPR
EFPU
EMRP
EWSP
ELIN
For further information put a break point at line 77 of CL_SO_SRV_SEND_OBJECT and try sending an object. You can see all the values there.
Regards,
Srikanth
12-28-2005 9:15 AM
OK Shrikanth,
I'll try to find a solution with your
hints. When ready I post it here.
Markus
12-28-2005 10:19 PM
Hi Markus,
Seems as if FM 'SO_DYNP_DOCUMENT_TRANSFER_API1' may popup a window. Below is a working program. Have fun!!
Cheers,
Ramki.
REPORT zramki_send_mail_bor .
*&---------------------------------------------------------------------*
*& Report ZRAMKI_SEND_MAIL_BOR
*&
*&---------------------------------------------------------------------*
*& Send document with BOR Object as attachment
*&---------------------------------------------------------------------*
DATA: docdata LIKE sodocchgi1,
objpack LIKE sopcklsti1 OCCURS 10 WITH HEADER LINE,
objhead LIKE solisti1 OCCURS 10 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.
DATA: tab_lines TYPE i,
doc_size TYPE i,
objdes(100).
* For the BOR attachment
CONSTANTS:
c_object_describe LIKE swotobjid-describe VALUE '*<OBJECT>*'.
DATA:
l_object TYPE swotobjid,
l_objheader LIKE soxobj.
PARAMETERS:
p_objtyp TYPE swo_objtyp OBLIGATORY,
p_objkey TYPE swo_typeid OBLIGATORY.
* Create Message Body
* Main Text
objtxt = 'Test Document.'.
APPEND objtxt.
objtxt = 'You will find a BOR object attachment in message.'.
APPEND objtxt.
objtxt = 'Have a nice day.'.
APPEND objtxt.
* Title and Description
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
docdata-obj_name = 'BOR Object'.
Concatenate p_objtyp '-' p_objkey into objdes.
Concatenate 'BOR Object' objdes 'as Attachment'
into docdata-obj_descr separated by space.
condense docdata-obj_descr.
* Write Packing List (Main)
CLEAR objpack-transf_bin.
objpack-head_start = 0.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'RAW'.
APPEND objpack.
* Create OBJ attachment
l_object-describe = c_object_describe.
l_object-objtype = p_objtyp.
l_object-objkey = p_objkey.
CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
IMPORTING
own_logical_system = l_object-logsys
EXCEPTIONS
own_logical_system_not_defined = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE e398(00) WITH 'No Log Sys Found'.
ENDIF.
MOVE-CORRESPONDING l_object TO l_objheader.
APPEND l_objheader TO objhead.
* Write Packing List (Attachment)
CLEAR objpack.
objpack-head_start = 1.
objpack-head_num = 1.
objpack-body_start = 0.
objpack-body_num = 0.
objpack-doc_type = 'OBJ'.
objpack-obj_name = p_objtyp.
objpack-obj_descr = Objdes.
APPEND objpack.
* Create receiver list
reclist-receiver = sy-uname.
reclist-rec_type = 'B'.
APPEND reclist.
* Send Message
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = docdata
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
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.
ENDIF.
WRITE: / 'End of Program'.
12-29-2005 10:02 AM