Skip to Content

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


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.

Add comment
10|10000 characters needed characters exceeded

3 Answers

  • Best Answer
    Posted on Jan 14, 2019 at 10:18 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 14, 2019 at 09:33 AM

    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
    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 11, 2019 at 08:31 AM

    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 control the job programatically (not through sm36,sm37) (a new job).

    Add comment
    10|10000 characters needed characters exceeded

    • 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?->