Skip to Content
0
Former Member
Dec 01, 2004 at 04:31 AM

Email via report using : SO_NEW_DOCUMENT_ATT_SEND_API1: Function Module.

442 Views

Hi,

Actually i want to send a mail ( to a yahoo mail address ) using a report, as i came to know that one has to use the above Function Module i started using it. But i am unable to send an e-mail. the report is getting executed and the return code i am getting is zero and i am getting an object i.d. too. But the recipient is not receiving the mail.

I am attaching my code here. Please help.

Any help in this regard is highly appreciated.

DATA : tab_lines TYPE i.

DATA : var_receiver LIKE sadrud.

  • EXPORT TO FM

DATA : wa_docu_data LIKE sodocchgi1.

  • IMPORT FROM FM

DATA : flag_sent_to_all LIKE sonv-flag.

DATA : obj_id LIKE sofolenti1-object_id.

  • TABLES TO FM

DATA : obj_header LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE.

DATA : rec_list LIKE somlreci1 OCCURS 0 WITH HEADER LINE.

DATA : obj_txt LIKE solisti1 OCCURS 0 WITH HEADER LINE.

START-OF-SELECTION.

var_receiver-address = 'gouthamprg@yahoo.com'.

obj_txt-line = 'This is the sent Document'.

APPEND obj_txt.

CLEAR obj_txt.

DESCRIBE TABLE obj_txt LINES tab_lines.

READ TABLE obj_txt INDEX tab_lines.

BREAK-POINT.

wa_docu_data-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( obj_txt ).

wa_docu_data-obj_name = 'TESTING'.

wa_docu_data-obj_descr = 'This is Test Mail'.

wa_docu_data-proc_type = 'R'.

wa_docu_data-proc_name = 'Z34_MAIL_TEST'.

wa_docu_data-proc_syst = '*'.

wa_docu_data-proc_clint = '*'.

  • wa_docu_data-to_do_out = 'X'.

  • wa_docu_data-sensitivity = 'O'.

obj_header-transf_bin = ' '.

  • obj_header-head_start = 1.

  • obj_header-head_num = 0.

obj_header-body_start = 1.

obj_header-body_num = tab_lines.

obj_header-doc_type = 'RAW'.

APPEND obj_header.

CLEAR obj_header.

BREAK-POINT.

rec_list-receiver = var_receiver-address.

rec_list-rec_type = 'U'.

rec_list-express = 'X'.

rec_list-com_type = 'INT'.

rec_list-notif_del = 'X'.

APPEND rec_list.

CLEAR rec_list.

BREAK-POINT.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = wa_docu_data

put_in_outbox = 'X'

commit_work = 'X'

IMPORTING

sent_to_all = flag_sent_to_all

new_object_id = obj_id

TABLES

packing_list = obj_header

  • OBJECT_HEADER =

  • CONTENTS_BIN =

contents_txt = obj_txt

  • CONTENTS_HEX =

  • OBJECT_PARA =

  • OBJECT_PARB =

receivers = rec_list

  • 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 SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

BREAK-POINT.

WRITE : / , 'Object Created' , obj_id,50 'SENT TO ALL' , flag_sent_to_all.

LOOP AT rec_list.

WRITE :/ , 'status' , rec_list-retrn_code,

/ , 'Sent to' , rec_list-receiver.

ENDLOOP.

Thanks and Regards,

Goutham.