Send ALV report as email attachment but in background scheduling mode
Hi All,
I have ALV report which runs fine in the foreground.
But i need to display it in the spool that is by scheduling in the background.
can i send an excel attachement as e-mail in the background scheduling? my report contains
10 columns and i need them in proper format on excel sheet attachment? plz help me out?if possible
give me abap code..
HI,
Use the below link
Sending Mail to the schedular of Background Job
Thanks
Similar Messages
-
Sending ALV report(As a attachment ) through EMail
Dear Friends,
Could anyone please help me to solve this problem.
I need to send ALV report <b>as an attachment</b> to External mail-id as well as SAP USER ID..The user wants to schedule this ABAP program in background, at the end the final output should be send to his ID. I facing problem to locate correct Functional Module....
I would like to thank, if anyone give some idea on this issue also if possible a sample code.
Thanks in advance
With Reg
BabuHI Kamal Babu
After sending your ABAP List to the spool request (SP01), you can use the SAP standard spool PDF conversion program.
RSTXPDFT4 - This report program converts ABAP List to PDF files.
Or Just try this sample code:
After running the background jobs, send the spool to the SAP users Office Mail Box.
REPORT ZMAILSPOOL.
INCLUDE LBTCHDEF.
Include the Business Object Repository object
INCLUDE <CNTN01>.
DATA ABAPNM LIKE SY-REPID.
DATA BEGIN OF LOCAL_JOB.
INCLUDE STRUCTURE TBTCJOB.
DATA END OF LOCAL_JOB.
DATA BEGIN OF LOCAL_STEP_TBL OCCURS 10.
INCLUDE STRUCTURE TBTCSTEP.
DATA END OF LOCAL_STEP_TBL.
Data declarations for the mail recipient
DATA RECIPIENT TYPE SWC_OBJECT.
DATA RECIPIENT_OBJ LIKE SWOTOBJID.
SWC_CONTAINER CONTAINER.
Data declarations for the background job
PARAMETERS ABAPNAME(20) DEFAULT 'ZTEST1'.
PARAMETERS EMPFNAME LIKE SY-UNAME DEFAULT SY-UNAME.
ABAPNM = ABAPNAME.
LOCAL_JOB-JOBNAME = ABAPNAME.
Generate recipient object (see report RSSOKIF1 for an example)
1. Create the recipient:
IF EMPFNAME <> SPACE.
"** 1.1 Generate an object reference to a recipient object
SWC_CREATE_OBJECT RECIPIENT 'RECIPIENT' SPACE.
"** 1.2 Write the import parameters for method
"** recipient.createaddress into the container
"** and empty the container
SWC_CLEAR_CONTAINER CONTAINER.
"** Set address element (internal user 'JSMITH')
SWC_SET_ELEMENT CONTAINER 'AddressString' EMPFNAME.
"** Set address type (internal user)
SWC_SET_ELEMENT CONTAINER 'TypeId' 'B'.
"** 1.3 Call the method recipient.createaddress
SWC_CALL_METHOD RECIPIENT 'CreateAddress' CONTAINER.
"** Issue any error message generated by a method exception
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE 'E' NUMBER SY-MSGNO.
ENDIF.
SWC_CALL_METHOD RECIPIENT 'Save' CONTAINER.
SWC_OBJECT_TO_PERSISTENT RECIPIENT RECIPIENT_OBJ.
ENDIF.
Recipient has been generated and is ready for use in a
background job
CALL FUNCTION 'JOB_OPEN'
exporting
DELANFREP = ' '
JOBGROUP = ' '
jobname = LOCAL_JOB-JOBNAME
SDLSTRTDT = NO_DATE
SDLSTRTTM = NO_TIME
IMPORTING
JOBCOUNT = LOCAL_JOB-JOBCOUNT
EXCEPTIONS
CANT_CREATE_JOB = 1
INVALID_JOB_DATA = 2
JOBNAME_MISSING = 3
OTHERS = 4
if sy-subrc <> 0.
WRITE: / 'JOB_OPEN PROBLEM ', SY-SUBRC.
ELSE.
WRITE: / 'JOB OPEN SUCCESS',
LOCAL_JOB-JOBNAME, LOCAL_JOB-JOBCOUNT.
endif.
CALL FUNCTION 'JOB_SUBMIT'
exporting
ARCPARAMS =
authcknam = SY-UNAME
COMMANDNAME = ' '
OPERATINGSYSTEM = ' '
EXTPGM_NAME = ' '
EXTPGM_PARAM = ' '
EXTPGM_SET_TRACE_ON = ' '
EXTPGM_STDERR_IN_JOBLOG = 'X'
EXTPGM_STDOUT_IN_JOBLOG = 'X'
EXTPGM_SYSTEM = ' '
EXTPGM_RFCDEST = ' '
EXTPGM_WAIT_FOR_TERMINATION = 'X'
jobcount = LOCAL_JOB-JOBCOUNT
jobname = LOCAL_JOB-JOBNAME
LANGUAGE = SY-LANGU
PRIPARAMS = ' '
REPORT = ABAPNM
REPORT = 'ZTEST1'
VARIANT = ' '
IMPORTING
STEP_NUMBER = LOCAL_JOB-STEPCOUNT
EXCEPTIONS
BAD_PRIPARAMS = 1
BAD_XPGFLAGS = 2
INVALID_JOBDATA = 3
JOBNAME_MISSING = 4
JOB_NOTEX = 5
JOB_SUBMIT_FAILED = 6
LOCK_FAILED = 7
PROGRAM_MISSING = 8
PROG_ABAP_AND_EXTPG_SET = 9
OTHERS = 10
if sy-subrc <> 0.
WRITE: / 'JOB_SUBMIT PROBLEM ', LOCAL_JOB-JOBCOUNT,
LOCAL_JOB-JOBNAME, ABAPNAME, SY-SUBRC.
endif.
IF EMPFNAME <> SPACE.
CALL FUNCTION 'JOB_CLOSE'
exporting
AT_OPMODE = ' '
AT_OPMODE_PERIODIC = ' '
CALENDAR_ID = ' '
EVENT_ID = ' '
EVENT_PARAM = ' '
EVENT_PERIODIC = ' '
jobcount = LOCAL_JOB-JOBCOUNT
jobname = LOCAL_JOB-JOBNAME
LASTSTRTDT = NO_DATE
LASTSTRTTM = NO_TIME
PRDDAYS = 0
PRDHOURS = 0
PRDMINS = 0
PRDMONTHS = 0
PRDWEEKS = 0
PREDJOB_CHECKSTAT = ' '
PRED_JOBCOUNT = ' '
PRED_JOBNAME = ' '
SDLSTRTDT = NO_DATE
SDLSTRTTM = NO_TIME
STARTDATE_RESTRICTION = BTC_PROCESS_ALWAYS
STRTIMMED = 'X'
TARGETSYSTEM = ' '
START_ON_WORKDAY_NOT_BEFORE = SY-DATUM
START_ON_WORKDAY_NR = 0
WORKDAY_COUNT_DIRECTION = 0
RECIPIENT_OBJ = RECIPIENT_OBJ
TARGETSERVER = ' '
DONT_RELEASE = ' '
IMPORTING
JOB_WAS_RELEASED = 'X'
EXCEPTIONS
CANT_START_IMMEDIATE = 1
INVALID_STARTDATE = 2
JOBNAME_MISSING = 3
JOB_CLOSE_FAILED = 4
JOB_NOSTEPS = 5
JOB_NOTEX = 6
LOCK_FAILED = 7
OTHERS = 8
IF ( SY-SUBRC <> 0 ).
WRITE: / 'Job_Close Problem:', ABAPNAME, SY-SUBRC.
ELSE.
WRITE: / 'Job_Close done'.
ENDIF.
ELSE. "no empfname
ENDIF.
Cheers,
Vijay Raheja -
How to send ALV report by Email
Hi.
we have developed a block ALV report which has 3 reports i.e Detail report , summary report and Error report. Currently user run the report in background.However there is need to send this report by Email . I can use FM:SO_OBJECT_SEND . I want how to pass this report to FM and how to handle if there are multiple email ids. I think we can create a group of the user with email id in business workplace and pass the group to FM.
I need help in how to assign the report and user group to this FMHi,
You may use the code given by Amit in this link -
MAil Attachment.
It is perfect to handle any type of email requirement.
Regards,
Amit
Reward all helpful replies. -
How to send ALV report by email, in the body of the email?
Hello friends,
I need to send a report ALV by email. First, the user wanted it attached as PDF file, but now he wants it in the body of the email.
Does anybody have any solution?
P.S.: I am using methods to send the email.
Thanks in advance.
Karla.Thank you Jan,
I used the following solution to get the report in HTML code:
I use submit to export the list to memory
SUBMIT zsdr006_alv EXPORTING LIST TO MEMORY AND RETURN.
Them I get the list from memory
CALL FUNCTION 'LIST_FROM_MEMORY'
Finaly I convert the list to HTML code
CALL FUNCTION 'WWW_HTML_FROM_LISTOBJECT'
The problem is when I send the email, it is still not going on the body of the email.
I tried taking off the attach method, but the email goes blank in the body.
Actually to SOST the message goes with the HMTL report in the body, just like I need, but when send to any e-mail address, it does not go on the body of the message.
Does any body could check this out?
TRY.
-------- create persistent send request ------------------------
send_request = cl_bcs=>create_persistent( ).
-------- create and set document with attachment ---------------
create document from internal table with text
IF p_pdf EQ 'X'.
l_type = 'RAW'.
APPEND text-t01 TO text.
IF NOT s_erdat-low IS INITIAL.
CONCATENATE s_erdat-low6(2) '.' s_erdat-low4(2) '.' s_erdat-low(4) INTO ls_text-line.
IF NOT s_erdat-high IS INITIAL.
CONCATENATE ls_text-line 'a' INTO ls_text-line SEPARATED BY space.
CONCATENATE ls_text-line s_erdat-high+6(2) INTO ls_text-line SEPARATED BY space.
CONCATENATE ls_text-line '.' s_erdat-high+4(2) '.' s_erdat-high(4) INTO ls_text-line.
ENDIF.
CONCATENATE 'Período:' ls_text-line INTO ls_text-line SEPARATED BY space.
APPEND ls_text TO text.
ENDIF.
ELSEIF p_htm EQ 'X'.
l_type = 'HTM'.
LOOP AT gt_ascdata INTO ls_ascdata.
ls_text = ls_ascdata-line.
APPEND ls_text TO text.
ENDLOOP.
ENDIF.
subject = text-t01.
document = cl_document_bcs=>create_document(
i_type = l_type
i_text = text
i_length = '12'
i_subject = subject ).
add attachment to document
BCS expects document content here e.g. from document upload
binary_content = ...
IF p_pdf EQ 'X'.
CALL METHOD document->add_attachment
EXPORTING
i_attachment_type = 'PDF'
i_attachment_subject = g_filename
i_att_content_hex = binary_content.
ELSEIF p_htm EQ 'X'.
CALL METHOD document->add_attachment
EXPORTING
i_attachment_type = 'HTM'
i_attachment_subject = g_filename
i_att_content_text = gt_ascdata.
ENDIF.
add document to send request
CALL METHOD send_request->set_document( document ).
--------- set sender -------------------------------------------
note: this is necessary only if you want to set the sender
different from actual user (SY-UNAME). Otherwise sender is
set automatically with actual user.
sender = cl_sapuser_bcs=>create( sy-uname ).
lv_email = g_email.
sender = cl_cam_address_bcs=>create_internet_address( lv_email ).
CALL METHOD send_request->set_sender
EXPORTING
i_sender = sender.
--------- add recipient (e-mail address) -----------------------
create recipient - please replace e-mail address !!!
LOOP AT s_email.
lv_email = s_email-low.
recipient = cl_cam_address_bcs=>create_internet_address( lv_email ).
add recipient with its respective attributes to send request
CALL METHOD send_request->add_recipient
EXPORTING
i_recipient = recipient
i_express = 'X'.
ENDLOOP.
---------- send document ---------------------------------------
CALL METHOD send_request->send(
EXPORTING
i_with_error_screen = 'X'
RECEIVING
result = sent_to_all ). -
LOGO not going when sending the report as Email attachement
Hi
We are calling reports in two ways (both as html format) to be sent as Email. The report includes company logo at the top
1.Running report in cache through Web.Show_document and
copy it by using copy_report_object_output and
displaying it using Web.show_document('mailto: '||:resorts_name.e_mail);
2. By using xml distribution list to dynamic emails
web.show_document('myserver...servlet?report=myreport&server=myserver&userid=user@ourdb
&distribute=yes&destination=ourxml.xml');
By using 1st method The report has to manually reattach, and is attached and sent but Company Logo is not being displayed and it shows only the html file and at the logo it displays the red crossed. The reason seams that when it produces the report it creates two file html and gif file and while reattaching it attach only htm and not logo.
By Using 2nd method of the distribution list and the xml file it attaches report in the body however it disturbs the margin due to the email headers and it shows the logo but when prints the report again it show red marked blank area as of 1.
Does any one faced the problem of logo not being displayed at the email when report was sent and any solution regarding this will be highly appreatiated.
Regards
Yasir MaqboolHi,
After generating them write a program to send the mail .
for that convert the pay slip to PDF format and attch it to mail.
for converting it to PDF use this FM <b>CONVERT_PAYSLIP_TO_PDF</b>
after conversion send it using <b>SO_NEW_DOCUMENT_ATT_SEND_API1</b>
Regards
vijay -
Send reports as email attachment
Hi,
In the APEX application, I have a page that has filters on top and few reports generated based on the given filter values. I have a email button that when pressed, send the whole page as an email attachment. I cannot use PDF. Is it possible to send the page with few reports as email attachment?
Thanks
saruWhen you send as an e-mail, do you mean the html produced report or some sort output file? You could send it as an excel produced output.
Why can't you use a PDF option in this case?
Thank you,
Tony Miller
Webster, TX -
Hi,
when I send an report by email, a file with the *.eps extension
is attached to the mail.
how can the users open it ?
Thank youWell, after reading lots of messages about this ".eps" files
I've jumped into the conclusion that, besides what the name
means "Encapsulated Post Script", they are a complete mistery
for almost everyone. In all messages posted in these forums I've
read that "You need an Oracle product to be able to read .eps
files" but nobody mentions the product's name...
A workaround is to produce HTML output and send it like that.
Depending on the Reports version you have you can set your
report's System Parameters like this and it will do:
DESNAME : Mail Recipient (eg. [email protected])
DESFORMAT : HTML
DESTYPE : Mail
What I'm trying to figure out is how to make Reports find the
images it attaches to the HTML, 'cause it never does. If you
find out, please let me know.
Hope that helps. -
Simple code to send ALV display as XLS attachment to SAP inbox
Hi All,
Simple code to send ALV display as XLS attachment to SAP inbox.
Also i need to send only 200 records per attachement. So in this case i need send multiple attachment per mail
Thanks,
LokeshThe following code is used to send the internal table which u pass fo the ALV display to be send as excel sheet attachment
Internal table is it_attach[]
ld_email = po_email.
ld_mtitle = 'Email From Z377_EMAIL_XLS'.
ld_format = 'XLS'.
ld_attdescription = 'filename'.
ld_attfilename = 'Allot'.
ld_sender_address = ' '.
ld_sender_address_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[] = it_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 li_content 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 = li_content
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. -
Can you send slideshows as an email attachment?
can you send slideshows as an email attachment? Please provide the steps if it is possible, thank you
Yes, but you shouldn't.
Here's how.
Export the Slideshow to the FInder - a process that will make a QuickTime movie of it.
Attach that movie to the email. Send
Why not? Videos are very large files. Most Internet providers have a limit on the largest file you can send. Sending one too large means it can bounce back to you. ALso, even if the other person can receive it, downloading large files via email is slow, and can even cause crashes on some email apps on older systems.
Intead of emailing it, upload it to DropBox, YouTube, Vimeo, or any other sharing site and send the person a link.
Then they can download it themselves
Regards
TD -
What is the way to send a report through email?
Dear all
i am working with report3.0. i want to send the report through email.will aneyone plese tell me what are the steps needed to do this.
report is already generated.but when i am clicking on mail option it gives error
rep-4201 : error occured while initialize the mail subsystem.
rep-4220 : there is a problem with the mail subsystem.
thanks in adv.
dp
nullhello,
i would try DESTYPE=MAIL and the DESNAME would be the receipient.
but be aware that on windows the desname must be a valid entry in the addressbook of your mail client (restriction of some MAPI clients)
regards,
the oracle reports team -
How do I save my exported doc in order to send it as an email attachment?
how do I save my exported doc in order to send it as an email attachment?
Plug your ipod in and pull up itunes. Then click on the device name in the left hand side. Click the restore option. When it goes all the way through and says "your device has been restored and is restarting, once it restarts you want to choose the option that says "setup as a new device"
-
How to send puchase report in email ?
how to send puchase report in email ?
Search SCN, you will get lot of post for this.
Here is an example.
http://scn.sap.com/thread/321890 -
I do not know my security question answers. I send my answers send to my old email address but I cannot get into that anymore. How do I send my email to the email address I have now?
Hi RileyDP,
You will have to contact iTunes Support to get them reset:
http://support.apple.com/kb/HT5699?viewlocale=en_US
or by email:
https://ssl.apple.com/emea/support/itunes/contact.html
Cheers,
GB -
Need to send my ALV report via Email.
hi
I have this ALV report. I know I can go up to the toolbar and email the report manually to the user. But I am looking for a code to do that automatically. meaning When I run the report in the selection screen i will provide the email address and the report after its ran it should also email that (when its done manually it sends the attachment as an PDF, which i have no problem with) report as PDF.
Please help me with the code i need to use..
I tried with the following but the program crashes
CALL FUNCTION 'RFC_MAIL' DESTINATION 'LOCAL_EXEC'
EXPORTING USER = '[email protected]'
TABLES MAIL = REC.You can output the report to a spool and then convert the spool to PDF using standard FM <b>CONVERT_ABAPSPOOLJOB_2_PDF</b>. Then use FM <b>SO_DOCUMENT_SEND_API1</b> to attach the pdf data in an outgoing email.
Here is the sample codes:
*& Report ZEMAILPDF *
*& Converts spool request into PDF document and emails it to *
*& recipicant. *
*& Execution *
*& This program can be run in background or online and a spool request *
*& will still be created *
REPORT zemailpdf.
PARAMETER: p_email1 LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_sender LIKE somlreci1-receiver
DEFAULT ''[email protected]'',
p_delspl AS CHECKBOX,
p_online no-display.
*DATA DECLARATION
DATA: gd_recsize TYPE i.
* Spool IDs
TYPES: BEGIN OF t_tbtcp.
INCLUDE STRUCTURE tbtcp.
TYPES: END OF t_tbtcp.
DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
wa_tbtcp TYPE t_tbtcp.
* Job Runtime Parameters
DATA: gd_eventid LIKE tbtcm-eventid,
gd_eventparm LIKE tbtcm-eventparm,
gd_external_program_active LIKE tbtcm-xpgactive,
gd_jobcount LIKE tbtcm-jobcount,
gd_jobname LIKE tbtcm-jobname,
gd_stepcount LIKE tbtcm-stepcount,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
DATA: w_recsize TYPE i,
w_spool_nr like sy-spono.
* %_print LIKE pri_params.
DATA: gd_subject LIKE sodocchgi1-obj_descr,
it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_sender_type LIKE soextreci1-adr_typ,
gd_attachment_desc TYPE so_obj_nam,
gd_attachment_name TYPE so_obj_des.
* Spool to PDF conversions
DATA: gd_spool_nr LIKE tsp01-rqident,
gd_destination LIKE rlgrap-filename,
gd_bytecount LIKE tst01-dsize,
gd_buffer TYPE string.
* Binary store for PDF
DATA: BEGIN OF it_pdf_output OCCURS 0.
INCLUDE STRUCTURE tline.
DATA: END OF it_pdf_output.
CONSTANTS: c_dev LIKE sy-sysid VALUE 'DEV',
c_no(1) TYPE c VALUE ' ',
c_device(4) TYPE c VALUE 'LOCL'.
*START-OF-SELECTION.
START-OF-SELECTION.
* Write statement to represent report output. Spool request is created
* if write statement is executed in background. This could also be an
* ALV grid which would be converted to PDF without any extra effort
WRITE 'Hello World'.
new-page.
commit work.
new-page print off.
If p_online = 'X'.
* Processing performed when program calls itself when run online
gd_spool_nr = sy-spono.
EXPORT gd_spool_nr TO MEMORY ID 'SPOOLTOPDF'.
EXIT.
endif.
IF sy-batch EQ 'X'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
ELSE.
gd_spool_nr = sy-spono.
* If executed online, it submits a program to perform the write statements
* instructing it to create a spool request, this could be another program
* which just performs the write statements and then exports sy-spono
* to memory. But in this example it calls itself passing X to parameter
* p_online, which takes it down an alternative procesing path.
submit ZSPOOLTOPDF2
with p_online = 'X'
to sap-spool
spool parameters %_print
* archive parameters %_print
without spool dynpro
and return.
ENDIF.
* Get spool id from program called above
IMPORT gd_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
PERFORM convert_spool_to_pdf.
PERFORM process_email.
if p_delspl EQ 'X'.
PERFORM delete_spool.
endif.
IF sy-sysid = c_dev.
wait up to 5 seconds.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDIF.
* FORM obtain_spool_id *
FORM obtain_spool_id.
CHECK NOT ( gd_jobname IS INITIAL ).
CHECK NOT ( gd_jobcount IS INITIAL ).
SELECT * FROM tbtcp
INTO TABLE it_tbtcp
WHERE jobname = gd_jobname
AND jobcount = gd_jobcount
AND stepcount = gd_stepcount
AND listident <> '0000000000'
ORDER BY jobname
jobcount
stepcount.
READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
IF sy-subrc = 0.
message s004(zdd) with gd_spool_nr.
gd_spool_nr = wa_tbtcp-listident.
MESSAGE s004(zdd) WITH gd_spool_nr.
ELSE.
MESSAGE s005(zdd).
ENDIF.
ENDFORM.
* FORM get_job_details *
FORM get_job_details.
* Get current job details
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
EXCEPTIONS
no_runtime_info = 1
OTHERS = 2.
ENDFORM.
* FORM convert_spool_to_pdf *
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.
* FORM delete_spool *
FORM delete_spool.
DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
ld_spool_nr = gd_spool_nr.
CHECK p_delspl <> c_no.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
spoolid = ld_spool_nr.
ENDFORM.
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
* Send email
FORM send_file_as_email_attachment tables it_message
it_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.
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.
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[] = it_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.
<i><b>**** Points are always welcome ****</b></i> -
Need to send ALV Report as an Excel sheet via Email
Well , I need to Email an ALV Report as an Excel Sheet using my program. What do I need to do and how?
Answers will be rewarded with points.
ThanksHi Manu,
You can copy and paste the following codes and try to execute..
Hope this will help you..
note: dont forget to change 'SAPUSER' to your SAP user id.
REPORT yhn_test8 .
TYPE-POOLS: slis, slist, truxs.
DATA t5 LIKE t005t OCCURS 0 WITH HEADER LINE.
DATA fcat TYPE slis_t_fieldcat_alv.
DATA listobject LIKE abaplist OCCURS 0 WITH HEADER LINE.
DATA stack TYPE slist_listlevel_stack WITH HEADER LINE.
DATA ttxt LIKE solisti1 OCCURS 0 WITH HEADER LINE.
PARAMETER p_alv RADIOBUTTON GROUP a.
PARAMETER p_excel RADIOBUTTON GROUP a.
START-OF-SELECTION.
SELECT * INTO TABLE t5
FROM t005t
WHERE spras = sy-langu.
CLEAR : fcat, fcat[].
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'T005T'
CHANGING
ct_fieldcat = fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF p_alv = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
it_fieldcat = fcat
TABLES
t_outtab = t5
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
ELSEIF p_excel = 'X'.
CALL FUNCTION 'LIST_FREE_MEMORY'.
SUBMIT yhn_test8 EXPORTING LIST TO MEMORY AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = listobject
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc = 0.
Generate LIST for excel file
CALL FUNCTION 'LIST_TO_TXT'
TABLES
listtxt = ttxt
listobject = listobject
EXCEPTIONS
empty_list = 1
list_index_invalid = 2
OTHERS = 3.
IF sy-subrc = 0.
LOOP AT ttxt.
REPLACE ALL OCCURRENCES OF '|' IN ttxt-line
WITH cl_abap_char_utilities=>horizontal_tab.
MODIFY ttxt.
ENDLOOP.
PERFORM send_email.
ENDIF.
ENDIF.
ENDIF.
*& Form send_email
FORM send_email .
DATA docs LIKE docs OCCURS 0 WITH HEADER LINE.
DATA excelsize TYPE i.
DATA excel LIKE solisti1 OCCURS 0 WITH HEADER LINE.
DATA doc LIKE sodocchgi1.
DATA excelln TYPE i.
DATA int_objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
DATA int_objhead LIKE solisti1 OCCURS 2 WITH HEADER LINE.
DATA int_objtext LIKE solisti1 OCCURS 0 WITH HEADER LINE.
DATA int_reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
DATA bodyln LIKE sy-tabix.
DATA output_data TYPE ssfcrescl.
excel[] = ttxt[].
excel table sizes
DESCRIBE TABLE excel LINES excelln.
Body Email
int_objtext-line = 'Test Body'.
APPEND int_objtext.
DESCRIBE TABLE int_objtext LINES bodyln.
READ TABLE int_objtext INDEX bodyln.
CLEAR doc.
doc-doc_size = ( bodyln - 1 ) * 255 + STRLEN( int_objtext ).
doc-obj_name = ' '.
doc-sensitivty = 'P'.
doc-proc_syst = sy-sysid.
doc-proc_clint = sy-mandt.
CLEAR: int_objpack, int_objpack[].
int_objpack-transf_bin = ' '.
int_objpack-head_start = 1.
int_objpack-head_num = 0.
int_objpack-body_start = 1.
int_objpack-body_num = bodyln.
int_objpack-doc_type = 'RAW'.
int_objpack-obj_descr = 'Test'.
APPEND int_objpack.
CLEAR: int_objhead, int_objhead[].
int_objhead = 'Attachment'.
APPEND int_objhead.
int_objpack-transf_bin = 'X'.
int_objpack-head_start = 1.
int_objpack-head_num = 0.
int_objpack-body_start = 1.
int_objpack-body_num = excelln.
int_objpack-doc_size = excelsize.
int_objpack-doc_type = 'XLS'.
int_objpack-obj_name = 'excel'.
int_objpack-obj_descr = 'test.xls'. "File name
APPEND int_objpack.
Set Receiver
int_reclist-receiver = 'SAPUSER'.
int_reclist-rec_type = 'B'.
int_reclist-notif_del = 'X'.
int_reclist-notif_read = 'X'.
int_reclist-notif_ndel = 'X'.
int_reclist-express = 'X'.
APPEND int_reclist.
doc-obj_descr = 'Report in Excel'.
Sending Email
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = int_objpack
object_header = int_objhead
contents_bin = excel
contents_txt = int_objtext "Body
receivers = int_reclist
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.
ENDFORM. " send_email
Maybe you are looking for
-
JES MS 6.2 and Symantec Brightmail 6.0.1
We are trying to get Brightmail version 6.0.1 working on Solaris 9 with MS 6.2. Brightmail is on the same server as the MTA is running on. It doesn't look like mail is bring processed by Brightmail, when I send test messages through the MTA the count
-
How to modify the table control?
Hi all, How to modify the table control after setting the lines = 1. ie tbl_ctr-lines = 1.(tbl_ctr is the table control). Can anyone explain this with an example? Thanks.
-
NavigateToURL() POST Method...
I am trying to submit data to an ASP page via the navigateToURL() POST method, but when I try to reference the request variable.. it is blank. Any ideas what I am doing wrong? script: var url:URLRequest = new URLRequest(" http://www.mydomain.com/test
-
Where is Background Color Property for Text Field Prompt in Developer 6i
I update all my works from developer 2000 to developer 6i (forms 6.0). All my screens are now irregular becoz, the text field prompt background color property is not present in forms 6i. Can you help me how to solve this prob. (one more solution i fo
-
Will the Apple Store replace my iPhone 5s for free if the screen is lifting up on its own?