Mail trigger - Background job
Hi Experts,
I have faced one problem in Mail Triggering. to the User.
Our Requirement is,
Whenever we execute one report ( ALV output) in Background , The Output should go the user thro mail ( automatic Mail trigger when the background Job is finished)
if anybody knows, plz guide me to do it.
With Regards,
Mahesh.
Hi Dude,
Execute This Program as it is.UR requirement will be full filled .
Here the important Thing is the FM 'SO_NEW_DOCUMENT_ATT_SEND_API1'
tables
packing_list = it_packing_list
contents_txt = it_message
receivers = it_receivers
Hope this Code helps U.
*& Report ZSENDMAIL
report zsendmail.
parameters: psubject(40) type c default 'Testing'.
PUSH BUTTON
data: it_packing_list like sopcklsti1 occurs 0 with header line,
it_contents like solisti1 occurs 0 with header line,
it_receivers like somlreci1 occurs 0 with header line,
it_attachment like solisti1 occurs 0 with header line,
gd_cnt type i,
gd_sent_all(1) type c,
gd_doc_data like sodocchgi1,
gd_error type sy-subrc.
data: it_message type standard table of solisti1 initial size 0
with header line.
*START-OF-SELECTION.
start-of-selection.
perform populate_message_table.
*Send email message, although is not sent from SAP until mail send
*program has been executed(rsconn01)
perform send_email_message.
*Instructs mail send program for SAPCONNECT to send email(rsconn01)
perform initiate_mail_execute_program.
*& Form POPULATE_MESSAGE_TABLE
adds text to email text table
form populate_message_table.
data : itab type table of sflight with header line.
data : lv_itab(255) type c.
select carrid
connid from sflight into corresponding fields of table itab
where carrid = 'LH' and connid = '0400'.
loop at itab.
write : / itab-carrid , itab-connid.
concatenate itab-carrid itab-connid into lv_itab separated by space.
append lv_itab to it_message.
endloop.
endform. " POPULATE_MESSAGE_TABLE
**& Form SEND_EMAIL_MESSAGE
*send email message
form send_email_message.
*fill the document data.
gd_doc_data-doc_size = 1.
data: tab_lines like sy-tabix.
describe table it_message lines tab_lines.
read table it_message index tab_lines.
gd_doc_data-doc_size = ( tab_lines - 1 ) * 255 + strlen( it_message ).
**POPULATE the SUBJECT/GENERIC message ATTRIBUTES
gd_doc_data-obj_langu = sy-langu.
gd_doc_data-obj_name = 'SAPRPT'.
gd_doc_data-obj_descr = psubject.
gd_doc_data-sensitivty = 'F'.
**describe the body of the message
**information about structure of data tables
clear it_packing_list.
refresh it_packing_list.
it_packing_list-transf_bin = space.
it_packing_list-head_start = 1.
it_packing_list-head_num = 0.
it_packing_list-body_start = 1.
describe table it_message lines it_packing_list-body_num.
it_packing_list-doc_type = 'RAW'.
append it_packing_list.
**add the recipients email address
clear it_receivers.
refresh it_receivers.
it_receivers-receiver = 'KRK'. "p_email.
it_receivers-rec_type = 'B'.
it_receivers-com_type = 'INT'.
it_receivers-notif_del = 'X'.
it_receivers-notif_ndel = 'X'.
append it_receivers.
it_receivers-receiver = 'OBT'. "p_email.
it_receivers-rec_type = 'B'.
it_receivers-com_type = 'INT'.
it_receivers-notif_del = 'X'.
it_receivers-notif_ndel = 'X'.
append it_receivers.
**CALL the fm TO post the MESSAGE to sapmail
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
exporting
document_data = gd_doc_data
put_in_outbox = 'X'
importing
sent_to_all = gd_sent_all
tables
packing_list = it_packing_list
contents_txt = it_message
receivers = it_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.
**store function module return code
gd_error = sy-subrc.
**GET it_receivers return code
loop at it_receivers.
endloop.
endform. " SEND_EMAIL_MESSAGE
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
**instructs mail send program for sapconnect to send email.
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
Similar Messages
-
Dear All,
We have a background job, which will execute a z program. The out put of Z program will be sent as a mail to the recipient listed in "Spool list recipient" (SM36).
We did unicode conversion and upgrade to ecc 6.0.
Even now background job send the out put to mail, but when we open the attached html file in the mail which contains the out put, it displaying with junk characters.
Out put looks like " æ¼â¾â¼¼ã¹¢â¼¼æ½¦ç®ã° "
Your help will be highly appriciated.
Thanks and regards
Josephhi check this...
Save Report Output to a PDF File
This report takes another report as input, and captures the output of that report. The output is then converted to PDF and saved to a local file. This shows how to use some of the PDF function modules, as well as an easy way to create PDF files.
One thing I am not thrilled about is how the spool number is retrieved. If anyone has any better method, please let me know! Until I actually have a production use for a program like this, I will not try to find a better way.
Source Code Listing
report zabap_2_pdf.
*-- Enhancements: only allow to be run with variant. Then called
*-- program will be transparent to users
*-- TABLES
tables:
tsp01.
*-- STRUCTURES
data:
mstr_print_parms like pri_params,
mc_valid(1) type c,
mi_bytecount type i,
mi_length type i,
mi_rqident like tsp01-rqident.
*-- INTERNAL TABLES
data:
mtab_pdf like tline occurs 0 with header line,
mc_filename like rlgrap-filename.
*-- SELECTION SCREEN
parameters:
p_repid like sy-repid, " Report to execute
p_linsz like sy-linsz default 132, " Line size
p_paart like sy-paart default 'X_65_132'. " Paper Format
start-of-selection.
concatenate 'c:\'
p_repid
'.pdf'
into mc_filename.
*-- Setup the Print Parmaters
call function 'GET_PRINT_PARAMETERS'
exporting
authority= space
copies = '1'
cover_page = space
data_set = space
department = space
destination = space
expiration = '1'
immediately = space
in_archive_parameters = space
in_parameters = space
layout = space
mode = space
new_list_id = 'X'
no_dialog= 'X'
user = sy-uname
importing
out_parameters = mstr_print_parms
valid = mc_valid
exceptions
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 3
others = 4.
*-- Make sure that a printer destination has been set up
*-- If this is not done the PDF function module ABENDS
if mstr_print_parms-pdest = space.
mstr_print_parms-pdest = 'LOCL'.
endif.
*-- Explicitly set line width, and output format so that
*-- the PDF conversion comes out OK
mstr_print_parms-linsz = p_linsz.
mstr_print_parms-paart = p_paart.
submit (p_repid) to sap-spool without spool dynpro
spool parameters mstr_print_parms
via selection-screen
and return.
*-- Find out what the spool number is that was just created
perform get_spool_number using sy-repid
sy-uname
changing mi_rqident.
*-- Convert Spool to PDF
call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
exporting
src_spoolid= mi_rqident
no_dialog = space
dst_device = mstr_print_parms-pdest
importing
pdf_bytecount = mi_bytecount
tables
pdf = mtab_pdf
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.
call function 'DOWNLOAD'
exporting
bin_filesize = mi_bytecount
filename = mc_filename
filetype = 'BIN'
importing
act_filename = mc_filename
tables
data_tab = mtab_pdf.
FORM get_spool_number *
Get the most recent spool created by user/report *
--> F_REPID *
--> F_UNAME *
--> F_RQIDENT *
form get_spool_number using f_repid
f_uname
changing f_rqident.
data:
lc_rq2name like tsp01-rq2name.
concatenate f_repid+0(8)
f_uname+0(3)
into lc_rq2name separated by '_'.
select * from tsp01 where rq2name = lc_rq2name
order by rqcretime descending.
f_rqident = tsp01-rqident.
exit.
endselect.
if sy-subrc ne 0.
clear f_rqident.
endif.
endform." get_spool_number
regards,
venkat . -
Hi All,
We need to schedule a Job in background in every 30 min or 1 hr, which will monitor all the other Jobs running in background.
If any job is running more than 30000 sec, it should trigger an email.
Please guide me how to achieve this( i'm ABAPer).
Regards
VEnk@see the following t.code may be it will use
SWWCLEAR_INSERT
Workflow: Background Job 'SWWCLEAR';
Workflow: Hintergrundjob 'SWWCLEAR';
Workflow : job arr.-plan 'SWWCLEAR';
Workflow: achtergrondjob 'SWWCLEAR'
Workflow: Background Job 'SWWCLEAR'
SWWCOND_INSERT
Workflow: Background Job 'SWWCOND';
Workflow: Batchjob 'SWWCOND';
Workflow : job batch 'SWWCOND';
Workflow: achtergrondjob 'SWWCOND'
Workflow: Background Job 'SWWCOND'
SWWD
Maintain Work Item Error Monitoring;
Workitem-Fehlerüberwachung pflegen;
Gérer surveillance erreurs WI;
Workitem-foutbewaking verzorgen
Maintain Work Item Error Monitoring
Edited by: Krupaji on Feb 17, 2010 12:45 PM -
E-mail sending background job diappeared in the system
Hello Gurus,
We have one e-mail sending job in our production system. The frequency of the job is daily. Now we are not able to find the sheduled/Released/Active/Finished/Canceled status for this from the last 2 days.
Please help me to get back the job in the system.
Thanks in advance.
Thanks & Regards,
ASkHi,
Logon to the client from which the mails should be send, go to TA SCOT then choose menu: view -> jobs, you can also reschedule if required.
Or check via utilities when the mails were sent. -
Send mail from background job scheduling
Hi All,
I am facing one problem in which i have one standard transaction code COOIS for which there is no userexit.
we have to run this in background get the output in excelsheet and then mail the excel output to individual.
Please help me out.
Points wil be rewarded for sure.Hi
This is the sample code previously I achieved the same requirement.
FORM send_mail_2 USING msgid msgno msgv1.
mailuser oder Gruppe like sy-uname default 'Ruckerk'.
DATA: express_hold_time LIKE sovaltime.
DATA: text LIKE sotxtinfo.
DATA: receiver LIKE somlreci1 OCCURS 0 WITH HEADER LINE.
MESSAGE ZF100 (FTP an UDB fehlgeschlagen)
text-msgid = msgid.
text-msgno = msgno.
text-msgv1 = msgv1.
text-msgv2 = ' '.
text-msgv3 = ' '.
text-msgv4 = ' '.
express_hold_time
express_hold_time-days = 01.
express_hold_time-h_min_sec = 240000.
receiver
receiver-receiver = mreceivr.
Gruppe von Empfängern
receiver-rec_type = 'C'.
und Expressmeldung ausgeben
receiver-express = 'X'.
APPEND receiver.
CALL FUNCTION 'MESSAGE_SEND_AS_MAIL'
EXPORTING
msgid = text-msgid
msgno = text-msgno
msgv1 = text-msgv1
msgv2 = text-msgv2
msgv3 = text-msgv3
TABLES
receivers = receiver.
IF sy-subrc <> 0.
WRITE:/ 'hat nicht geklappt', 'SY-SUBRC =', sy-subrc.
ENDIF.
PERFORM print_error_report.
Fehlermeldung zum Abbrechen des Report's ausgeben.
MESSAGE e398 WITH 'Jobabbruch' msgv1.
ENDFORM. " SEND_MAIL_2
Regards,
kumar -
How to trigger a mail once BG job finished.
Hi,
Could anyone please let me know how to trigger a mail once Background job finished. I let you give one scenario where exactly I require this concept. Say, I execute t.code MB52 with particular variants in background to find stuck qty(s) of material(s) in given site(s).Now I want that system will trigger a mail to concern team once job finished.
Thanks,
AKYou can try using workflow transaction SBWP.
you need to create a distibution list in the above transaction and add the requested mail ids to it.
then when you create a jon using transaction SM37 you have the option SPOOL LIST RECIPIENT where you can add the created distibution list
so when ever the job has run sucessfully then a mail is sent to all the mail id's in the list.
hope this helps.
cheers
sundeep -
Trigger a background job after executing tcode MMPV
Hi All,
I would like to trigger a background job after executing tcode MMPV. In MMPV, after closing a particular period and entering
new period, the transaction will be saved. After saving, the background job should be triggered. How to do it?
Regards,
VinodDepending what system you are on your best bet would be to create an enhancement point inside a form, that is called after the save has been performed, and raise an event within that form.
Events can be used to trigger background jobs are maintained in transaction SM62.
Cheers. -
What is the best solution to trigger background jobs within user exits?
Currently the method I am using is quite cumbersome.
1. Create user event in SM62
2. Create background job attached to this user event.
3. Within user exit call function module BP_EVENT_RAISE using user event.
The problem I have with this approach is that in the program I have to add a 15 - 20 sec delay to handle record locking. Lets say I am in a user exit in MM02, triggering this event without the delay can lead to no records been processed.
What are other ways of implementing this solution?
Can I do a SUBMIT report VIA JOB
or CALL FUNCTION IN UPDATE TASK.Try this way also.
In the userexit update a custom table with document number + flag (pending for process)
Create standalone program that to be scheduled like every 5 minutes (as you like ) search for this table and get all open documents (with flag eq space ) and process one by one.( Calling jobs)
This will reduced number of repetative background jobs
Say User A edit document 100 at 10.00 am and saves at 10.01 am and user B edit document 100 at 10.02 am and save it
10.03 am ( so every save if you trigger a backgound job, unncessary create jobs for same document number 10 )
a® -
Trigger mail for cancelled background jobs scheduled using SM37
Dear Experts,
My requirement is to trigger email whenever a job gets cancelled in background.
For this I have already tried creating a workflow using BO BPJOB for event ABORTED.
But for some reason the event is never getting triggered.
I tested executing the workflow from tcode SWDD, it was running successfully, which means that there is no issue with my workflow.
Now I want to resolve the above issue OR
I want to raise the event manually from the program through some BADI or Exit.
But I didn't find any BADI or Exit for tcode SM37. Can anybody let me know if any.Hi,
Please refer the below links.
Workflow- Background job fail
Re: Send mail when job fails
Regards
GK.
Moderator message: please do not post just links without any further explanations.
Edited by: Thomas Zloch on Sep 20, 2010 11:53 AM -
Trigger mail when backgroung job is cancel
Hi,
I want to trigger a mail to outlook when background job in sap gets cancel
Regards
GopalHi Gopal
Have u read through [This|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/97d2e8b3-0b01-0010-b787-b8ce558a51c2] document? -
Automatic Mail not getting generated through background job
Hi Experts,
We have set up a job variant with spool recipients. We are getting the automatic mail if the job is getting finished successfully. But we are not getting the automatic mail if the job is in cancelled status. Earlier we used to get the mail even if the job is in cancelled status. We are not sure if there is any setting which would restrict the automatic mail based on the job status.
Appreciate your help in this regard.
Thanks and Regards,
Ranjani.Hi,
Just for a work around, try checking the SAP user inbox for the user who has scheduled the background job.
I don't there is any seperate configuration in Spool List Recipient for the canceled jobs. We need to confirm that the email ids provided in the Spool List recipient are correct and the background job creates a spool request even if it is canceled.
Also if possible try deleting the existing background job and create a new background job with the same parameters and valid email id's maintained in the Spool List recipient.
OR
Without deleting the existing background job, parallely create a new background job with the same parameters and valid email id's maintained in the Spool List recipient. If it works then delete the old background job.
Thanks
Harish -
Background job schedule and mail triggering
Hi Experts,
I schedule a background job to run a custom program for project closure.The job is running successfully. But,the mail I am getting from this job run is same all the time (means it's showing same project closure again and again though I am running job for different projects). Is it some bug in our custom program or any parameters required to be check in job schedule?
Kindly suggest.
Thanks & Regards
SaurabhYes. That is the point I am missing. Just one 'date' is checked and project is taken into account for the custom program and after its successful run the mail is sent to users.
And when the same program I am assigning in SM36,it is actually running the program accurately for project/s but sending the same mail which it send for very first project earlier.
Can you please guide me on the way to create these variants?
You will need to Save different variants for different projects and then assign the variants with your job.
Will it be required to create variant again and again and assign different projects individually? As, we are not sure that which project is gonna be created in future. So, need guideline how these variants can help me to sort out the e-mail issue.
Regards
Saurabh -
Reg: Error in Mail sending through background job in SCOT
Hello experts,
I am trying to schedule a background job through SCOT so as to send the mails present in SOST.
The job is running but it is giving error as "Invalid status for recipient" in SOST.
But when I am sending it directly from SOST it is delivered without any errors. The email address is maintained correctly and SMTP settings are also correct as while sending it directly from SOST it reaches the required recipient without any error.
This error is observed only through background job. I am using program RSCONN01 with variant SAP&CONNECTINT in background job.
Kindly suggest why I am getting the error "Invalid status for recipient" in background job.
Thanks & Regards
Meraz
+91 8894522860I am getting the exact same issue.
were you able to fix this in the last 3 weeks?
thanks. -
Inbound IDoc creating background job even for trigger immediately setup
All,
I have a very serious problem in our production system.
Scenario:
Vendor is chagend in system A (Outbound) and the same is interfaced to System B (Inbound) and i am using trigger immediately option, but still I am seeing a background job is created for 'RBDAPP01' and creating the spool request. The issue is I am sending 1000 of idocs and the spool number is increasing daily in system B.
So, can any one explain me why the background job is getting triggered even though I set the partner profile settings as 'Trigger Immediately'.
The above issue is not happening in our quality system it simply updagtes vendor information in system B with out creating any background job. Please note that the same settings are maintained in both the systems.
Your immediate inputs are really valuable for me.
Regards,
SumanThis is an performance issue on the receiving system. In case the system does not have enough resources to process the IDoc immediately it will always schedule a background job to ensure the processing of data.
You need to check whether the system has enough work processes available during the time when 1000 of IDocs are received or send the IDocs in packages with some time in between.
Regards,
Kai -
Convert Spool to PDF and mail for the jobs not run in background.
Dear All,
I need to convert the spool job into pdf and mail as attachment for job not run in background.
I am printing the bills using the program SD70AV3A to print the bills in a batch using the SUBMIT.
But i am not using the spool options since its going to into waiting state in spool...and i need to change the printer properties to G
to get the printer to print the reports as these jobs run in backgroud....but this solution is not acceptable solution.
SUBMIT SD70AV3A
WITH RG_KSCHL-LOW = 'ZRR'
WITH RG_NACHA-LOW = '1'
WITH PM_VERMO = '2'
WITH PM_NSORT = '1'
WITH RG_VBELN IN range.
* TO SAP-SPOOL
* SPOOL PARAMETERS print_parameters
* WITHOUT SPOOL DYNPRO
* VIA JOB name NUMBER number
* AND RETURN.
so how do i get the spool number from the above after the job is submitted....and then convert into pdf and mail
please suggest some solution. I have searched on net but most the solutions are say to run the job as background job...
i have also looked into the program RSTXPDFT4 but it asks for the spool id ....how can i get spool id for the job that has been completed.
please suggest some solution.
Thanks
Bhargava.Hi,
Spool to PDF : FM 'CONVERT_ABAPSOOLJOB_2_PDF'
Table TSP01 to get spool number
You ,may need to convert OTF to PDF: FM CONVERT_OTF
and the to binary : FM 'SMCS_XSTRING_TO_BINARY'
To send mail use class: cl_document _bcs.
Regards,
Maria João Rocha
Maybe you are looking for
-
Removing a page from a pdf in preview?
I scanned some documents into a pdf, but accidentally scanned the same document twice. Is there a way to remove that one duplicate page without having to rescan a whole new pdf file?
-
Problem with report with filter from other query
Hi All, I have some report with two queries: 1. First contain Date(1) converted to int (like 20140807). This query calculate Date as getdate minus number of day which I could define (for example -8 return getdate minus 8 days). 2. The second contain
-
How do I change my email for login?
Email login now will go away soon..how do I change without resetting firefox?
-
Clarify Camera Raw 3.7 vs. 5.2 differences
What is the difference in they ways that Camera Raw 3.7 will convert a RAW file versus 5.2? Are the differences purely in the functionality and UI or does 3.7 do a materially poorer job at conversion? If so, in what way?
-
Hi all, i want to add a second controller to an existing one. So, i have to build the same wlans with the same ssids and PSKs. How can i view (or copy without having to view them) the PSKs stored in the first WLC in order to use them in the second al