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: 

Is it possible to send ABAP classical report as a Email Out put

Hari_Krishana
Explorer
0 Kudos

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

6 REPLIES 6

vinoth_aruldass
Contributor
0 Kudos

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.

0 Kudos

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

Sijin_Chandran
Active Contributor
0 Kudos

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 .

Former Member
0 Kudos

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.

  •   Transfer the 132-long strings to 255-long strings

  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                                            *

---- 

FORM process_email.

  DESCRIBE TABLE it_mess_att LINES gd_recsize.

  CHECK gd_recsize > 0.

  PERFORM send_email USING p_email1.

  •   perform send_email using p_email2.

ENDFORM.

---- 

  •         FORM send_email                                               *

---- 

  •   -->  p_email                                                       *

---- 

FORM send_email USING p_email.

  CHECK NOT ( p_email IS INITIAL ).

  REFRESH it_mess_bod.

  •   Default subject matter

  gd_subject         = 'Subject'.

  gd_attachment_desc = 'Attachname'.

  •   CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.

  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 no sender specified - default blank

  IF p_sender EQ space.

    gd_sender_type  = space.

  ELSE.

    gd_sender_type  = 'INT'.

  ENDIF.

  •   Send file by email as .xls speadsheet

  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.


 


 


 


 


former_member491621
Contributor
0 Kudos

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

http://scn.sap.com/thread/861202

https://scn.sap.com/thread/216167

former_member189849
Contributor
0 Kudos

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