cancel
Showing results for 
Search instead for 
Did you mean: 

How to receive mail Alerts from CPS?

Former Member
0 Kudos

Hi Experts,

Need help on receiving alert mail from CPS.

I do not even want the log files. Just need a alert if a job goes to ERROR status.

As far as I analysed, I got to now that we have to submit the definitions System_Mail_Configure and System_Mail_Send with  the necessary details.

But though I tried, I did not get any mails.

Can you help me out in filling the below blanks.

In the job definition System_mail_configure.

Help me in filling the below.

Below question might sound silly but please bear.

Can I give "DETECT" in From and give any email ID in Server (gmail or my company's mail id)?

Similarly, In the job definition System_mail_Send

Help me in filling the below.

My assumptions:

To: My mail id

Subject: Job failure Alert CPS

Text : ---------

Relative Job: Should I give the job chain name/Job name?

Job File: What should I provide here?

Server And From: Can I give same details as provided in System_Mail Configure?

After all this, should I submit these two, first CONFIGURE job and second SEND job?

Many thanks in advance!!

Thanks

Ramakrishnan R

Accepted Solutions (1)

Accepted Solutions (1)

nanda_kumar21
Active Contributor
0 Kudos

Hey Rama,

Just adding to what HP already mentioned,

  1. The Mail configure job is run only once for a redwood system to define the SMTP server address. You don't have to run it again, or mention the same parameters in System_Mail_Send job.
  2. Only "to" field is mandatory in system_mail_send job (rest all optional). You can fill the Server and From address if you want to use an SMTP server different from the one that is already configured using Mail configure job.
  3. Login to the operating system of the CPS system and ping & telnet the mail server and confirm that connection is OK.
  4. If you want a mail alert, everytime a job fails, then you have to create a job chain for every single job you have and follow the method HP mentioned.
  5. Always use a distribution list for the "to" address. That way, when some one leaves the company tomorrow, you don't have to edit thousands of job chains to remove one single mail address.
  6. I would rather buy Alerting module. Because this basic alerting is time consuming work. If you have jobs that run in parallel in a job chain (which means they are withing a single step), then you will have to make each of them a job chain, then include those small chains inside the bigger chain.
  7. Also, this basic alert doesn't include a lot of required information about the job. When there is a change in sequence of the steps, then again you will have to rearrange the mail alert steps

thanks

Nanda

Answers (5)

Answers (5)

Former Member
0 Kudos

@ Nanda and HP:

I am scheduling the system_mail_send job under the same step of the job that  want to get alerts.

Hence I will not be able to use Status Handlers right?

Do you suggest me to create a new step for System_mail_send?

I tried doing this and I am able to get all the logs. I gave * in Job file.

Many thanks for your help.

I could not have done this without your help

Regards,

Ramakrishnan R

h_carpenter
Active Contributor
0 Kudos

I am scheduling the system_mail_send job under the same step of the job that  want to get alerts.

No, do not do that, it will never work. Jobs in a step are executed in parallel, which means the mail job will not be able to get the file since it is not yet finished being created. Put the Mail job in a separate step that is executed AFTER the job that generates the file.

Regards,

HP

nanda_kumar21
Active Contributor
0 Kudos

Hi ramakirshnan,

Since you are beginning to explore SAP CPS, i highly recommend the admin guide. It has all these information with easy examples. The above tests that we suggested, all are in the guide.

Also it has methods of improving this basic emailing mechanism to a better alerting tool using REL and Redwood scripting.

Thanks

Nanda

Former Member
0 Kudos

Thanks nanda.

Will surely read through

Regards,

Ramakrishnan R

Former Member
0 Kudos

Hi and http://scn.sap.com/people/nanda.kumar21

Many thanks..

Finally managed to receive mails.

I'm getting the subject, and Text of the mail.

But i'm not getting the job log.

Most of the jobs does not create Spool but atleast I would require the Job log file.

And how do I make sure that I get alerts only for job in KILLED or ERROR status.

The mistake I made was that instead of creating a new job under a step inside the job chain, I was running the System_mail_send job directly from the Definitions

Please help me for getting the job log as an attachment in my mail.

Regards

Ramakrishnan R

nanda_kumar21
Active Contributor
0 Kudos

Just put * for the field Job File in System_mail_send. This will attach all the file outputs of a job to the mail.

Thanks

Nanda

Former Member
0 Kudos

Hi Nanda,

I tried,

*

stderr

stderr.log


All the three is not giving results


These above should also be entered inside the job chain only right, because I did that only.


Regards

RK

nanda_kumar21
Active Contributor
0 Kudos

Yes, everything in a job chain.

Step 1 - job you want to monitor

step 2 - system_mail_send

Which job did you try in step 1?

Are you seeing any log for the job in step 1?

What is the name of the log? Also let us know what version of CPS are you using?

Thanks

Nanda

Former Member
0 Kudos

Hi Nanda,

Understood the below.

"Yes, everything in a job chain.

Step 1 - job you want to monitor

step 2 - system_mail_send".

Which job did you try in step 1?

Are you seeing any log for the job in step 1?


PFB job name and Log of Job in below screenshot.



Name of the log is joblog.log and i tried using that in Job File.


Also I tried joblog (without .log).


But no positive results.


We are using the version - M33.85-65736


Regards,

Ramakrishnan R


nanda_kumar21
Active Contributor
0 Kudos

try *.log

thanks

Nanda

nanda_kumar21
Active Contributor
0 Kudos

...also you can use the status handlers(located on right side when you select step 1) on step 1 to set the job chain execution to proceed to step 2 only the if the job in step 1 is killed or in error.

For other status, set the handler to mark the job chain as completed.

Thanks

Nanda

h_carpenter
Active Contributor
0 Kudos

Hi again,

Please show us the diagram of your failed job chain run so we can see what is wrong, * means all JobFiles of the job and works for me.

As for handling Error and Killed jobs, as Nanda pointed out, use status handlers.

Regards,

HP

Former Member
0 Kudos

Hi Nanda,

Still its not working.

Is there any other prerequisite that needs to be addressed.

Also how do I restrict mails only to jobs that are in error status.

If I get mails for all jobs (completed status) it will be too difficult to handle the mails.

Please suggest.

Regards

Ramakrishnan R

Former Member
0 Kudos

Hi HP,

Please find screenshots below.

Also Job chain's diagram below.

I am shading out my company's names in  the screenshots as I am not sure whether this kind of screenshot sharing is allowed in my company.

@ Nanda and Hp:

I am scheduling the system_mail_send job under the same step of the job that  want to get alerts.

Hence I will not be able to use Status Handlers right?

Do you suggest me to create a new step for System_mail_send?

Regards,

Ramakrishnan R

Former Member
0 Kudos

Hi and http://scn.sap.com/people/h.carpenter,

Many thanks for detailed replies.

I will be trying your suggestions on wednesday (pls bear the delay).

Will get back immediately with my results.

In the meanwhile I tried to run System_Mail_send without any Relative job.

But I got some issues like could not detect SMTP server and port 25 is blocked.

Am not sure if the above line is exact but that is the message it conveyed.

If It did not accept my Company's mail id, can I do something in CPS and correct that or is there now way where I can get mails to my company mail Id?

Thanks

Ramakrishnan R

h_carpenter
Active Contributor
0 Kudos

Hi Ramakrishnan,

The CPS server needs to be able to connect to your SMTP server. Please try

telnet <mail_server> 25

That should connect, if it does not work, you get an error message. My expectation is that it will fail, see with your network administration team - most likely it is a firewall.

As for the relative job issue, which version are you running ?

Also, please inspect the following:

Note: I have left out Server, because I want to use the default. I have deleted the from and to addresses (first and last):

Subject: Test

Text: Test info

Result: I received an email with the output of System_Info (Step 1, Job 1)

Regards,

HP

Message was edited by: h. Carpenter Added job chain diagram image

Former Member
0 Kudos

Hi Both,

Thanks for helping me.

But i'm still stuck at this part.

Relative Job: Step 1, Job 2 <<- the job number 2 of step named "Step 1" in the job chain


For example,


Job Chain: TEST_JOB


Step 1:

Job Name: TEST_RK


now, in Relative job, what should I give?


Option 1: Step 1, TEST_RK


Option 2: TEST_RK


Or, are both options wrong?


Thanks

Ramakrishnan R

Former Member
0 Kudos

Hi All, , ,

I actually tried doing the above two options and got the below errors.

Relative Job: Step 1, Job Name



Relative Job: Job Name


Please suggest.


Regards,

Ramakrishnan

h_carpenter
Active Contributor
0 Kudos

Hi Ramakrishnan,

Ok, you are almost there ... the syntax is: <step_name>, Job <job_number>

For example: "Step 1, Job 1" or "Data Retrieval, Job 2" ...

You are specifying "Step 1, <Some name I cannot see because you have hidden it ;-)>"

So, assuming your step is named Step 1, and you want the first job of step 1, try:

Step 1, Job 1

Regards,

HP

Former Member
0 Kudos

Hi HP,

Thanks. But still I am facing issues.

By the syntax is: <step_name>, Job <job_number>

I am giving Step 1, Job ID (took from a already failed instance).

I'm giving you screenshots of my job definition below.

Can you please provide me the syntax.

Step Name

Job Name

The job id that I gave was based on the earlier failed Job ID's.

Please help

Regards,

Ramakrishnan R

h_carpenter
Active Contributor
0 Kudos

Hi Ramakrishnan,

Ok, please try "Step 1, Job 1".

Note that you can also specify "Job 123456" without Step, but that is not really what you want because you would have to fill the parameter with the job id ... Your step has 1 job, so that job is "Job 1".

See attached image, imagine you have 3 jobs in Step 1, you would specify the relative jobs as follows:

Step 1, Job 1

Step 1, Job 2

Step 1, Job 3

This is really powerful, because it automatically looks up the job id under the hood. Note that if you delete Job 2 in the above example, Job 3 will become Job 2 -> watch out when you delete a job from the step because it will not update "Relative Job" expressions automatically.

Regards,

HP

Former Member
0 Kudos

Hi HP,

I tried many different combinations, like

Step 1, Job name (custom job name)

Step 1, Job 1

Step 1, Job id

job name

Job name, Job chain name

Job Chain name

Job id alone,etc

But in all of them I got error message saying "Cannot find parent step".

Please help.

Regards,

RK

h_carpenter
Active Contributor
0 Kudos

which version are you running, this is weird ...

nanda_kumar21
Active Contributor
0 Kudos

Hi Radhakrishnan,

Are you receiving mails when you submit System_Mail_send separately?

If yes can you try adding any one of job ids (completed, error, anyone) in the relative job field and see what you're getting?

When the log says, relative job is step 1, jobid xx, the current job id is yy, what is that job with id yy?

in this case, did you supply the job id manually? like Step 1, yy. this wouldn't have worked.because in step 1, there is no job with id yy.

You shouldn't manually fill job id, because for every run the job id is generated and automatically assigned to job. So if you hard code it, how will it pick the current job id?

You should only use number '1' or '2' etc.., as HP mentioned. Simply, step 1, job 1. this wil alert about the first job in step 1.

Also if you search for notes section in the service market place with you CPS version, you will a note that describes the changes and bug fixes that are available in the next version from your CPS version, where you can check against your issue. If it's not mentioned there, you can raise an OSS message, for which i assume, SAP would recommend upgrading to a higher version of CPS.

Thanks

Nanda

Something about the job id in the logs, intrigued me. Message was edited by: Nanda Kumar

h_carpenter
Active Contributor
0 Kudos

Hi Ramakrishnan,

From: someone@company.com

Server: smtp.company.com

To: someone@company.com

Subject: Job failure Alert CPS

Text : ---------

Relative Job: Step 1, Job 2 <<- the job number 2 of step named "Step 1" in the job chain

Job File: stderr.log <<-if you want a job file

Basically, you can have the following job chain with three steps, first to do actual work (named "Run Abap"), second only run if error occurred in first step (named "Error Handling"), last step does nothing, used to jump over step number 2 :

Run Abap (Step 1)-> Status Handlers -> onCompleted Goto "Do nothing, all is fine", onError goto "Error Handling"

-> Some AbapRun

Error Handling (Step 2)

-> System_Mail_Send

-->To: someone@company.com

-->Subject: Job chain failed

-->Text: This job chain failed, see attached error log.

-->Relative Job: Run Abap, Job 1 <------ only fill if you want the stderr.log

-->Job File:stderr.log <------ only fill if you want the stderr.log

-->Server:use default, so don't fill

-->From: use default, so don't fill

Do nothing, all is fine  (Step 3)

There are other ways to do it, of course, but this keeps it simple.

You can also search the log file for errors and send just the lines containing errors, or send the first, last 15 lines, for example ... but that is another subject for another thread ... I guess ... 😉

See

http://<server>:<port>/scheduler/help/user_guide/definitions/job_definition_types/mail_job_definition_type.html

http://<server>:<port>/scheduler/help/modules/mail/main_mail.html

for more information.

Regards from

HP