cancel
Showing results for 
Search instead for 
Did you mean: 

Mail based on event raise

Former Member
0 Kudos

Hi guys,

New to SAP CPS, but need help in setting up the mail alerting based on following scenario:

Job chain contains 3 jobs: job_a, job_b, job_c. Custom mail definition is job_mail.

Path flow job_a->job_b->job_c.

Now in the chain flow, let us assume job_a works fine, job_b fails, the customer scenario is such that even if the job_b fails, the job_c should run. But job_b on error status should raise event say “EV_SendEmail”. My custom defined job_mail runs on wait event "EV_SendEmail" should run on the raise of this event. The job currently runs, sends out the email, but sends the job log and the job id of this job “job_mail”. Not the job_b’s id or the job_b’s log file.

How do I make this scenario work?

Accepted Solutions (1)

Accepted Solutions (1)

nanda_kumar21
Active Contributor
0 Kudos

an easier way would be, create a small job chain:

Step 1  - Job b

Step 2 - mail_send on job b failure (relative job = setp 1, job 1; file = *)

Now if step 1 fails, set the status handler to move to step 2, but if it completes, mark the job chain complete.

Now add this small chain intead of job_b in the big job chain.

In bigger job chain, the step where you added the small chain, set all the status handlers to move the Job_c, irrespective of whether small chain is success or error.

Thanks

Nanda

Former Member
0 Kudos

Hi Nanda,

What you say makes sense if the job chain is small. But there is a very big job chain(nearly 50 steps and 50 jobs). If the customer wants alerting for each job in the job chain, then i have to create 50 small job chains in that big job chain and for each job, i have to have add a mail_send job to send the mail notifications. So, my job chain size would be (nx2) where n is the number of jobs in job chain.

I suggested this, but then the stakeholders told this is not going to make sense, hence wanted it through an event.

Warm regards,

Pavan

nanda_kumar21
Active Contributor
0 Kudos

In that case,create a custom mail job in HTML format if you would like.

Now, create a parameter(constraint as expression) for that job, say PARENTJOBID and set the default value to


=waitEvents.name.raiserJobId

Now use this parameter in your mail body or subject, which will automatically be populated by the job that raised the event.

Similarly you can attach the files for the same job by mentioning under attachments like:


[Attachments]

Job $PARENTJOBID:*

thanks

Nanda

Former Member
0 Kudos

Hi Nanda,

I had actually tried your suggestion, it did not work(My source html had a syntax bug). But after what you told, I modified my source, now it gives me this error. Not sure where I am missing "=".

If you could let me know this, it would be great!

Screenshots are below.

I tried it like this:

Mail job source:

Event definition:

Job definition to raise event:

Error in CPS

Warm Regads,

Pavan

h_carpenter
Active Contributor
0 Kudos

Hi Pavan,

Yes, Nanda did an excellent job and, you forgot an = on your jobfile line (line 11, not 12)

Try this:

[Attachments]

job-@{name}.txt=${jobid}:*

instead of

[Attachments]

Job $jobid:*

Regards,

HP

Former Member
0 Kudos

Hi HP,

Thanks, yours did the trick.

@Nanda: Thanks for the excellent help given, you helped me iron out my main flaw!

Just one last question, could you guys let me know if JobName gives me JobName, or is there any other variable in the jobcs class, so that I can get the JobName as well. Also, if you have the class definition of the class containing jobId, please do share here, so that I can check them out and write some custom script! Thanks a lot!

Warm Regards,

Pavan

h_carpenter
Active Contributor
0 Kudos

Hi Pavan,

Please check out this: https://[::]:53000/scheduler/help/modules/mail/custom_mail.html

You might have to specify a different server and port, that help files lists the variables you have.

You can use the ${jobname} as follows::

job-${jobname}-file@{name}.txt=${jobid}:*

Regards,

HP

Answers (0)