cancel
Showing results for 
Search instead for 
Did you mean: 

Send Email Attaching the Report generated in Program.

Former Member
0 Kudos

Hi All,

I am generating a report in list format with write statements.

My requirement is to send an email attaching this report as an attachment.

I wanted to know how to get the listobject of the report generated by my program from the memory. Can anyone guide me with this ?

It will be appreciable , If any one can give me more information on sending mails attaching the reports generated by the program.

Thanks in advance,

Mayank

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You can use the following part of code,

submit ztest exporting list to memory and return.

  • and read list from memory into table

call function 'LIST_FROM_MEMORY'

tables

listobject = listobject

exceptions

others = 1.

if sy-subrc <> 0.

message id '61' type 'E' number '731'

with 'LIST_FROM_MEMORY'.

endif.

First submit the report output to the memory and then read it in the table.

Now compress the output in the table

call function 'TABLE_COMPRESS'

tables

in = listobject

out = objbin

exceptions

others = 1.

if sy-subrc <> 0.

message id '61' type 'E' number '731'

with 'TABLE_COMPRESS'.

endif.

Now you can use the following FM to send the data as an attachment to any user.

SO_NEW_DOCUMENT_ATT_SEND_API1

Hopw this will solve ur problem

Amit

Former Member
0 Kudos

Hi

I tried the solution given,

Submitting the same program which we are executing for exporting its list in to memory. And on the next line trying to read it with the function module 'LIST_FROM_MEMORY'.

First of all we cannot submit the same program for exporting its own list to memory.

Please send me the way to export the same programs list to memory for calling it ahead in the same program.

So that i can use the list generated by the program to use it as attachment in the mail Which I want to send.

Thanks

Mayank

Former Member
0 Kudos

Hi,

below links may help you.

/people/thomas.jung3/blog/2004/09/07/sending-e-mail-from-abap--version-46d-and-lower--api-interface

and

/people/thomas.jung3/blog/2004/09/08/sending-e-mail-from-abap--version-610-and-higher--bcs-interface

reward points for helpfull answers.

regards,

venu

ramki_maley
Active Contributor
0 Kudos

Mayank,

Here is an example code for you.

REPORT  zramki_submit_self                      .

PARAMETERS:
 p_date LIKE sy-datum DEFAULT sy-datum,
 p_submit NO-DISPLAY.

IF p_submit IS INITIAL.
  SUBMIT (sy-repid) WITH p_date   = p_date
                    WITH p_submit = 'X'
               EXPORTING LIST TO MEMORY AND RETURN.
<b>*** Process the list here and send the mail</b> 
ELSE.
<b>*** Generate the report here.</b>
  do 5 times.  
    WRITE: /1 sy-index, sy-datum.
  enddo.
  EXIT.
ENDIF.

Cheers,

Ramki Maley.

Please reward points if the answer is helpful.

For info on awarding points click on this link: https://www.sdn.sap.com/sdn/index.sdn?page=crp_help.htm

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Har,

below links might help you.

http://www.geocities.com/mpioud/Z_EMAIL_ABAP_REPORT.html

http://www.thespot4sap.com/Articles/SAP_Mail_SO_Object_Send.asp

reward points for helpfull answers and close the thread if your question is solved.

regards,

venu.

Former Member
0 Kudos

Hi,

I found that you need the contents of the nternal table

iusr02.I would suggest you to copy the program into a

custom program and modify it to export the internal

table <b>iusr02</b> this to Memory.

Then from the program where you are calling this

program import the internal table this from memory.

Then you can mail this internal table from SAP.

Please reward points if you find this explanation

useful.

Regards,

Siva

Former Member
0 Kudos

hi,

try this function module

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = document_data

put_in_outbox = c_x

TABLES

packing_list = packing_list

object_header = object_header

contents_txt = t_idisp2

receivers = receivers

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

operation_no_authorization = 4

OTHERS = 99.

Former Member
0 Kudos

Hi,

I think the problem is not clear.

My problem is to get the listobject name which got generated after the program run.I want to attach this list report to the email. I have seen a code from one of the link.

Here it is.

  • List of Users According to Logon Date and Password Change

  • NOTE: Create ALI/OTF Document in Spool

SUBMIT rsusr200 WITH valid = 'X'

WITH notvalid = space

WITH unlocked = 'X'

WITH locked = space

EXPORTING LIST TO MEMORY AND RETURN.

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

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

Here the report is sumitted with the option of exporting the list in to the memory which is later read using 'LIST_FROM_MEMORY'.

But here i need the same report's output to be captured and want to read the list generated from memory into table.

How can i get the listobject of the list generated by the report in the same report program itself ??

Please let me know.

Mayank

Former Member
0 Kudos
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

will help you

Kind regards

Matthias Kabel

andreas_mann3
Active Contributor
0 Kudos

Hi,

try:

1) read report sy-repid into objbin

2)

fm SO_DOCUMENT_SEND_API1
... 
       TABLES
          DATA_TAB = objbin.

Andreas