01-18-2013 8:02 AM
Hi Experts I have a ABAP classical report would it be possible to send an email with the Out put to the users?? if so can you please help me with the sample code
Moderator Message: Please search for the available information before posting. This is FAQ
Refer:SAP Community Network Wiki - ABAP Development - Sending Mails - Home Page, Check the section SPOOL.
Message was edited by: Kesavadas Thekkillath
01-18-2013 8:22 AM
hi,
yes it is possible . convert the output spool to pdf and send it as an attachment.
there are many documents available please google for the information.
hope it helps,
Vinoth.
01-18-2013 8:36 AM
Hi,
Not sure why do you say it has to be taken from spool and converted to PDF?
I would suggest look at class CL_BCS and its relevant documentation, very much available on SCN.
This class can be used to send mails with attachment. Thanks!
Regards,
Kumud
01-18-2013 8:22 AM
Hi Hari ,
Try with SUBMIT command.
Call your report using SUMBIT and EXPORTING LIST addition.
You may get required data in EXPORTED LIST contents.
This may work not sure though .
01-18-2013 8:34 AM
Hi
Create the spool and using this u can send the output to an email
FORM convert_spool_to_pdf.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
OTHERS = 12.
CHECK sy-subrc = 0.
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
it_mess_att = gd_buffer.
APPEND it_mess_att.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDFORM.
----
----
FORM process_email.
DESCRIBE TABLE it_mess_att LINES gd_recsize.
CHECK gd_recsize > 0.
PERFORM send_email USING p_email1.
ENDFORM.
----
----
----
FORM send_email USING p_email.
CHECK NOT ( p_email IS INITIAL ).
REFRESH it_mess_bod.
gd_subject = 'Subject'.
gd_attachment_desc = 'Attachname'.
it_mess_bod = 'Message Body text, line 1'.
APPEND it_mess_bod.
it_mess_bod = 'Message Body text, line 2...'.
APPEND it_mess_bod.
IF p_sender EQ space.
gd_sender_type = space.
ELSE.
gd_sender_type = 'INT'.
ENDIF.
PERFORM send_file_as_email_attachment
tables it_mess_bod
it_mess_att
using p_email
'Example .xls documnet attachment'
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
changing gd_error
gd_reciever.
ENDFORM.
01-18-2013 8:34 AM
Hi Hari,
Yes you can send the report output as mail attachment.
You have to send the output to spool, then convert the spool output to PDF and then send the PDF as mail attachment.
For sending the output to spool you can use NEW-PAGE PRINT ON. see the link below
http://help.sap.com/abapdocu_70/en/ABAPNEW-PAGE_PRINT.htm
For converting the spool output to pdf
http://help.sap.com/saphelp_nw04/helpdata/en/85/54c73cee4fb55be10000000a114084/content.htm
https://scn.sap.com/thread/1339865
For sending email you can search for FM 'SO_DOCUMENT_SEND_API1' . Also,see the links
01-18-2013 8:38 AM
Agree with "Vinoth" and that is the normal procedure and for more info see the belo link
http://wiki.sdn.sap.com/wiki/display/Community/Send+Email+of+output+as+PDF.
Regards
Mahesh