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.
TABLES: ekko.
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.
9 comments:
Nice Program
Thanks for the great information in your blog on. It was so nice Program Thank you for valuable informationsap video tutorials
Thanks for Sharing this Information.You are providing very valuable information sap video tutorials
Fabulous..!!! The information you Provided is much useful sap video tutorials
Well it Was Very Good Information. Thanks for sharing this Informationsap video tutorials
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!!!!!!
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!!!!!!
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
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
Post a Comment