Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to send job log of an already scheduled job via email?

0 Kudos

Hello,

I have a Z program which is already scheduled to run everyday. The requirement is to send the job log and job spool as soon as this job is run via email.I already have the code ready with me to send job spool via emal.

My questions are:

1) If I use FM BP_JOBLOG_READ, it asks for job count which I will have to fetch via FM JOB_OPEN. But doesnt JOB_OPEN schedule a job? I already have a job scheduled. I just need the job count.

2) Should I fetch the job log and send mail in the same Z program or should I create a new report via se38 and then add the new report as my next job step in sm37?

Thanks and Regards,

Farzeen Khan.

1 ACCEPTED SOLUTION

Hello everyone,

Thanks for you valuable comments. I found the solution.

I used GET_JOB_RUNTIME_INFO to get the jobcount. After that I created a FM in which job log is fetched using BP_JOBLOG_READ (passed jobcount as received from FM GET_JOB_RUNTIME_INFO) and mail is sent using FM SO_NEW_DOCUMENT_ATT_SEND_API1.

I called this FM in update task and then did commit work.

5 REPLIES 5

DoanManhQuynh
Active Contributor

1. For scheduled job, i think you can read job count from table TBTCO then you dont have to open job to get job count.

2. I think its better to separate it. if you want to do it in one go, then you have to go back to use fm JOB_OPEN...to control the job programatically (not through sm36,sm37) (a new job).

0 Kudos

So according to your answer:

If I want to code in the same program, I will have to use FM JOB_OPEN. Then what about the job that is already scheduled? Should I delete that job?

If I want a new report, should it be like this?->

JOB_OPEN

SUBMIT ZPROGRAM

BP_JOBLOG_READ

JOB_CLOSE

Sandra_Rossi
Active Contributor
0 Kudos

Note that when you schedule a job, you may enter an email, and the spool files will be sent automatically. But not the job log (probably because it's more technical stuff).

raymond_giuseppi
Active Contributor

So your job is already scheduled and periodic, I suppose, so each execution will get its own count number.

So you could (non-exhaustive list)

  • Look, in another job, for the last executed job based on jobname (table TBTCO or a FM such as BP_JOB_SELECT)
  • Add another step to your job (or add the code at end of your program) there you get the jobcount with a FM such as GET_JOB_RUNTIME_INFO

Hello everyone,

Thanks for you valuable comments. I found the solution.

I used GET_JOB_RUNTIME_INFO to get the jobcount. After that I created a FM in which job log is fetched using BP_JOBLOG_READ (passed jobcount as received from FM GET_JOB_RUNTIME_INFO) and mail is sent using FM SO_NEW_DOCUMENT_ATT_SEND_API1.

I called this FM in update task and then did commit work.