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

Submit program - send list via email

Former Member
0 Likes
1,270

Hi all,

i want to submit a program in my coding and the result (list) should be sent via email...

I need a sample coding...

regards

5 REPLIES 5
Read only

Former Member
0 Likes
886

This message was moderated.

Read only

Former Member
0 Likes
886

Hi,

use this FM to send the report via email

SO_NEW_DOCUMENT_SEND_API1

Regards,

Siddarth

Read only

Former Member
0 Likes
886

*Setting the properties of mail

Sl_maildata-obj_name = 'Name of the Object"

Sl_maildata-obj_descr = "Subject of Mail".

sl_maildata-obj_langu = 'EN'.

*Should append all the List to the Mail

Append each and every line to wtl_mailtxt.

*Appending the receivers

tl_mailrec - append all the receiverrs

tl_mailrec-receiver = 'Mailid".

tl_mailrec-type = 'U' "for External address

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

document_data = sl_maildata

document_type = 'HTM'

commit_work = 'X'

TABLES

object_content = tl_mailtxt

receivers = tl_mailrec

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.

Read only

Former Member
0 Likes
886

Hi,

Hi,

SUBMIT <report> EXPORTING LIST TO MEMORY

AND RETURN.

CALL FUNCTION 'LIST_FROM_MEMORY'

TABLES

listobject = i_objbin----> it will store the out put from the report.

EXCEPTIONS

not_found = 1

OTHERS = 2.

IF sy-subrc = 0.

For sending Excel Attachment.

  • Send Message

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = i_docdata

put_in_outbox = c_x

TABLES

packing_list = i_objpack

object_header = i_objhead

contents_bin = i_objbin

contents_txt = i_objtxt

receivers = i_reclist

and specify the document type

i_objpack-doc_type = 'XLS'.

ENDIF.

See this link as well

Edited by: Amresh kumar Panda on Apr 3, 2009 4:58 PM

Read only

Former Member
0 Likes
886

Hi !

consider following program as example

TYPE-POOLS : slis.

DATA:

l_datum TYPE sy-datum,

ls_docdata TYPE sodocchgi1,

lt_objpack TYPE TABLE OF sopcklsti1 WITH HEADER LINE,

lt_objhead TYPE TABLE OF solisti1 WITH HEADER LINE,

lt_objtxt TYPE TABLE OF solisti1 WITH HEADER LINE,

lt_objbin TYPE TABLE OF solisti1 WITH HEADER LINE,

lt_reclist TYPE TABLE OF somlreci1 WITH HEADER LINE,

lt_listobject TYPE TABLE OF abaplist WITH HEADER LINE,

l_tab_lines TYPE i,

l_att_type LIKE soodk-objtp.

DATA: name(60).

RANGES s_vorne FOR blpk-vorne. " Rep Opr No

SUBMIT zirpt_daily_cost

WITH p_werks EQ p_werks

WITH p_udate EQ p_udate

WITH p_bno EQ p_bno

EXPORTING LIST TO MEMORY AND RETURN.

  • Read list from memory into table

CALL FUNCTION 'LIST_FROM_MEMORY'

TABLES

listobject = lt_listobject

EXCEPTIONS

not_found = 1

OTHERS = 2.

IF sy-subrc <> 0.

  • Error in function module &1

MESSAGE ID '61' TYPE 'E' NUMBER '731'

WITH 'LIST_FROM_MEMORY'.

ENDIF.

  • Because listobject is of size RAW(1000)

  • and objbin is of size CHAR(255) we make this table copy

CALL FUNCTION 'TABLE_COMPRESS'

TABLES

in = lt_listobject

out = lt_objbin

EXCEPTIONS

compress_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

  • Error in function module &1

MESSAGE ID '61' TYPE 'E' NUMBER '731'

WITH 'TABLE_COMPRESS'.

ENDIF.

  • NOTE: Creation of attachment is finished yet.

  • For your report, the attachment should be placed into table

  • objtxt for plain text or

  • objbin for binary content.

  • Now create the message and send the document.

  • Create Message Body

  • Title and Description

  • l_datum = sy-datum - 1.

l_datum = p_udate - p_bno .

dd = l_datum+6(2).

mm = l_datum+4(2).

yy = l_datum(4).

ls_docdata-obj_name = 'Cost Report'.

CONCATENATE p_subj '&Parameter= ' dd '/' mm '/' yy

INTO ls_docdata-obj_descr .

  • Main Text

lt_objtxt = 'Daily Cost Report'. "ls_docdata-obj_descr.

APPEND lt_objtxt.

  • Write Packing List (Main)

DESCRIBE TABLE lt_objtxt LINES l_tab_lines.

READ TABLE lt_objtxt INDEX l_tab_lines.

ls_docdata-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( lt_objtxt ).

CLEAR lt_objpack-transf_bin.

lt_objpack-head_start = 1.

lt_objpack-head_num = 0.

lt_objpack-body_start = 1.

lt_objpack-body_num = l_tab_lines.

lt_objpack-doc_type = 'RAW'.

APPEND lt_objpack.

  • Create Message Attachment

  • Write Packing List (Attachment)

l_att_type = 'ALI'.

DESCRIBE TABLE lt_objbin LINES l_tab_lines.

READ TABLE lt_objbin INDEX l_tab_lines.

lt_objpack-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( lt_objbin ).

lt_objpack-transf_bin = 'X'.

lt_objpack-head_start = 1.

lt_objpack-head_num = 0.

lt_objpack-body_start = 1.

lt_objpack-body_num = l_tab_lines.

lt_objpack-doc_type = l_att_type.

lt_objpack-obj_name = 'ATTACHMENT'.

lt_objpack-obj_descr = 'FLASH REPORT'. "#EC *

APPEND lt_objpack.

READ TABLE email INDEX 1.

IF sy-subrc = 0.

LOOP AT email.

lt_reclist-receiver = email-low.

lt_reclist-rec_type = 'U'.

lt_reclist-com_type = 'INT'.

APPEND lt_reclist.

ENDLOOP.

ENDIF.

READ TABLE cmail INDEX 1.

IF sy-subrc = 0.

LOOP AT cmail.

lt_reclist-receiver = cmail-low.

lt_reclist-rec_type = 'U'.

lt_reclist-com_type = 'INT'.

lt_reclist-copy = 'X'.

APPEND lt_reclist.

ENDLOOP.

ENDIF.

  • Send Message

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = ls_docdata

put_in_outbox = 'X'

commit_work = 'X'

TABLES

packing_list = lt_objpack

object_header = lt_objhead

contents_bin = lt_objbin

contents_txt = lt_objtxt

receivers = lt_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.

  • Document sent

MESSAGE ID 'SO' TYPE 'S' NUMBER '022'.

SUBMIT rsconn01 WITH mode = 'INT'

  • WITH OUTPUT = 'X'

AND RETURN.

ELSE.

  • Document <&> could not be sent

MESSAGE ID 'SO' TYPE 'S' NUMBER '023'

WITH ls_docdata-obj_name.

ENDIF.

ENDFORM. " f_send_mail