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: 

Mail option in an alv report

Former Member
0 Kudos

hi experts,

I need keep an Mail option in my selection screen.when user select the option the output send to mail, by giving eid in selection screen.

4 REPLIES 4

Former Member
0 Kudos

Hi,

You can declare like this..........

SELECT-OPTIONS: s_email FOR t024-smtp_addr NO INTERVALS.

regards,

Ruchika

Reward if useful.

Former Member
0 Kudos

Hi Narayana

Check this sample code

 *&---------------------------------------------------------------------*
*& Report  ZTESTMAIL                                                   *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  ZTESTMAIL                               .

tables: bseg.


parameters: p_email type somlreci1-receiver default
'someone@yahoo.com'.


data: it_message type standard table of solisti1 initial size 0
with header line.
data: it_attach type standard table of solisti1 initial size 0
with header line.

DATA: begin of int_bseg occurs 0,

       zuonr like bseg-zuonr,
     end of int_bseg.

data: t_packing_list like sopcklsti1 occurs 0 with header line,
      t_contents like solisti1 occurs 0 with header line,
      t_receivers like somlreci1 occurs 0 with header line,
      t_attachment like solisti1 occurs 0 with header line,
      t_object_header like solisti1 occurs 0 with header line,

w_cnt type i,
w_sent_all(1) type c,
w_doc_data like sodocchgi1,
gd_error type sy-subrc,
gd_reciever type sy-subrc.


************************************************************************
*START_OF_SELECTION
start-of-selection.
* Retrieve sample data from table ekpo
perform data_retrieval.

* Populate table with detaisl to be entered into .xls file
*perform build_xls_data_table.


************************************************************************
*END-OF-SELECTION
end-of-selection.
* Populate message body text
perform populate_email_message_body.

* Send file by email as .xls speadsheet

perform send_file_as_email_attachment
tables it_message
it_attach
using p_email
'Assignment Date after 2 days'
'XLS'
'filename'
' '
' '
' '
changing gd_error
gd_reciever.

* Instructs mail send program for SAPCONNECT to send email(rsconn01)
perform initiate_mail_execute_program.


*&---------------------------------------------------------------------*
*& Form DATA_RETRIEVAL
*&---------------------------------------------------------------------*
* Retrieve data form EKPO table and populate itab it_ekko
*----------------------------------------------------------------------*
form data_retrieval.



select zuonr from bseg into corresponding  fields of int_bseg.
endselect.

DATA: begin of int_bseg1 occurs 0,

       zuonr1 like bseg-zuonr,
     end of int_bseg1.


loop at int_bseg.

      int_bseg1-zuonr1 = int_bseg-zuonr.


endloop.

endform. " DATA_RETRIEVAL



*&---------------------------------------------------------------------*
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
*&---------------------------------------------------------------------*
* Send email
*----------------------------------------------------------------------*
form send_file_as_email_attachment tables pit_message
pit_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.


data: ld_error type sy-subrc,
ld_reciever type sy-subrc,
ld_mtitle like sodocchgi1-obj_descr,
ld_email like somlreci1-receiver,
ld_format type so_obj_tp ,
ld_attdescription type so_obj_nam ,
ld_attfilename type so_obj_des ,
ld_sender_address like soextreci1-receiver,
ld_sender_address_type like soextreci1-adr_typ,
ld_receiver like sy-subrc.

ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.


* Fill the document data.
w_doc_data-doc_size = 1.



* Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.




** Fill the document data and get size of attachment
clear w_doc_data.
read table it_attach index w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + strlen( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
clear t_attachment.
refresh t_attachment.
t_attachment[] = pit_attach[].

* Describe the body of the message
clear t_packing_list.
refresh t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
describe table it_message lines t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
append t_packing_list.


* Add the recipients email address
clear t_receivers.
refresh t_receivers.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
append t_receivers.

call function 'SO_DOCUMENT_SEND_API1'
exporting
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
importing
sent_to_all = w_sent_all
tables
object_header = t_object_header
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_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.

* Populate zerror return code
ld_error = sy-subrc.

* Populate zreceiver return code
loop at t_receivers.
ld_receiver = t_receivers-retrn_code.
endloop.
endform.



*&---------------------------------------------------------------------*
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
*&---------------------------------------------------------------------*
* Instructs mail send program for SAPCONNECT to send email.
*----------------------------------------------------------------------*

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.                    " INITIATE_MAIL_EXECUTE_PROGRAM



*&---------------------------------------------------------------------*
*& Form POPULATE_EMAIL_MESSAGE_BODY
*&---------------------------------------------------------------------*
* Populate message body text
*----------------------------------------------------------------------*
form populate_email_message_body.
refresh it_message.
it_message = 'Assignment Date is coming After 2 Days Please check doc.'.
append it_message.
endform. " POPULATE_EMAIL_MESSAGE_BODY

Reward all helpfull answers

Regards

Pavan

Former Member
0 Kudos

Hi,

use the following code for send email.

&----


*& form f_sebd_email

&----


  • To send email with attachment

----


FORM f_send_email .

DATA: lv_hex0(1) TYPE c,

lv_hex1(1) TYPE c,

lt_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,

lt_objhead LIKE solisti1 OCCURS 0 WITH HEADER LINE,

lt_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,

lt_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,

lt_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,

lv_doc_chng LIKE sodocchgi1,

lv_tab_lines LIKE sy-tabix,

lv_date(10) TYPE c,

lv_time(10) TYPE c,

lv_po_wtd(10) TYPE c,

lv_po_mtd(10) TYPE c ,

lv_po_ytd(10) TYPE c,

lv_po_l_wtd(10) TYPE c ,

lv_po_l_mtd(10) TYPE c ,

lv_po_l_ytd(10) TYPE c,

lv_pr_wtd(10) TYPE c ,

lv_pr_mtd(10) TYPE c ,

lv_pr_ytd(10) TYPE c ,

lv_pr_l_wtd(10) TYPE c ,

lv_pr_l_mtd(10) TYPE c,

lv_pr_l_ytd(10) TYPE c.

CONSTANTS: lc_rec_typ(1) TYPE c VALUE 'U'.

lv_hex0 = cl_abap_char_utilities=>horizontal_tab.

lv_hex1 = cl_abap_char_utilities=>cr_lf.

  • Creating the document to be sent

lv_doc_chng-obj_name = sy-repid.

lv_doc_chng-obj_descr = sy-repid.

WRITE sy-datum TO lv_date USING EDIT MASK '__/__/____'.

WRITE sy-uzeit TO lv_time USING EDIT MASK '__:__:__'.

CONCATENATE lv_doc_chng-obj_descr gc_under lv_date gc_under lv_time

INTO lv_doc_chng-obj_descr.

*Email body

lt_objtxt = text-019.

APPEND lt_objtxt.

CONCATENATE text-020 lv_date INTO lt_objtxt.

APPEND lt_objtxt.

CONCATENATE text-021 lv_time INTO lt_objtxt.

APPEND lt_objtxt.

DESCRIBE TABLE lt_objtxt LINES lv_tab_lines.

READ TABLE lt_objtxt INDEX lv_tab_lines.

lv_doc_chng-doc_size = ( lv_tab_lines - 1 ) * 255 +

STRLEN( lt_objtxt ).

  • Creating the entry for the compressed document

CLEAR lt_objpack-transf_bin.

lt_objpack-head_start = 1.

lt_objpack-head_num = 0.

lt_objpack-body_start = 1.

lt_objpack-body_num = lv_tab_lines.

lt_objpack-doc_type = 'RAW'.

APPEND lt_objpack.

  • Creating the document attachment

CONCATENATE text-018

text-004 text-005 text-006

text-007 text-008 text-009

text-010 text-011 text-012

text-013 text-014 text-015

text-016 text-017

INTO lt_objbin SEPARATED BY lv_hex0.

CONCATENATE lt_objbin lv_hex1 INTO lt_objbin.

APPEND lt_objbin.

LOOP AT gt_final INTO gw_final.

CLEAR: lv_po_wtd,

lv_po_mtd ,

lv_po_ytd,

lv_po_l_wtd ,

lv_po_l_mtd ,

lv_po_l_ytd,

lv_pr_wtd ,

lv_pr_mtd ,

lv_pr_ytd ,

lv_pr_l_wtd ,

lv_pr_l_mtd,

lv_pr_l_ytd.

lv_po_wtd = gw_final-po_wtd.

lv_po_mtd = gw_final-po_mtd.

lv_po_ytd = gw_final-po_ytd.

lv_po_l_wtd = gw_final-po_l_wtd.

lv_po_l_mtd = gw_final-po_l_mtd.

lv_po_l_ytd = gw_final-po_l_ytd.

lv_pr_wtd = gw_final-pr_wtd.

lv_pr_mtd = gw_final-pr_mtd.

lv_pr_ytd = gw_final-pr_ytd.

lv_pr_l_wtd = gw_final-pr_l_wtd.

lv_pr_l_mtd = gw_final-pr_l_mtd.

lv_pr_l_ytd = gw_final-pr_l_ytd.

CONCATENATE gw_final-ekotx

gw_final-eknam

gw_final-ekgrp

lv_po_wtd

lv_po_mtd

lv_po_ytd

lv_po_l_wtd

lv_po_l_mtd

lv_po_l_ytd

lv_pr_wtd

lv_pr_mtd

lv_pr_ytd

lv_pr_l_wtd

lv_pr_l_mtd

lv_pr_l_ytd

INTO lt_objbin SEPARATED BY lv_hex0.

CONCATENATE lt_objbin lv_hex1 INTO lt_objbin.

APPEND lt_objbin.

ENDLOOP.

DESCRIBE TABLE lt_objbin LINES lv_tab_lines.

lt_objhead = lv_doc_chng-obj_descr.

APPEND lt_objhead.

  • Creating the entry for the compressed attachment

lt_objpack-transf_bin = gc_x.

lt_objpack-head_start = 1.

lt_objpack-head_num = 1.

lt_objpack-body_start = 1.

lt_objpack-body_num = lv_tab_lines.

lt_objpack-doc_type = 'XLS'.

lt_objpack-obj_name = 'ATTACHMENT'.

CONCATENATE sy-repid gc_under lv_date gc_under lv_time INTO

lt_objpack-obj_descr.

lt_objpack-doc_size = lv_tab_lines * 255.

APPEND lt_objpack.

LOOP AT s_email.

lt_reclist-receiver = s_email-low.

lt_reclist-rec_type = lc_rec_typ.

APPEND lt_reclist.

ENDLOOP.

IF sy-subrc = 0.

  • To send email

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = lv_doc_chng

put_in_outbox = gc_x

commit_work = gc_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

operation_no_authorization = 3

OTHERS = 99.

CASE sy-subrc.

WHEN 0.

WRITE: / 'Document sent successfully'.

WHEN 1.

WRITE: / 'Document could not be sent. Too many receivers'.

WHEN 2.

WRITE: / 'Document could not be sent to any of the recipients!'.

WHEN 3.

WRITE: / 'No authorization to send/create document!'.

WHEN OTHERS.

WRITE: / 'Error occurred during sending!'.

ENDCASE.

ENDIF.

ENDFORM. "f_send_email

regards,

Ruchika

Reward if useful...........

Former Member
0 Kudos

hi

good

go throgh the links

http://www.cdg-inc.com/news/WhitePaper_ALV_Reporting_Power.htm

REPORT ZTESTMAIL .

tables: ekko.

parameters: p_email type somlreci1-receiver default

'praveen.srrec@gmail.com'.

types: begin of t_ekpo,

ebeln type ekpo-ebeln,

ebelp type ekpo-ebelp,

aedat type ekpo-aedat,

matnr type ekpo-matnr,

end of t_ekpo.

data: it_ekpo type standard table of t_ekpo initial size 0,

wa_ekpo type t_ekpo.

types: begin of t_charekpo,

ebeln(10) type c,

ebelp(5) type c,

aedat(8) type c,

matnr(18) type c,

end of t_charekpo.

data: wa_charekpo type t_charekpo.

data: it_message type standard table of solisti1 initial size 0

with header line.

data: it_attach type standard table of solisti1 initial size 0

with header line.

data: t_packing_list like sopcklsti1 occurs 0 with header line,

t_contents like solisti1 occurs 0 with header line,

t_receivers like somlreci1 occurs 0 with header line,

t_attachment like solisti1 occurs 0 with header line,

t_object_header like solisti1 occurs 0 with header line,

w_cnt type i,

w_sent_all(1) type c,

w_doc_data like sodocchgi1,

gd_error type sy-subrc,

gd_reciever type sy-subrc.

t_object_header = 'Text.xls'. append t_object_header.

************************************************************************

*START_OF_SELECTION

start-of-selection.

  • Retrieve sample data from table ekpo

perform data_retrieval.

  • Populate table with detaisl to be entered into .xls file

perform build_xls_data_table.

************************************************************************

*END-OF-SELECTION

end-of-selection.

  • Populate message body text

perform populate_email_message_body.

  • Send file by email as .xls speadsheet

perform send_file_as_email_attachment

tables it_message

it_attach

using p_email

'Example .xls documnet attachment'

'XLS'

'filename'

' '

' '

' '

changing gd_error

gd_reciever.

  • Instructs mail send program for SAPCONNECT to send email(rsconn01)

perform initiate_mail_execute_program.

&----


*& Form DATA_RETRIEVAL

&----


  • Retrieve data form EKPO table and populate itab it_ekko

----


form data_retrieval.

select ebeln ebelp aedat matnr

up to 10 rows

from ekpo

into table it_ekpo.

endform. " DATA_RETRIEVAL

&----


*& Form BUILD_XLS_DATA_TABLE

&----


  • Build data table for .xls document

----


form build_xls_data_table.

*CONSTANTS: con_cret TYPE x VALUE '0D', "OK for non Unicode

*con_tab TYPE x VALUE '09'. "OK for non Unicode

*If you have Unicode check active in program attributes thnen you will

*need to declare constants as follows

*class cl_abap_char_utilities definition load.

constants:

con_tab type c value cl_abap_char_utilities=>horizontal_tab,

con_cret type c value cl_abap_char_utilities=>cr_lf.

concatenate 'EBELN' 'EBELP' 'AEDAT' 'MATNR'

into it_attach separated by con_tab.

concatenate con_cret it_attach into it_attach.

append it_attach.

loop at it_ekpo into wa_charekpo.

concatenate wa_charekpo-ebeln wa_charekpo-ebelp

wa_charekpo-aedat wa_charekpo-matnr

into it_attach separated by con_tab.

concatenate con_cret it_attach into it_attach.

append it_attach.

endloop.

endform. " BUILD_XLS_DATA_TABLE

&----


*& Form SEND_FILE_AS_EMAIL_ATTACHMENT

&----


  • Send email

----


form send_file_as_email_attachment tables pit_message

pit_attach

using p_email

p_mtitle

p_format

p_filename

p_attdescription

p_sender_address

p_sender_addres_type

changing p_error

p_reciever.

data: ld_error type sy-subrc,

ld_reciever type sy-subrc,

ld_mtitle like sodocchgi1-obj_descr,

ld_email like somlreci1-receiver,

ld_format type so_obj_tp ,

ld_attdescription type so_obj_nam ,

ld_attfilename type so_obj_des ,

ld_sender_address like soextreci1-receiver,

ld_sender_address_type like soextreci1-adr_typ,

ld_receiver like sy-subrc.

ld_email = p_email.

ld_mtitle = p_mtitle.

ld_format = p_format.

ld_attdescription = p_attdescription.

ld_attfilename = p_filename.

ld_sender_address = p_sender_address.

ld_sender_address_type = p_sender_addres_type.

  • Fill the document data.

w_doc_data-doc_size = 1.

  • Populate the subject/generic message attributes

w_doc_data-obj_langu = sy-langu.

w_doc_data-obj_name = 'SAPRPT'.

w_doc_data-obj_descr = ld_mtitle .

w_doc_data-sensitivty = 'F'.

  • Fill the document data and get size of attachment

clear w_doc_data.

read table it_attach index w_cnt.

w_doc_data-doc_size =

( w_cnt - 1 ) * 255 + strlen( it_attach ).

w_doc_data-obj_langu = sy-langu.

w_doc_data-obj_name = 'SAPRPT'.

w_doc_data-obj_descr = ld_mtitle.

w_doc_data-sensitivty = 'F'.

clear t_attachment.

refresh t_attachment.

t_attachment[] = pit_attach[].

  • Describe the body of the message

clear t_packing_list.

refresh t_packing_list.

t_packing_list-transf_bin = space.

t_packing_list-head_start = 1.

t_packing_list-head_num = 0.

t_packing_list-body_start = 1.

describe table it_message lines t_packing_list-body_num.

t_packing_list-doc_type = 'RAW'.

append t_packing_list.

  • Create attachment notification

t_packing_list-transf_bin = 'X'.

t_packing_list-head_start = 1.

t_packing_list-head_num = 1.

t_packing_list-body_start = 1.

describe table t_attachment lines t_packing_list-body_num.

t_packing_list-doc_type = ld_format.

t_packing_list-obj_descr = ld_attdescription.

t_packing_list-obj_name = ld_attfilename.

t_packing_list-doc_size = t_packing_list-body_num * 255.

append t_packing_list.

  • Add the recipients email address

clear t_receivers.

refresh t_receivers.

t_receivers-receiver = ld_email.

t_receivers-rec_type = 'U'.

t_receivers-com_type = 'INT'.

t_receivers-notif_del = 'X'.

t_receivers-notif_ndel = 'X'.

append t_receivers.

call function 'SO_DOCUMENT_SEND_API1'

exporting

document_data = w_doc_data

put_in_outbox = 'X'

sender_address = ld_sender_address

sender_address_type = ld_sender_address_type

commit_work = 'X'

importing

sent_to_all = w_sent_all

tables

object_header = t_object_header

packing_list = t_packing_list

contents_bin = t_attachment

contents_txt = it_message

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

  • Populate zerror return code

ld_error = sy-subrc.

  • Populate zreceiver return code

loop at t_receivers.

ld_receiver = t_receivers-retrn_code.

endloop.

endform.

&----


*& Form INITIATE_MAIL_EXECUTE_PROGRAM

&----


  • Instructs mail send program for SAPCONNECT to send email.

----


form initiate_mail_execute_program.

wait up to 2 seconds.

submit rsconn01 with mode = 'INT'

with output = 'X'

and return.

endform. " INITIATE_MAIL_EXECUTE_PROGRAM

&----


*& Form POPULATE_EMAIL_MESSAGE_BODY

&----


  • Populate message body text

----


form populate_email_message_body.

refresh it_message.

it_message = 'Please find attached a list test ekpo records'.

append it_message.

endform. " POPULATE_EMAIL_MESSAGE_BODY

*PARAMETERS: psubject(40) type c default 'Testing',

*p_email(40) type c default 'praveen.srrec@gmail.com'. "use ur email id

*

*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.

*START-OF-SELECTION.

*

*Perform populate_message_table.

*

**Send email message, although is not sent from SAP until mail send

**program has been executed(rsconn01)

*PERFORM send_email_message.

*

**Instructs mail send program for SAPCONNECT to send email(rsconn01)

*perform initiate_mail_execute_program.

*

*

**&----


**

**& Form POPULATE_MESSAGE_TABLE

**&----


**

    • Adds text to email text table

**----


**

*form populate_message_table.

*Append 'Line1' to it_message.

*Append 'Line2' to it_message.

*Append 'Line3' to it_message.

*Append 'Test- 1' to it_message.

*endform. " POPULATE_MESSAGE_TABLE

*

*

**&----


**

**& Form SEND_EMAIL_MESSAGE

**&----


**

    • Send email message

**----


**

*form send_email_message.

    • Fill the document data.

*gd_doc_data-doc_size = 1.

    • DATA: TAB_LINES LIKE sy-tabix.

**

    • DESCRIBE TABLE it_message LINES TAB_LINES.

    • READ TABLE it_message INDEX TAB_LINES.

    • gd_doc_data-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( it_message )

**.

*

    • Populate the subject/generic message attributes

*gd_doc_data-obj_langu = sy-langu.

*gd_doc_data-obj_name = 'SAPRPT'.

*gd_doc_data-obj_descr = psubject.

*gd_doc_data-sensitivty = 'F'.

*

    • Describe the body of the message

    • Information about structure of data tables

*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.

*

    • Add the recipients email address

*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 the FM to post the message to SAPMAIL

*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.

*

    • Store function module return code

*gd_error = sy-subrc.

*

    • Get it_receivers return code

*loop at it_receivers.

*endloop.

*endform. " SEND_EMAIL_MESSAGE

*

*

**&----


**& Form INITIATE_MAIL_EXECUTE_PROGRAM

**&----


    • Instructs mail send program for SAPCONNECT to send email.

**----


*

*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. " INITIATE_MAIL_EXECUTE_PROGRAM

thanks

mrutyun^