Search on this Website

Saturday, October 6, 2007

Example of Sending XLS file as a mail via SAPCONNECT

&---------------------------------------------------------------------*

*& Report ZEMAIL_ATTACH *

*&---------------------------------------------------------------------*

*& Example of sending external email via SAPCONNECT *

*&---------------------------------------------------------------------*

REPORT ZEMAIL_ATTACH .

TABLES: ekko.



PARAMETERS: p_email TYPE somlreci1-receiver

DEFAULT 'test@sapdev.co.uk'.


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.



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

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



See Complete Code :: Click here

No comments: