Application Development and Automation 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: 
Read only

SO_OBJECT_SEND

Former Member
0 Likes
651

Hi,

can we send mail to external mail using SO_OBJECT_SEND.I mean to any personal mail ids like yahoo.

if it so how is it possible ,please let me know as it is very urgent reqirement for me.

Reagrds,

Sunil.K

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
595

Have a look at below sample report:

REPORT Z34332_MAIL_WITH_ATTACHMENT1.
 
types: begin of t_mara,
matnr type mara-matnr,
matkl type mara-matkl,
mtart type mara-mtart,
meins type mara-meins,
end of t_mara.
 
 
data: gt_mara type table of t_mara,
wa_mara like line of gt_mara,
it_packing_list type table of SOPCKLSTI1,
wa_packing_list like line of it_packing_list,
it_receivers type table of SOMLRECI1,
wa_receivers like line of it_receivers,
it_mailbody type table of SOLISTI1,
wa_mailbody like line of it_mailbody,
it_attachment type table of SOLISTI1,
wa_attachment like line of it_attachment.
 
data: la_doc type SODOCCHGI1.
 
constants:
con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
con_cret type c value cl_abap_char_utilities=>CR_LF.
 
* get material
select matnr matkl mtart meins
into table gt_mara
from mara
up to 25 rows.
 
 
* Populate the subject/generic message attributes
la_doc-obj_langu = sy-langu.
la_doc-obj_descr = 'Material Details' . "Mail Header
la_doc-sensitivty = 'F'.
la_doc-doc_size = 1.
 
* Add the recipients email address
CLEAR wa_receivers.
REFRESH it_receivers.
wa_receivers-receiver = 'PCSDEVL'.
wa_receivers-rec_type = 'U'.
wa_receivers-com_type = 'INT'.
wa_receivers-notif_del = 'X'.
wa_receivers-notif_ndel = 'X'.
APPEND wa_receivers to it_receivers.
 
* Mail Body
CLEAR wa_mailbody.
REFRESH it_mailbody.
wa_mailbody-line = 'Please find the attachment'.
APPEND wa_mailbody to it_mailbody.
 
* Mail attachmwnt
CLEAR wa_attachment.
REFRESH it_attachment.
 
CONCATENATE 'MATNR' 'MATKL' 'MTART' 'MEINS'
INTO wa_attachment SEPARATED BY con_tab.
CONCATENATE con_cret wa_attachment INTO wa_attachment.
APPEND wa_attachment to it_attachment.
 
LOOP AT gt_mara INTO wa_mara.
CONCATENATE wa_mara-matnr wa_mara-matkl
wa_mara-mtart wa_mara-meins
INTO wa_attachment SEPARATED BY con_tab.
CONCATENATE con_cret wa_attachment INTO wa_attachment.
APPEND wa_attachment to it_attachment.
ENDLOOP.
 
 
* Describe the body of the message
CLEAR wa_packing_list.
REFRESH it_packing_list.
wa_packing_list-transf_bin = space.
wa_packing_list-head_start = 1.
wa_packing_list-head_num = 0.
wa_packing_list-body_start = 1.
wa_packing_list-body_num = 1.
wa_packing_list-doc_type = 'RAW'.
APPEND wa_packing_list to it_packing_list.
 
* Create attachment notification
wa_packing_list-transf_bin = 'X'.
wa_packing_list-head_start = 1.
wa_packing_list-head_num = 1.
wa_packing_list-body_start = 1.
 
DESCRIBE TABLE it_attachment LINES wa_packing_list-body_num.
wa_packing_list-doc_type = 'XLS'. " To word attachment change this as 'DOC'
wa_packing_list-obj_descr = ' '.
concatenate wa_packing_list-doc_type 'file' into wa_packing_list-OBJ_DESCR
separated by space.
wa_packing_list-doc_size = wa_packing_list-body_num * 255.
APPEND wa_packing_list to it_packing_list.
 
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = la_doc
PUT_IN_OUTBOX = 'X'
* SENDER_ADDRESS = SY-UNAME
* SENDER_ADDRESS_TYPE = 'B'
COMMIT_WORK = 'X'
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
* SENDER_ID =
tables
packing_list = it_packing_list
* OBJECT_HEADER =
CONTENTS_BIN = it_attachment
CONTENTS_TXT = it_mailbody
* CONTENTS_HEX =
* OBJECT_PARA =
* OBJECT_PARB =
receivers = it_receivers
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.

Best Regards,

Vibha

Please mark all the helpful answers

3 REPLIES 3
Read only

Former Member
0 Likes
596

Have a look at below sample report:

REPORT Z34332_MAIL_WITH_ATTACHMENT1.
 
types: begin of t_mara,
matnr type mara-matnr,
matkl type mara-matkl,
mtart type mara-mtart,
meins type mara-meins,
end of t_mara.
 
 
data: gt_mara type table of t_mara,
wa_mara like line of gt_mara,
it_packing_list type table of SOPCKLSTI1,
wa_packing_list like line of it_packing_list,
it_receivers type table of SOMLRECI1,
wa_receivers like line of it_receivers,
it_mailbody type table of SOLISTI1,
wa_mailbody like line of it_mailbody,
it_attachment type table of SOLISTI1,
wa_attachment like line of it_attachment.
 
data: la_doc type SODOCCHGI1.
 
constants:
con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
con_cret type c value cl_abap_char_utilities=>CR_LF.
 
* get material
select matnr matkl mtart meins
into table gt_mara
from mara
up to 25 rows.
 
 
* Populate the subject/generic message attributes
la_doc-obj_langu = sy-langu.
la_doc-obj_descr = 'Material Details' . "Mail Header
la_doc-sensitivty = 'F'.
la_doc-doc_size = 1.
 
* Add the recipients email address
CLEAR wa_receivers.
REFRESH it_receivers.
wa_receivers-receiver = 'PCSDEVL'.
wa_receivers-rec_type = 'U'.
wa_receivers-com_type = 'INT'.
wa_receivers-notif_del = 'X'.
wa_receivers-notif_ndel = 'X'.
APPEND wa_receivers to it_receivers.
 
* Mail Body
CLEAR wa_mailbody.
REFRESH it_mailbody.
wa_mailbody-line = 'Please find the attachment'.
APPEND wa_mailbody to it_mailbody.
 
* Mail attachmwnt
CLEAR wa_attachment.
REFRESH it_attachment.
 
CONCATENATE 'MATNR' 'MATKL' 'MTART' 'MEINS'
INTO wa_attachment SEPARATED BY con_tab.
CONCATENATE con_cret wa_attachment INTO wa_attachment.
APPEND wa_attachment to it_attachment.
 
LOOP AT gt_mara INTO wa_mara.
CONCATENATE wa_mara-matnr wa_mara-matkl
wa_mara-mtart wa_mara-meins
INTO wa_attachment SEPARATED BY con_tab.
CONCATENATE con_cret wa_attachment INTO wa_attachment.
APPEND wa_attachment to it_attachment.
ENDLOOP.
 
 
* Describe the body of the message
CLEAR wa_packing_list.
REFRESH it_packing_list.
wa_packing_list-transf_bin = space.
wa_packing_list-head_start = 1.
wa_packing_list-head_num = 0.
wa_packing_list-body_start = 1.
wa_packing_list-body_num = 1.
wa_packing_list-doc_type = 'RAW'.
APPEND wa_packing_list to it_packing_list.
 
* Create attachment notification
wa_packing_list-transf_bin = 'X'.
wa_packing_list-head_start = 1.
wa_packing_list-head_num = 1.
wa_packing_list-body_start = 1.
 
DESCRIBE TABLE it_attachment LINES wa_packing_list-body_num.
wa_packing_list-doc_type = 'XLS'. " To word attachment change this as 'DOC'
wa_packing_list-obj_descr = ' '.
concatenate wa_packing_list-doc_type 'file' into wa_packing_list-OBJ_DESCR
separated by space.
wa_packing_list-doc_size = wa_packing_list-body_num * 255.
APPEND wa_packing_list to it_packing_list.
 
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = la_doc
PUT_IN_OUTBOX = 'X'
* SENDER_ADDRESS = SY-UNAME
* SENDER_ADDRESS_TYPE = 'B'
COMMIT_WORK = 'X'
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
* SENDER_ID =
tables
packing_list = it_packing_list
* OBJECT_HEADER =
CONTENTS_BIN = it_attachment
CONTENTS_TXT = it_mailbody
* CONTENTS_HEX =
* OBJECT_PARA =
* OBJECT_PARB =
receivers = it_receivers
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.

Best Regards,

Vibha

Please mark all the helpful answers

Read only

Former Member
0 Likes
595

Hi,

1.It is possible to send mail using it.

check this link

http://www.sap-img.com/fu016.htm

Check this for configuration help..

http://www.sapgenie.com/interfaces/sapconnect.htm

See the below program.

FUNCTION Z_SEND_MAIL_FOR_SPOOLLIST.

*"----


""Local interface:

*" IMPORTING

*" VALUE(SPOOLNUMBER) LIKE SY-SPONO DEFAULT SY-SPONO

*" VALUE(MAILNAME) LIKE SOOD1-OBJNAM DEFAULT 'NOTE'

*" VALUE(SUBJECT) LIKE SOOD1-OBJDES

*" VALUE(RECEPIENT) LIKE SY-UNAME OPTIONAL

*" VALUE(DLI) LIKE SOOS1-DLINAM OPTIONAL

*" TABLES

*" TEXT STRUCTURE SOLI OPTIONAL

*" EXCEPTIONS

*" ERROR

*"----


DATA: OBJECT_HD_CHANGE LIKE SOOD1 OCCURS 0 WITH HEADER LINE,

OBJPARA LIKE SELC OCCURS 0 WITH HEADER LINE,

RECEIVERS LIKE SOOS1 OCCURS 0 WITH HEADER LINE.

OBJECT_HD_CHANGE-OBJLA = SY-LANGU.

OBJECT_HD_CHANGE-OBJNAM = MAILNAME.

OBJECT_HD_CHANGE-OBJDES = SUBJECT.

OBJECT_HD_CHANGE-OBJSNS = 'F'.

OBJECT_HD_CHANGE-VMTYP = 'T'.

OBJECT_HD_CHANGE-SKIPS = 'X'.

OBJECT_HD_CHANGE-ACNAM = 'SP01'.

OBJECT_HD_CHANGE-OBJCP = 'X'.

RECEIVERS-RCDAT = SY-DATUM.

RECEIVERS-RCTIM = SY-UZEIT.

IF DLI IS INITIAL.

RECEIVERS-RECNAM = RECEPIENT.

RECEIVERS-RTUNAM = RECEPIENT.

ELSE.

RECEIVERS-RECNAM = DLI.

RECEIVERS-ADR_NAME = DLI.

RECEIVERS-RECESC = 'C'.

ENDIF.

RECEIVERS-SNDEX = 'X'. " Express-Mail

APPEND RECEIVERS.

OBJPARA-NAME = 'SPI'.

OBJPARA-LOW = SPOOLNUMBER.

APPEND OBJPARA.

CALL FUNCTION 'SO_OBJECT_SEND'

EXPORTING

OBJECT_HD_CHANGE = OBJECT_HD_CHANGE

OBJECT_TYPE = 'RAW'

OWNER = SY-UNAME

TABLES

OBJCONT = TEXT

OBJPARA = OBJPARA

RECEIVERS = RECEIVERS

EXCEPTIONS

OTHERS = 01.

IF SY-SUBRC NE 0.

RAISE ERROR.

ENDIF.

ENDFUNCTION.

Regards,

Shiva Kumar

Read only

Former Member
0 Likes
595

Hi Sunil.

Use the following FM to send mail (both SAP Id and Internet Id like Yahoo)

CLEAR wa_reclist.

wa_reclist-receiver = 'your email id'.

wa_reclist-rec_type = 'U'. "(Check the possible values in domain SO_ESCAPE)

APPEND wa_reclist TO t_reclist.

  • Here

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = wa_docdata

put_in_outbox = c_x

commit_work = c_x

TABLES

packing_list = t_objpack

object_header = t_objhead

contents_bin = t_objbin

contents_txt = t_objtxt

receivers = t_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 EQ 0.

COMMIT WORK AND WAIT.

ENDIF.

Please award points