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: 

how to send ABAP report output list through e-mail

former_member953603
Participant
0 Kudos

HI EXPERTS,

how to send output list(after execution) of ABAP report through e-mail???

Regards:

balakrishna.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

Use the Function Module

" SO_NEW_DOCUMENT_ATT_SEND_API1 " for this purpose

8 REPLIES 8

Former Member
0 Kudos

Hi,

Please refer to the link below:

http://www.sapdev.co.uk/reporting/email/emailhome.htm

Thanks,

Sriram POnna.

Former Member
0 Kudos

Hi

Use the Function Module

" SO_NEW_DOCUMENT_ATT_SEND_API1 " for this purpose

Former Member
0 Kudos

Hi,

Please check below link.

http://www.sapdev.co.uk/reporting/rep_spooltopdf2.htm

Regards,

Kishore

Former Member
0 Kudos

hi

good

First configure the settings required for sending mail in SCOT Tcode and for sending FAX.

Use the fun modules

SO_NEW_DOCUMENT_ATT_SEND_API1 for sending mail.

see the sample code:

Mailing with Attachment by ABAP Coding

Refer this link:

FORM send_list_to_basis .

DATA: w_path LIKE rlgrap OCCURS 0 WITH HEADER LINE,

lt_index TYPE sy-tabix,

doc_type(3) TYPE c,

descr LIKE it_objpack_basis-obj_descr,

temp_data LIKE w_path,

temp1 TYPE string,

tab_lines TYPE i,

langu(15) TYPE c,

expirydate TYPE so_obj_edt,

L_FILE1(100).

CONCATENATE 'C:\' sy-repid '_' sy-datum '.XLS' INTO L_FILE1.

W_PATH-FILENAME = L_FILE1.

APPEND w_path.

CLEAR w_path.

wa_doc_chng-obj_descr = 'User List not logged on for 180 days'.

wa_doc_chng-obj_langu = 'E'.

wa_doc_chng-obj_expdat = sy-datum.

CLEAR w_subject.

CONCATENATE 'Please find attached document with list of users'

'not logged on for 180 days for client' sy-mandt

INTO w_subject SEPARATED BY space.

it_objtxt_basis-line = w_subject.

APPEND it_objtxt_basis.

CLEAR it_objtxt_basis.

it_objtxt_basis-line = text-004.

APPEND it_objtxt_basis.

CLEAR it_objtxt_basis.

CLEAR w_tab_line.

DESCRIBE TABLE it_objtxt_basis LINES w_tab_line.

READ TABLE it_objtxt_basis INDEX w_tab_line INTO l_cline.

wa_doc_chng-doc_size =

( w_tab_line - 1 ) * 255 + STRLEN( l_cline ).

CLEAR it_objpack_basis-transf_bin.

it_objpack_basis-head_start = 1.

it_objpack_basis-head_num = 0.

it_objpack_basis-body_start = 1.

it_objpack_basis-body_num = w_tab_line.

it_objpack_basis-doc_type = 'RAW'.

APPEND it_objpack_basis.

CLEAR it_objpack_basis.

LOOP AT w_path.

temp1 = w_path.

descr = w_path.

CALL FUNCTION 'STRING_REVERSE'

EXPORTING

string = descr

lang = 'E'

IMPORTING

rstring = descr.

CALL FUNCTION 'STRING_SPLIT'

EXPORTING

delimiter = '\'

string = descr

IMPORTING

head = descr

tail = temp_data.

CALL FUNCTION 'STRING_REVERSE'

EXPORTING

string = descr

lang = 'E'

IMPORTING

rstring = descr.

CALL FUNCTION 'STRING_SPLIT'

EXPORTING

delimiter = '.'

string = descr

IMPORTING

head = temp_data

tail = doc_type.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = temp1

filetype = 'BIN'

header_length = 0

read_by_line = 'X'

replacement = '#'

TABLES

data_tab = it_upload.

DESCRIBE TABLE it_upload LINES tab_lines.

DESCRIBE TABLE it_objbin_basis LINES lt_index.

lt_index = lt_index + 1.

LOOP AT it_upload.

wa_objbin_basis-line = it_upload-line.

APPEND wa_objbin_basis TO it_objbin_basis.

CLEAR wa_objbin_basis.

ENDLOOP.

it_objpack_basis-transf_bin = 'X'.

it_objpack_basis-head_start = 0.

it_objpack_basis-head_num = 0.

it_objpack_basis-body_start = lt_index.

it_objpack_basis-body_num = tab_lines.

it_objpack_basis-doc_type = doc_type.

it_objpack_basis-obj_descr = descr.

it_objpack_basis-doc_size = tab_lines * 255.

APPEND it_objpack_basis.

CLEAR it_objpack_basis.

ENDLOOP.

it_reclist_basis-receiver = 'XXX@.com'.

it_reclist_basis-rec_type = 'U'.

APPEND it_reclist_basis.

CLEAR it_reclist_basis.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = wa_doc_chng

put_in_outbox = 'X'

commit_work = 'X'

TABLES

packing_list = it_objpack_basis

contents_txt = it_objtxt_basis

contents_bin = it_objbin_basis

receivers = it_reclist_basis

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

operation_no_authorization = 4

OTHERS = 99.

IF sy-subrc EQ 0.

SUBMIT rsconn01 WITH mode = 'INT' AND RETURN.

ENDIF.

ENDFORM. " send_list_to_basis

thanks

mrutyun^

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Here is a simple example program.



report zrich_0003 .

data: maildata like sodocchgi1.
data: mailtxt like solisti1 occurs 10 with header line.
data: mailrec like somlrec90 occurs 0 with header line.
data: list type table of abaplist with header line.
data: ascilines(1024) type c occurs 0 with header line.
data: htmllines type table of w3html with header line.

start-of-selection.

  submit <zreport> exporting list to memory and return.

  call function 'LIST_FROM_MEMORY'
       tables
            listobject = list
       exceptions
            not_found  = 1
            others     = 2.

  call function 'LIST_TO_ASCI'
       tables
            listobject         = list
            listasci           = ascilines
       exceptions
            empty_list         = 1
            list_index_invalid = 2
            others             = 3.

  call function 'WWW_HTML_FROM_LISTOBJECT'
       tables
            html       = htmllines
            listobject = list.

  clear: maildata, mailtxt, mailrec.
  refresh: mailtxt, mailrec.

  maildata-obj_name = 'TEST'.
  maildata-obj_descr = 'Test Subject'.

  loop at htmllines.
    mailtxt = htmllines.
    append mailtxt.
  endloop.

  mailrec-receiver = 'you@yourcompany'.
  mailrec-rec_type = 'U'.
  append mailrec.

  call function 'SO_NEW_DOCUMENT_SEND_API1'
       exporting
            document_data              = maildata
            document_type              = 'HTM'
            put_in_outbox              = 'X'
       tables
            object_header              = mailtxt
            object_content             = mailtxt
            receivers                  = 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.

* This will trigger the send process in SAPconnent
*  submit rsconn01 with mode = 'INT'
*               with output = 'X'
*                          and return.

Regards,

RIch Heilman

0 Kudos

I have a similiar issue. In the program code, the foll. is given:

    SUBMIT RSCONN01 WITH MODE   = 'INT'

                    WITH OUTPUT = 'X'

                    AND RETURN.

This causes all the objects in SOST to be released. I want only my objects to be released.

how do I use RSCONN01 selectively ?

please clarify.

Former Member
0 Kudos

I have a similiar issue. In the program code, the foll. is given:

    SUBMIT RSCONN01 WITH MODE   = 'INT'

                    WITH OUTPUT = 'X'

                    AND RETURN.

This causes all the objects in SOST to be released. I want only my objects to be released.

how do I use RSCONN01 selectively ?

please clarify.

Former Member
0 Kudos

Hello everybody, I will show you also a similar code sample, to send e-mail through a ABAP Report

REPORT  ZRR_MAIL.
DATA:it_receivers    TYPE STANDARD TABLE OF  somlreci1,
     ls_recievers
LIKE LINE OF it_receivers,
     it_packing_list
TYPE STANDARD TABLE OF  sopcklsti1,
     l_document    
TYPE sodocchgi1,
     ls_packing_list
LIKE LINE OF  it_packing_list,
     l_subject
(90)       TYPE c,
     it_message        
TYPE STANDARD TABLE OF solisti1,
     ls_message     
LIKE LINE OF it_message,
     c1
(99)    TYPE c,
     c2
(15)    TYPE c,
     l_lines
TYPE i.
SELECTION-SCREEN begin of block Enter WITH FRAME TITLE titlu.PARAMETERS : email TYPE so_recname DEFAULT 'Enter here the e-mail adress',
             adr
TYPE SO_TEXT255 DEFAULT 'Dear Andreea,'.SELECTION-SCREEN end of block Enter.
AT SELECTION-SCREEN.
* Begin of - Add recieverFREE ls_recievers.
ls_recievers
-receiver   = email. " Email id
IF email CS '@'.
  ls_recievers
-rec_type   = 'U'.                    "External Email id
  ls_recievers
-com_type   = 'INT'.ELSE.
 
EXIT. " temporary we will not send an internal e-mail. comment this line to allow this.
  ls_recievers
-rec_type   = 'B'.              "Send to intern Email idENDIF.

ls_recievers
-notif_del  = 'X'.
ls_recievers
-notif_ndel = 'X'.APPEND ls_recievers TO it_receivers .
FREE ls_recievers.*END of - ADD Reciever
DESCRIBE TABLE it_receivers LINES l_lines.CHECK l_lines > 0. "do we have any recievers?
* Add the text to mail text table

  l_subject
= 'Send Mail from ABAP Program.'(001).*&--  Body  of the mail ----------------&*
 
CLEAR ls_message.
*Salutation and text

  ls_message
-line = adr.
 
APPEND ls_message TO it_message.

 
CLEAR ls_message.
  ls_message
-line = '                               '.
 
APPEND ls_message TO it_message.
*Begin of text

 
CLEAR ls_message.
  ls_message
-line = 'I love SAP :))'(002).
 
APPEND ls_message TO it_message.

 
CLEAR ls_message.
  ls_message
-line = '                                        '.
 
APPEND ls_message TO it_message.

 
CLEAR ls_message.
  ls_message
-line = 'Cu drag,'.
 
APPEND ls_message TO it_message.

   
CLEAR ls_message.
  ls_message
-line = sy-uname.
 
APPEND ls_message TO it_message.
* End of Text



**********& Send EMAIL MESSAGE  &*********************************
  l_document
-doc_size = 1.*Populate the subject/generic message attributes
  l_document
-obj_langu = sy-langu.
  l_document
-obj_name = 'SAPRPT'.
  l_document
-obj_descr = l_subject.
  l_document
-sensitivty = 'F'.*Describe the body of the message

 
CLEAR ls_packing_list.

 
REFRESH it_packing_list.
  ls_packing_list
-transf_bin = space.
  ls_packing_list
-head_start = 1.
  ls_packing_list
-head_num = 0.
  ls_packing_list
-body_start = 1.

 
DESCRIBE TABLE it_message LINES ls_packing_list-body_num.

  ls_packing_list
-doc_type = 'RAW'.

 
APPEND ls_packing_list TO it_packing_list.
*&------ Call the Function Module to send the message to External and SAP Inbox
 
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
   
EXPORTING
      document_data             
= l_document
      put_in_outbox             
= 'X'
      commit_work               
= 'X'
   
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.
 
else.
   
MESSAGE 'E-mail sent!' TYPE 'I'.
 
ENDIF.