Sending mail of ALV Report automatically
Hi All,
Don't we have one funtional module to send the report output automatically when it is executed.
I want to give userID only for input.
Please tel me as soon as possible.
Regards,
Rohit
Hi,
Try this
SELECT U~BNAME
A~SMTP_ADDR
INTO TABLE T_MAILID
FROM USR21 AS U INNER JOIN
ADR6 AS A
ON APERSNUMBER = UPERSNUMBER AND
AADDRNUMBER = UADDRNUMBER
WHERE U~BNAME IN S_UNAME.
from this you can get the Mail id :
then you use the function module SO_NEW_DOCUMENT_SEND_API1.
Similar Messages
-
Automatically send mail from ALV reports
hi experts,
I have created an ALV report for overtime calculation.The report will be generated on weekly basis in the background and will display calculated overtime worked by employees in the previous week. I want the Report to run background and send the report in the HR dept concened officer in excel format automatically on weekly basis for his approval.
how do i go about.
regards,
aerohi,
<b>1</b>. u can prepare the output in an internal table ITAB.
<b>2</b>. and then u can fill mail content with the help of ITAB data
<b>3</b>. and then call function <b>'SO_NEW_DOCUMENT_SEND_API1'</b> if u have no attachement to be sent, but only normal mail with content in it.
The sample code is below.
FORM header_of_mail.
CLEAR g_s_object_content.
REFRESH g_t_object_content.
Get an empty line
MOVE space TO g_s_object_content+0(81).
APPEND g_s_object_content TO g_t_object_content.
Print partner number and description
CLEAR g_s_object_content.
MOVE text-t13 TO g_s_object_content. " WMS
MOVE sy-uline TO g_s_object_content+15(1).
MOVE g_f_wms_descr TO g_s_object_content+30.
APPEND g_s_object_content TO g_t_object_content.
Print Division for which the mail is meant for
CLEAR g_s_object_content.
MOVE text-t14 TO g_s_object_content. " Material with division
MOVE sy-uline TO g_s_object_content+25(1).
MOVE g_t_y16m_rcp_par-spart TO g_s_object_content+30.
APPEND g_s_object_content TO g_t_object_content.
Get an empty line
CLEAR g_s_object_content.
MOVE space TO g_s_object_content+0(81).
APPEND g_s_object_content TO g_t_object_content.
Get a dotted line.
CLEAR g_s_object_content.
MOVE sy-uline TO g_s_object_content+0(120).
APPEND g_s_object_content TO g_t_object_content.
Print column headings
CLEAR g_s_object_content.
MOVE text-t04 TO g_s_object_content+3(16). " IDoc number
MOVE text-t05 TO g_s_object_content+27(18). " Material number
MOVE text-t07 TO g_s_object_content+63(6). " Length
MOVE text-t08 TO g_s_object_content+81(5). " Width
MOVE text-t09 TO g_s_object_content+97(6). " Height
MOVE text-t10 TO g_s_object_content+109(11). " Brut Weight
APPEND g_s_object_content TO g_t_object_content.
Get a dotted line.
CLEAR g_s_object_content.
MOVE sy-uline TO g_s_object_content+0(120).
APPEND g_s_object_content TO g_t_object_content.
ENDFORM. " HEADER_OF_MAIL
FORM body_of_mail.
Print contents such as IDoc number, material no. and measures
LOOP AT g_t_mail_for_division.
CLEAR g_s_object_content.
MOVE g_t_mail_for_division-docnum TO g_s_object_content+3(16).
MOVE g_t_mail_for_division-matnr TO g_s_object_content+27(18).
MOVE text-t11 TO g_s_object_content+49(4).
MOVE g_t_mail_for_division-laeng_from_sap TO
g_s_object_content+57(13).
MOVE g_t_mail_for_division-breit_from_sap TO
g_s_object_content+74(13).
MOVE g_t_mail_for_division-hoehe_from_sap TO
g_s_object_content+91(13).
MOVE g_t_mail_for_division-brgew_from_sap TO
g_s_object_content+108(13).
APPEND g_s_object_content TO g_t_object_content.
CLEAR g_s_object_content.
MOVE text-t12 TO g_s_object_content+49(4).
MOVE g_t_mail_for_division-laeng_from_idoc TO
g_s_object_content+57(13).
MOVE g_t_mail_for_division-breit_from_idoc TO
g_s_object_content+74(13).
MOVE g_t_mail_for_division-hoehe_from_idoc TO
g_s_object_content+91(13).
MOVE g_t_mail_for_division-brgew_from_idoc TO
g_s_object_content+108(13).
APPEND g_s_object_content TO g_t_object_content.
ENDLOOP.
ENDFORM. " BODY_OF_MAIL
FORM send_mail USING p_y16m_rcp_par STRUCTURE y16m_rcp_par.
Have a subject for the mail
g_s_document_data-obj_name = text-t02.
g_s_document_data-obj_descr = text-t03.
Fill receiver information
CLEAR g_s_receivers.
REFRESH g_t_receivers.
g_s_receivers-rec_type = p_y16m_rcp_par-rec_type.
g_s_receivers-receiver = p_y16m_rcp_par-rec_id.
g_s_receivers-express = 'X'.
APPEND g_s_receivers TO g_t_receivers.
Call function to send mail
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = g_s_document_data
document_type = 'RAW'
PUT_IN_OUTBOX = ' '
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
TABLES
OBJECT_HEADER =
object_content = g_t_object_content
CONTENTS_HEX =
OBJECT_PARA =
OBJECT_PARB =
receivers = g_t_receivers
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " SEND_MAIL
hope this helps.
pls reward if useful...
Message was edited by:
pawan ambadas -
How to send a oracle application report automatically to a specific e-mail
hi!!!!!
how to automatically send a mail once the oracle application report is generated ??
It should happen automatically...
Do we have to use any function for that??? or is there any other way of doing it???You can use utl_smtp package in the after report trigger to send mail after the report run is completed.
for example look at my post
Re: Sending concurrent program output as an Email to a distribution list -
Problem to send text file to mail from ALV report
Hi Friends,
I have a problem in my ALV report with text file. As per the requirment, when we execute the program then text attachment should go to the particual email.
When i am using file type as XLS i am getting attachment with all 4 recoreds( input for 4 records) in mail. But all 4 records are coming in SAME ROW. It should come 4 records in 4 rows. when I use file type as TXT and separated by pipe symble in code, it is showing only one recored for same above input.
When i use file type as XLS and click the attachment in email, it will triggire one popul with three options like SAVE, OPEN, CANCEL.
But when i click on text file attachment, it is directly showing ony one recored.
Please correct me on this.
my code is
PERFORM send_file_as_email_attachment
tables i_message
i_attach
using v_email
'User last log on details'
'XLS'
'User log on list'
changing v_error
v_reciever.
FORM send_file_as_email_attachment tables pi_message
pi_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
DATA: l_error TYPE sy-subrc,
l_reciever TYPE sy-subrc,
l_mtitle LIKE sodocchgi1-obj_descr,
l_email LIKE somlreci1-receiver,
l_format TYPE so_obj_tp ,
l_attdescription TYPE so_obj_nam ,
l_attfilename TYPE so_obj_des ,
l_sender_address LIKE soextreci1-receiver,
l_sender_address_type LIKE soextreci1-adr_typ,
l_receiver LIKE sy-subrc.
l_email = p_email.
l_mtitle = p_mtitle.
l_format = p_format.
l_attdescription = p_attdescription.
l_attfilename = p_filename.
l_sender_address = p_sender_address.
l_sender_address_type = p_sender_addres_type.
Fill the document data.
v_doc_data-doc_size = 1.
Populate the subject/generic message attributes
v_doc_data-obj_langu = sy-langu.
v_doc_data-obj_name = 'SAPRPT'.
v_doc_data-obj_descr = l_mtitle .
v_doc_data-sensitivty = 'F'.
Fill the document data and get size of attachment
CLEAR v_doc_data.
READ TABLE i_attach INDEX v_cnt.
v_doc_data-doc_size =
( v_cnt - 1 ) * 255 + STRLEN( i_attach ).
v_doc_data-obj_langu = sy-langu.
v_doc_data-obj_name = 'SAPRPT'.
v_doc_data-obj_descr = l_mtitle.
v_doc_data-sensitivty = 'F'.
CLEAR i_attachment.
REFRESH i_attachment.
i_attachment[] = pi_attach[].
Describe the body of the message
CLEAR i_packing_list.
REFRESH i_packing_list.
i_packing_list-transf_bin = space.
i_packing_list-head_start = 1.
i_packing_list-head_num = 0.
i_packing_list-body_start = 1.
DESCRIBE TABLE i_message LINES i_packing_list-body_num.
i_packing_list-doc_type = 'RAW'.
APPEND i_packing_list.
Create attachment notification
i_packing_list-transf_bin = 'X'.
i_packing_list-head_start = 1.
i_packing_list-head_num = 1.
i_packing_list-body_start = 1.
DESCRIBE TABLE i_attachment LINES i_packing_list-body_num.
i_packing_list-doc_type = l_format.
i_packing_list-obj_descr = l_attdescription.
i_packing_list-obj_name = l_attfilename.
i_packing_list-doc_size = i_packing_list-body_num * 255.
APPEND i_packing_list.
Add the recipients email address
CLEAR i_receivers.
REFRESH i_receivers.
i_receivers-receiver = l_email.
i_receivers-rec_type = 'U'.
i_receivers-com_type = 'INT'.
i_receivers-notif_del = 'X'.
i_receivers-notif_ndel = 'X'.
APPEND i_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = v_doc_data
put_in_outbox = 'X'
sender_address = l_sender_address
sender_address_type = l_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = v_sent_all
TABLES
packing_list = i_packing_list
contents_bin = i_attachment[]
contents_txt = i_message
receivers = i_receivers
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
Populate zerror return code
l_error = sy-subrc.Hi,
declare the following constant in u r program and concatenate at the end of each and every record in your internal table.
CONSTANTS : LV_CRLF TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF.
for eg.
if u internal table has values like
row1
row2
row3
concatenate the 1st record lv_crlf into first record.
conactenate second record lv_crlf into second record.
concatenate third record lv_crlf into third record.
now attach the internal table to the FM which u use for sending email. Each and every row will come in new line. The LV_CRLF will hold nothing but a line feed character (#).
Hope it will solve u r problem
Regards,
Rose. -
Cant send an e-mail in ALV report for background executaion
Hello friends,
I am displaying ALV report using container.
Now when i run this report in background, an e-mail should be go with an EXCEL attachment of report.
I am able to send e-mail and attachment in foreground .
I am also able to run alv report in background.
now, only problem is that i am am not able to send e-mail in background.
any sujjetions ?
Points will rewarded if little bit useful.
Regards,
nimesh
if cl_gui_alv_grid=>offline( ) is initial.
Create custom container
CREATE OBJECT g_r_cust_container
EXPORTING
container_name = gv_ctrl_custom.
Create TOP-Document
CREATE OBJECT g_r_dd_document
EXPORTING
style = 'ALV_GRID'.
Create Splitter for custom_container
CREATE OBJECT g_r_splitter
EXPORTING
parent = g_r_cust_container
rows = 2
columns = 1.
Split the grid in two parts- top and grid
CALL METHOD g_r_splitter->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = g_r_parent_top.
CALL METHOD g_r_splitter->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = g_r_parent_grid.
Set height for g_parent_html
CALL METHOD g_r_splitter->set_row_height
EXPORTING
id = 1
height = 1.
Create grid object
CREATE OBJECT g_r_alvgrid
EXPORTING
i_parent = g_r_parent_grid. "g_r_cust_container.
else .
Create grid object
CREATE OBJECT g_r_alvgrid
EXPORTING
i_parent = or_doc. "g_r_cust_container.
endif .
Create object handler object (of type local class)
CREATE OBJECT g_r_handler.
SET HANDLER g_r_handler->top_of_page FOR g_r_alvgrid.
SET HANDLER g_r_handler->print_top_of_page FOR g_r_alvgrid.
w_disvariant-report = sy-repid.
w_disvariant-variant = p_vari.
CALL METHOD g_r_alvgrid->set_table_for_first_display
EXPORTING
i_structure_name = 'ysds_sox_price_change'
is_layout = w_layout
is_variant = w_disvariant
i_save = yc_chara
CHANGING
it_outtab = t_st_result
it_fieldcatalog = t_fieldcat[]
it_sort = t_sortinfo[].
CALL METHOD g_r_dd_document->initialize_document
EXPORTING
background_color = cl_dd_area=>col_textarea.no i am using container for ALV.
In above code i have mantioned If.......ELSE.....Condition.
which give me allow to run ALV in background mode but my problem is that i am not able to send e-mail with attachment in background mode.
DATA : or_doc type ref to cl_gui_docking_container .
My report is working fine in foreground but not able to send email in background.
so anybody can solve it? -
Problem in Auto Mail of ALV Report : Urgent
Hello All ,
I have created one ALV Report contain 240 Columns . This report is need to schedule for auto mail in HTML Format.
My Problem is when I am sending this report manually the html output displays all the columns in the mail attachment. While it is scheduled thro' SM36 in background mode the HTML format displays only restricted columns (say upto 132 columns)
Also, we have tried to create new page format X_65_512/2 to accomodate the output. However this option did not work.
Any solution to resolve the same is most welcome !
Regards
Swati NamdeoHi
This problem was not resolved. I tried few things but not good. So what we did we created a few profile like MM/SD/FICA and we executed report based on profile and sent them only the column relevant to them.
Regards,
Atul Joshi -
How to use batch file in window to send out Oracle AWR report automatically
Dear All
Please help me to write batch script as scheduler in windows to send out Oracle AWR report every 2 hours automatically
I have database 10.2.0.3 , its on windows platform .
Thanks in advance846671 wrote:
Dear All
Please help me to write batch script as scheduler in windows to send out Oracle AWR report every 2 hours automatically
I have database 10.2.0.3 , its on windows platform .
Thanks in advancewhat utility do you use to "send out" Oracle AWR report ? -
While sending mails thru my report, Iam getting popups - how to avoid popus
How ever when I execute the program I am able to send mails successfully and but I am getting two popups.
One pop up says its title as u2018SAP connect Send Process : List of sent objectsu2019 and it is showing the list in popup.
When I press u2018ENTERu2019 on above pop up u2026
Another pop up says its title as u2018SAP office express infou2019 and in the popup there is F8 button followed Express document u201CCannot be sent: Errors of EDI 869 input file" received from auu201D and then pop has buttons as enter, choose inbox buttons.
My functional consultant donu2019t want these popups as he want to run this program in background mode.
How can I remove popus ?
How can I remove popus ?
Do I need to comment
PERFORM initiate_mail_execute_program. in my code ?
Please suggest me ?
FORM initiate_mail_execute_program.
WAIT UP TO 2 SECONDS.
IF gd_error EQ 0.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDIF.
ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM
OR what else can I do - inorder to riun my program in background mode.
Thanks IN ADVANCE.> One pop up says its title as u2018SAP connect Send Process : List of sent objectsu2019 and it is showing the list in popup.
> When I press u2018ENTERu2019 on above pop up u2026
This is coming from SUBMIT RSCONN01 you pass output = ' '. instead of 'X'
> Another pop up says its title as u2018SAP office express infou2019 and in the popup there is F8 button followed Express document u201CCannot be sent: Errors of EDI 869 input file" received from auu201D and then pop has buttons as enter, choose inbox buttons.
>
second one is express document.
check you might marked that as 'X' make it ' '.
RECEIVERS-SNDEX = ' '. <===this is incase of SO_OBJECT_SEND
RECEIVERS-EXPRESS = ' '. "<==== this is incase of SO_NEW_DOCUMENT_ATT_SEND_API1
check which function you are using accordingly you need to make that express = ' '. -
Can't Send Mail - An Updated Report
My ISP is a (relatively) small one, Metrocast. They do not require authentication to log on to the smtp.metrocast.net server. In all iterations of OS X, from public beta to 10.5.7, sending email was instantaneous, or nearly so.
Right after the 10.6 upgrade, it was impossible to send mail. I used the "edit server list - advanced" function to enter my UID and password for the email account (even though it is not required), and I can now send mail - but it takes 60-120 seconds for the mail to go to the server.
Also, it constantly requires a password, even though a) the server DOESN'T require it, and b) the password is entered in Mail preferences.
Something has changed about smtp behavior in 10.6, and I can't seem to get it working right.Hi
You need to check with your ISP whether or not the send mail server (SMTP) requires a password. Some do, but many do not. When you know the correct password to send mail, then you need to tell Mail as follows:
Mail menu > Preferences > Accounts > Select the account
Click on the Outgoing Mail Server (SMTP) combo box, and select Edit SMTP Server List...
In the Account Information tab put the server name
In the Advanced Tab, set up the authentication information from your ISP.
Good luck
Bob -
How to send output of alv report as mail
Hi Experts,
I Have retrieved data from USER tables and i need to send the output of the list through mail.
could you please help me in completing this task
Moderator message: FAQ, please search for previous discussions of this topic.
Edited by: Thomas Zloch on Mar 16, 2011 9:41 AMHi,
You can send the report data as an either excel sheet ot txt attachment in side the email. for this you can use the function module . for this refer to program BCS_EXAMPLE_7 . -
Error in sending mail of my reports
Hi,
I am using bipublisher.I have some reports in xls/html/pdf.....formats i want to send these reports via email.
Admin-->Email-->Server-->general tab i used
servername: Myserver.
email :www.xyz.com( here i have to give smtp port number of the website like 40.122....... like this or as given above)
Port: 25
under security i am giving my registered mail address for that site(www.xyz.com)
Here is the problem when i schedule my report and tried to send it .
I am getting error...
oracle.apps.xdo.service.delivery.DeliveryException: oracle.apps.xdo.delivery.DeliveryException: Could not connect to SMTP host: www.xyzl.com, port: 25;
nested exception is:
java.net.ConnectException: Connection refused: connect
at oracle.apps.xdo.service.delivery.impl.DeliveryServiceImpl.deliverToEmail(DeliveryServiceImpl.java:227)
at oracle.apps.xdo.servlet.scheduler.XDOJob.deliver(XDOJob.java:1128)
at oracle.apps.xdo.servlet.scheduler.XDOJob.execute(XDOJob.java:436)
at org.quartz.core.JobRunShell.run(JobRunShell.java:195)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
Caused by: oracle.apps.xdo.delivery.DeliveryException: Could not connect to SMTP host: www.fcsemail.com, port: 25;
nested exception is:
java.net.ConnectException: Connection refused: connect
at oracle.apps.xdo.delivery.smtp.SMTPDeliveryRequestHandler.submitRequest(Unknown Source)
at oracle.apps.xdo.delivery.AbstractDeliveryRequest.submit(Unknown Source)
at oracle.apps.xdo.service.delivery.impl.DeliveryServiceImpl.deliverToEmail(DeliveryServiceImpl.java:221)
... 4 more
Caused by: javax.mail.MessagingException: Could not connect to SMTP host: www.fcsemail.com, port: 25;
nested exception is:
java.net.ConnectException: Connection refused: connect
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1008)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:197)
at javax.mail.Service.connect(Service.java:233)
at javax.mail.Service.connect(Service.java:134)
at javax.mail.Service.connect(Service.java:86)
at com.sun.mail.smtp.SMTPTransport.connect(SMTPTransport.java:104)
... 7 more
any idea!!!!.Is there any need to setup SMTP mail server??Hi Saichand,
Yes, you need to use an existing and correct SMTP host (and port, if needed depending on your code).
SMTP host like rrrr.mymail.com
regards.. -
Send mail using ALV tree(for excel file) outlook
Hello Gurus!!!
The code is as follows :-
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
FILENAME = 'C:\exceldown\tree2.xls'
FILETYPE = 'ASC'
APPEND = ' '
WRITE_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = lt_project.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT outlook 'Outlook.Application'.
CALL METHOD OF outlook 'CREATEITEM' = outmail EXPORTING #1 = 0.
SET PROPERTY OF outmail 'TO' = '[email protected]'.
SET PROPERTY OF outmail 'SUBJECT' = 'Project Management'.
SET PROPERTY OF outmail 'BODY' = 'This is excel attachment'.
*SET PROPERTY OF outmail 'Insert File' = 'C:\exceldown\tree2.xls'.
<b>CALL METHOD OF outmail 'Insert File'. <b>****NOT WORKING</b>
SET PROPERTY OF outmail 'Attach' = 'C:\exceldown\tree2.xls'.</b>
CALL METHOD OF outmail 'SEND'.
FREE OBJECT outlook.
Kindly suggest your answers.
Helpful points will be rewarded
Thanks,
Sachin.Achieved the requirement using FM RS_TREE_CONSTRUCT
-
Send ALV report as attachment in EXCEL format
Hi SAP Guru,
I had a report output as ALV format.
Currently, when the background job ended, it would be send out to the recipent thru SAPconnect as PDF format using internet mailing address.
I tried to search for a configuraiton for EXCEL output but there don;t seems to be any option availble.
I can only choose from PDF/TEXT/HTM/PS in the output document type selection in SOST.
How can I configure to allow the system to send out the ALV report to my recipent in EXCEL format instead of PDF or HTML?
ThanksHi,
By Using OOPS Concept you can send ALV Output as Excel Format by using Class Interface: CL_BCS.
Do some search on CL_BCS.
There are some demo Program, sreach for BCS* on SE38.
Thanks & Regards
M Nair -
Send mail as follow-up action in reporting agent
I need to send a mail with the exceptions flaoting from a query. I tried to use the follow-up action of 'send mail' in the reporting agent. that didnt work because in our SAP we're not using the exchange connector and mails cannot be sent in the regular way.
I have an external command of sending mail.
Does anyone has a way of solving this problem, meaning, using my external command of sending mail in order to send the mail with the exceptions (this command works just fine in process chains, for example, for notification of process progress)
Thank You,
Yoav.Hello Nili,
I think you can edit content and Subject etc.
http://help.sap.com/saphelp_nw2004s/helpdata/en/21/35783b82ee5d31e10000000a114084/content.htm
Hope this helps.
San. -
Output of ALV report as attachment in email
Dear all ,
I would like to send output of ALV report as attachment in email.
i already written code for this using FM SO_NEW_DOCUMENT_ATT_SEND_API1.
I can able to send list output as HTM format. But I want to send ALV report output
As a attachment. How can I do this .please explain
Thanks in advance
Regards
ManoharHello,
U can sent like this.
Check this report
REPORT ZV_SEND_MAIL .
TABLES: EKKO.
PARAMETERS: P_EMAIL TYPE SOMLRECI1-RECEIVER
DEFAULT '[email protected]'.
TYPES: BEGIN OF T_EKPO,
EBELN TYPE EKPO-EBELN,
EBELP TYPE EKPO-EBELP,
AEDAT TYPE EKPO-AEDAT,
MATNR TYPE EKPO-MATNR,
END OF T_EKPO.
DATA: IT_EKPO TYPE STANDARD TABLE OF T_EKPO INITIAL SIZE 0,
WA_EKPO TYPE T_EKPO.
TYPES: BEGIN OF T_CHAREKPO,
EBELN(10) TYPE C,
EBELP(5) TYPE C,
AEDAT(8) TYPE C,
MATNR(18) TYPE C,
END OF T_CHAREKPO.
DATA: WA_CHAREKPO TYPE T_CHAREKPO.
DATA: IT_MESSAGE TYPE STANDARD TABLE OF SOLISTI1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: IT_ATTACH TYPE STANDARD TABLE OF SOLISTI1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: T_PACKING_LIST LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
T_CONTENTS LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
T_RECEIVERS LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
T_ATTACHMENT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
T_OBJECT_HEADER LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
W_CNT TYPE I,
W_SENT_ALL(1) TYPE C,
W_DOC_DATA LIKE SODOCCHGI1,
GD_ERROR TYPE SY-SUBRC,
GD_RECIEVER TYPE SY-SUBRC.
*START_OF_SELECTION
START-OF-SELECTION.
* Retrieve sample data from table ekpo
PERFORM DATA_RETRIEVAL.
* Populate table with detaisl to be entered into .xls file
PERFORM BUILD_XLS_DATA_TABLE.
*END-OF-SELECTION
END-OF-SELECTION.
* Populate message body text
PERFORM POPULATE_EMAIL_MESSAGE_BODY.
* Send file by email as .xls speadsheet
PERFORM SEND_FILE_AS_EMAIL_ATTACHMENT
TABLES IT_MESSAGE
IT_ATTACH
USING P_EMAIL
'Example .xls documnet attachment'
'XLS'
'filename'
CHANGING GD_ERROR
GD_RECIEVER.
* Instructs mail send program for SAPCONNECT to send email(rsconn01)
PERFORM INITIATE_MAIL_EXECUTE_PROGRAM.
*& Form DATA_RETRIEVAL
* Retrieve data form EKPO table and populate itab it_ekko
FORM DATA_RETRIEVAL.
SELECT EBELN EBELP AEDAT MATNR
UP TO 10 ROWS
FROM EKPO
INTO TABLE IT_EKPO.
ENDFORM. " DATA_RETRIEVAL
*& Form BUILD_XLS_DATA_TABLE
* Build data table for .xls document
FORM BUILD_XLS_DATA_TABLE.
CONSTANTS: CON_CRET TYPE X VALUE '0D', "OK for non Unicode
CON_TAB TYPE X VALUE '09'. "OK for non Unicode
*If you have Unicode check active in program attributes thnen you will
*need to declare constants as follows
*class cl_abap_char_utilities definition load.
*constants:
* con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
* con_cret type c value cl_abap_char_utilities=>CR_LF.
CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
INTO IT_ATTACH SEPARATED BY CON_TAB.
CONCATENATE CON_CRET IT_ATTACH INTO IT_ATTACH.
APPEND IT_ATTACH.
LOOP AT IT_EKPO INTO WA_CHAREKPO.
CONCATENATE WA_CHAREKPO-EBELN WA_CHAREKPO-EBELP
WA_CHAREKPO-AEDAT WA_CHAREKPO-MATNR
INTO IT_ATTACH SEPARATED BY CON_TAB.
CONCATENATE CON_CRET IT_ATTACH INTO IT_ATTACH.
APPEND IT_ATTACH.
ENDLOOP.
ENDFORM. " BUILD_XLS_DATA_TABLE
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
* Send email
FORM SEND_FILE_AS_EMAIL_ATTACHMENT TABLES PIT_MESSAGE
PIT_ATTACH
USING P_EMAIL
P_MTITLE
P_FORMAT
P_FILENAME
P_ATTDESCRIPTION
P_SENDER_ADDRESS
P_SENDER_ADDRES_TYPE
CHANGING P_ERROR
P_RECIEVER.
DATA: LD_ERROR TYPE SY-SUBRC,
LD_RECIEVER TYPE SY-SUBRC,
LD_MTITLE LIKE SODOCCHGI1-OBJ_DESCR,
LD_EMAIL LIKE SOMLRECI1-RECEIVER,
LD_FORMAT TYPE SO_OBJ_TP ,
LD_ATTDESCRIPTION TYPE SO_OBJ_NAM ,
LD_ATTFILENAME TYPE SO_OBJ_DES ,
LD_SENDER_ADDRESS LIKE SOEXTRECI1-RECEIVER,
LD_SENDER_ADDRESS_TYPE LIKE SOEXTRECI1-ADR_TYP,
LD_RECEIVER LIKE SY-SUBRC.
LD_EMAIL = P_EMAIL.
LD_MTITLE = P_MTITLE.
LD_FORMAT = P_FORMAT.
LD_ATTDESCRIPTION = P_ATTDESCRIPTION.
LD_ATTFILENAME = P_FILENAME.
LD_SENDER_ADDRESS = P_SENDER_ADDRESS.
LD_SENDER_ADDRESS_TYPE = P_SENDER_ADDRES_TYPE.
* Fill the document data.
W_DOC_DATA-DOC_SIZE = 1.
* Populate the subject/generic message attributes
W_DOC_DATA-OBJ_LANGU = SY-LANGU.
W_DOC_DATA-OBJ_NAME = 'SAPRPT'.
W_DOC_DATA-OBJ_DESCR = LD_MTITLE .
W_DOC_DATA-SENSITIVTY = 'F'.
* Fill the document data and get size of attachment
CLEAR W_DOC_DATA.
READ TABLE IT_ATTACH INDEX W_CNT.
W_DOC_DATA-DOC_SIZE =
( W_CNT - 1 ) * 255 + STRLEN( IT_ATTACH ).
W_DOC_DATA-OBJ_LANGU = SY-LANGU.
W_DOC_DATA-OBJ_NAME = 'SAPRPT'.
W_DOC_DATA-OBJ_DESCR = LD_MTITLE.
W_DOC_DATA-SENSITIVTY = 'F'.
CLEAR T_ATTACHMENT.
REFRESH T_ATTACHMENT.
T_ATTACHMENT[] = PIT_ATTACH[].
* Describe the body of the message
CLEAR T_PACKING_LIST.
REFRESH T_PACKING_LIST.
T_PACKING_LIST-TRANSF_BIN = SPACE.
T_PACKING_LIST-HEAD_START = 1.
T_PACKING_LIST-HEAD_NUM = 0.
T_PACKING_LIST-BODY_START = 1.
DESCRIBE TABLE IT_MESSAGE LINES T_PACKING_LIST-BODY_NUM.
T_PACKING_LIST-DOC_TYPE = 'RAW'.
APPEND T_PACKING_LIST.
* Create attachment notification
T_PACKING_LIST-TRANSF_BIN = 'X'.
T_PACKING_LIST-HEAD_START = 1.
T_PACKING_LIST-HEAD_NUM = 1.
T_PACKING_LIST-BODY_START = 1.
DESCRIBE TABLE T_ATTACHMENT LINES T_PACKING_LIST-BODY_NUM.
T_PACKING_LIST-DOC_TYPE = LD_FORMAT.
T_PACKING_LIST-OBJ_DESCR = LD_ATTDESCRIPTION.
T_PACKING_LIST-OBJ_NAME = LD_ATTFILENAME.
T_PACKING_LIST-DOC_SIZE = T_PACKING_LIST-BODY_NUM * 255.
APPEND T_PACKING_LIST.
* Add the recipients email address
CLEAR T_RECEIVERS.
REFRESH T_RECEIVERS.
T_RECEIVERS-RECEIVER = LD_EMAIL.
T_RECEIVERS-REC_TYPE = 'U'.
T_RECEIVERS-COM_TYPE = 'INT'.
T_RECEIVERS-NOTIF_DEL = 'X'.
T_RECEIVERS-NOTIF_NDEL = 'X'.
APPEND T_RECEIVERS.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = W_DOC_DATA
PUT_IN_OUTBOX = 'X'
SENDER_ADDRESS = LD_SENDER_ADDRESS
SENDER_ADDRESS_TYPE = LD_SENDER_ADDRESS_TYPE
COMMIT_WORK = 'X'
IMPORTING
SENT_TO_ALL = W_SENT_ALL
TABLES
PACKING_LIST = T_PACKING_LIST
CONTENTS_BIN = T_ATTACHMENT
CONTENTS_TXT = IT_MESSAGE
RECEIVERS = T_RECEIVERS
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
DOCUMENT_TYPE_NOT_EXIST = 3
OPERATION_NO_AUTHORIZATION = 4
PARAMETER_ERROR = 5
X_ERROR = 6
ENQUEUE_ERROR = 7
OTHERS = 8.
* Populate zerror return code
LD_ERROR = SY-SUBRC.
* Populate zreceiver return code
LOOP AT T_RECEIVERS.
LD_RECEIVER = T_RECEIVERS-RETRN_CODE.
ENDLOOP.
ENDFORM.
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
* Instructs mail send program for SAPCONNECT to send email.
FORM INITIATE_MAIL_EXECUTE_PROGRAM.
WAIT UP TO 2 SECONDS.
SUBMIT RSCONN01 WITH MODE = 'INT'
WITH OUTPUT = 'X'
AND RETURN.
ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM
*& Form POPULATE_EMAIL_MESSAGE_BODY
* Populate message body text
FORM POPULATE_EMAIL_MESSAGE_BODY.
REFRESH IT_MESSAGE.
IT_MESSAGE = 'Please find attached a list test ekpo records'.
APPEND IT_MESSAGE.
ENDFORM. " POPULATE_EMAIL_MESSAGE_BODY
If useful reward.
Vasanth
Maybe you are looking for
-
About to use my tree for firewood
I was wondering if someone could maybe clue me into a problem that I am having with my DefaultMutableTree. See, I call a recursive method to get the file system of the computer, which is what is added to the tree. So the user is looking at a tree str
-
My Apple TV sync computer's hard drive failed.
I had a PC syncing with my Apple TV. The hard drive was failing but I was able to get all of my iTunes content to an external hard drive prior to it biting the dust. I have replaced that PC with a Macbook (Snow Leopard 10.6.2 and iTunes 9.0.3) and al
-
Upgrade for a G3-350 with Mac OS 8.6
My son was recently given an old imac from 1999. The only infor I can find for it is that it is a G3-350 and the OS is 8.6. What would I be able to upgrade the OS to? I am a pc user, and this is my first time dealing with a MAC, so I don't know anyth
-
PL/SQL will compile with warnings but will not run
I have a pl/sql package that will compile with warnings but no errors but when i try to run it I get an ORA-6508 error telling me there is an error somewhere in the package but I can't find it. I have two user schemas that use 2 slightly different ve
-
want to have photo image to fill window, can't get photo border to turn red when sizing to web frame