Application Development 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: 

Modified an existing report convert display into ALV and send to email

Former Member
0 Kudos

hi,

convert existing report into alv & send o/p of alv to email .

praveen .

2 REPLIES 2

former_member756887
Participant
0 Kudos

u can't trhe exitinmg report in alv form but u can change it in excel , rich tex , html format

for that execute ur report click on list -file-select option.

for sending mail here u are not define that u want to send mail external or internal . if u want to send mail internal then for that

for that execute ur report click on list ---office .

if u want to send mail external then..

former_member756887
Participant
0 Kudos

write this code

REPORT zsendemail .

PARAMETERS: psubject(40) type c default 'Hello',

p_email(40) type c default 'email address'.

data: it_packing_list like sopcklsti1 occurs 0 with header line,

it_contents like solisti1 occurs 0 with header line,

it_receivers like somlreci1 occurs 0 with header line,

it_attachment like solisti1 occurs 0 with header line,

gd_cnt type i,

gd_sent_all(1) type c,

gd_doc_data like sodocchgi1,

gd_error type sy-subrc.

data: it_message type standard table of SOLISTI1 initial size 0

with header line.

START-OF-SELECTION.

Perform populate_message_table.

PERFORM send_email_message.

perform initiate_mail_execute_program.

form populate_message_table.

Append 'Email line 1' to it_message.

Append 'Email line 2' to it_message.

Append 'Email line 3' to it_message.

Append 'Email line 4' to it_message.

endform.

form send_email_message.

gd_doc_data-doc_size = 1.

gd_doc_data-obj_langu = sy-langu.

gd_doc_data-obj_name = 'SAPRPT'.

gd_doc_data-obj_descr = psubject.

gd_doc_data-sensitivty = 'F'.

clear it_packing_list.

refresh it_packing_list.

it_packing_list-transf_bin = space.

it_packing_list-head_start = 1.

it_packing_list-head_num = 0.

it_packing_list-body_start = 1.

describe table it_message lines it_packing_list-body_num.

it_packing_list-doc_type = 'RAW'.

append it_packing_list.

clear it_receivers.

refresh it_receivers.

it_receivers-receiver = p_email.

it_receivers-rec_type = 'U'.

it_receivers-com_type = 'INT'.

it_receivers-notif_del = 'X'.

it_receivers-notif_ndel = 'X'.

append it_receivers.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = gd_doc_data

PUT_IN_OUTBOX = 'X'

IMPORTING

SENT_TO_ALL = gd_sent_all

TABLES

PACKING_LIST = it_packing_list

CONTENTS_TXT = it_message

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.

gd_error = sy-subrc.

loop at it_receivers.

endloop.

endform.

form initiate_mail_execute_program.

wait up to 2 seconds.

if gd_error eq 0.

submit rsconn01 with mode = 'INT'

with output = 'X'

and return.

endif.

endform.