Tuesday, December 6, 2016

Report Output via Email

In the following program we are sending the report output via email. To achieve this we are using a standard Function Module - EFG_GEN_SEND_EMAIL

REPORT zsr_test NO STANDARD PAGE HEADING.

TABLESekko.
TYPES:
  BEGIN OF ty_ekko,
    ebeln TYPE ekko-ebeln,
  END OF ty_ekko.

DATA:
  wa_ekko       TYPE ty_ekko,
  it_ekko       TYPE TABLE OF ty_ekko,
  lv_date       TYPE sy-datum,
  date_external TYPE char12,

  i_title       TYPE char100,
  i_recipient   TYPE char50.

START-OF-SELECTION.
  PERFORM fetch_data.
  PERFORM convert_date.
  PERFORM send_email.

*&---------------------------------------------------------------------*
*&      Form  FETCH_DATA
*&---------------------------------------------------------------------*
*       Fetch data of PO from EKKO
*----------------------------------------------------------------------*
FORM fetch_data .

  CLEAR lv_date.
  lv_date sy-datum 30.

  SELECT ebeln FROM ekko
    INTO TABLE it_ekko
    WHERE aedat GT lv_date.

  IF sy-subrc 0.
    SORT it_ekko.
  ENDIF.

ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  CONVERT_DATE
*&---------------------------------------------------------------------*
*       Convert date to External format
*----------------------------------------------------------------------*
FORM convert_date .

  CLEAR lv_date.
  CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
    EXPORTING
      date_internal            sy-datum
    IMPORTING
      date_external            date_external
    EXCEPTIONS
      date_internal_is_invalid 1
      OTHERS                        2.

ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  SEND_EMAIL
*&---------------------------------------------------------------------*
*       Sending mail
*----------------------------------------------------------------------*
FORM send_email .

  IF it_ekko IS NOT INITIAL.

    CONCATENATE 'Purchase Order List on : '
                date_external
    INTO i_title SEPARATED BY ' '.
    i_recipient 'sandip.aim@gmail.com'.

    CALL FUNCTION 'EFG_GEN_SEND_EMAIL'
      EXPORTING
        i_title                i_title
        i_sender               sy-uname
        i_recipient            i_recipient
        i_flg_commit           'X'
        i_flg_send_immediately 'X'
      TABLES
        i_tab_lines            it_ekko
*       I_TAB_RECIPIENTS       =
      EXCEPTIONS
        not_qualified          1
        failed                 2
        OTHERS                 3.
  ENDIF.

ENDFORM.


In this example the output is sent to only one email ID. We can use multiple email IDs by passing a table I_TAB_RECIPIENTS. We can maintain a custom table which contains mail IDs. The email will come as follows.




17 comments:

Rahul Gupta said...

Nice Program

sap videos said...

Thanks for the great information in your blog on. It was so nice Program Thank you for valuable informationsap video tutorials

sap videos said...


Thanks for Sharing this Information.You are providing very valuable information sap video tutorials

Shalini said...

Hi, This is shalini from Chennai learned SAP Training in Chennai from mr.karthick. The training really was good and i got selected in leading mnc company as SAP Consultant.

You can contact 8122241286 for Best SAP Training in Chennai or reach www.thecreatingexperts.com

sap videos said...


Fabulous..!!! The information you Provided is much useful sap video tutorials

Shalini said...

Hi, This is shalini from Chennai learned SAP Training in Chennai from mr.karthick. The training really was good and i got selected in leading mnc company as SAP Consultant.

You can contact 8122241286 for Best SAP Training in Chennai or reach www.thecreatingexperts.com

RS Trainings said...

thank you for sharing such a unique content.please provide latest updates .one of the recommanded blog

SAP ABAP Online training

SAP ABAP Online training in hyderabad
SAP ABAP Online training in usa

Video Tutorials said...


Well it Was Very Good Information. Thanks for sharing this Informationsap video tutorials

sanayamohit said...

SAP Success Factors Real Time Hands on Training in Chennai...

Don't always Depend on Training Institute Alone and so please aware of Best Trainers too..

http://thecreatingexperts.com/sap-successfactors-training-in-chennai/

If You need a Best Trainer over SAP Success Factors Means??? Please ready for an DEMO From the Trainer MR.Karthick
CONTACT:8122241286

Both Classroom/Online Training is Available!!!!!!

sushma said...

SAP Success Factors Real Time Hands on Training in Chennai…

Don’t always Depend on Training Institute alone.Please aware of Best Trainers too..

http://thecreatingexperts.com/sap-successfactors-training-in-chennai/

If You need a Best Trainer in SAP Success Factors??? Then be ready for a DEMO From the Trainer MR.Karthick
CONTACT:8122241286
http://thecreatingexperts.com/sap-mm-training-in-chennai/

Both Classroom/Online Training is Available!!!!!!

Unknown said...

SAP Success Factors Real Time Hands on Training in Chennai…

Don’t always Depend on Training Institute alone.Please aware of Best Trainers too..

http://thecreatingexperts.com/sap-successfactors-training-in-chennai/

If You need a Best Trainer in SAP Success Factors??? Then be ready for a DEMO From the Trainer MR.Karthick
CONTACT:8122241286
http://thecreatingexperts.com/sap-mm-training-in-chennai/

Both Classroom/Online Training is Available!!!!!!

Unknown said...

Best SAP Success Factors Training Institute in Chennai
Best SAP MM Training Institute in Chennai
Best SAP SD Training Institute in Chennai
Best SAP ABAP Training Institute in Chennai
Best SAP FICO Training Institute in Chennai
Best SAP BASIS Training Institute in Chennai

http://thecreatingexperts.com/sap-successfactors-training-in-chennai/

If You need a Best Trainer in SAP Success Factors??? Then be ready for a DEMO From the Trainer MR.Karthick
CONTACT:8122241286
http://thecreatingexperts.com/sap-mm-training-in-chennai/

Both Classroom/Online Training is Available!!!!!!

sanayamohit said...

Best SAP Success Factor Training in Chennai

http://thecreatingexperts.com/sap-training-in-chennai/
http://thecreatingexperts.com/sap-successfactors-training-in-chennai/
http://thecreatingexperts.com/sap-mm-training-in-chennai/
http://thecreatingexperts.com/sap-fico-training-in-chennai/

simashree said...

SAP Success Factors Real Time Hands on Training in Chennai…

Don’t always Depend on Training Institute alone.Please aware of Best Trainers too..

http://thecreatingexperts.com/sap-successfactors-training-in-chennai/

If You need a Best Trainer in SAP Success Factors??? Then be ready for a DEMO From the Trainer MR.Karthick
CONTACT:8122241286
http://thecreatingexperts.com/sap-mm-training-in-chennai/

Both Classroom/Online Training is Available!!!!!!

Priyasekar said...

Thanks for your info...Here THE CREATING EXPERTS provide hands on training with real time scenarios

http://thecreatingexperts.com/sap-abap-training-in-chennai/

contact +91-08122241286

ragu varan said...

Best SAP HANA Training in Chennai by leading HANA Consultant.
Reach at 9003085882
http://thecreatingexperts.com/category/sap-hana-training-in-chennai/

I.N. Gagan said...

Hi sandip,

i want to send mail with excel attachments, the excel is having more than 255 characters so how to achieve this without using the oops concept in the program.

Regards
Gagan