cancel
Showing results for 
Search instead for 
Did you mean: 

Run Automatic code

Former Member
0 Kudos

Hi,

In my application i want to execute a query that will run Automatic every day, and according to its results execute some code like sending e-mails etc.

Regards,

Rivka Lieberman

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You could use KM schedular, but it won't be part of your project. It will be separate entity deployed on the server.

Read Blog [KM's Scheduler|https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/1515] [original link is broken] [original link is broken] [original link is broken];

Former Member
0 Kudos

Hi Jawed Ali,

It's a really good weblog, but after I follow all the steps required for the deployment I can see the task in the path to schedule it. But when I put an hour to test it (every 5 minutes) it doesn't work.

any suggestion?

Thank You

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

I've got it to work!

The CM Systems in the Scheduler Tasks

wasn't defined.

Thanks for all of your help,

Rivka

Former Member
0 Kudos

Hi,

I've got it to work!

I discovered the problem, the CM Systems wasn't defined,

Thanks for all of your help,

Rivka

Edited by: Rivka Leah Lieberman on Sep 8, 2008 2:09 PM

Former Member
0 Kudos

hello,

sorry for this being not sap specific, but my suggestion would be to code a very tiny application (c/c++/vb etc...) that connects to the db via odbc and executes your required sql. once you have that done, create a scheduled task that runs this application once a day.

regards,

chris

Former Member
0 Kudos

Hi Jawed Ali,

It's a really good weblog, but after I follow all the steps required for the deployment I can see the task in the path to schedule it. But when I put an hour to test it (every 5 minutes) it doesn't work.

any suggestion?

Thank You

Edited by: Rivka Leah Lieberman on Sep 4, 2008 8:28 AM

Former Member
0 Kudos

Hi,

If you dont want this task to be done with the KM schedular.

Create a POJO java class, and create a jar out of it schedule this

In windows

Using the schedular

In unix

either at or crone job.

Regards

Ayyapparaj

Former Member
0 Kudos

I also had problems in viewing the output of process defined in the weblog, to test whether the scheduler is working we use this simple code for run method:

public void run(String id, Properties properties) {
	try {
			
		File testFile = new File("/usr/tmp/schedular.log"); 	//for Linux/UNIX
		//File testFile = new File("d:/schedular.log"); 	//for windows
		
		if (testFile.exists())
			testFile.delete();

		testFile.createNewFile();			
					
		FileOutputStream out = new FileOutputStream(file);
		out.println(new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date())+": Schedular is executed successfully.")			
		out.close();
	} catch (IOException ioe) 
	{
		error("Caught an IOException: \n" + ioe.getMessage());
	} catch (Exception e) 
	{
		error("Caught an Exception: \n" + e.getMessage());
	}	
}

change the File Object creation statement according to your environment.

Let me know if you need any help.

Regards,

Jawed Ali

Former Member
0 Kudos

Hi,

Still doesn't work.

I tried running the simple code you sent me, but there was no log file created or updated in the folder i specified.

Do you have any idea why this doesn't work?

also in the default trace i cannot find anything thats got to do with the scheduler, do you know where i can find scheduler logs?

Thank You,

Rivka Lieberman

Edited by: Rivka Leah Lieberman on Sep 8, 2008 11:45 AM

sureshmandalapu6
Active Contributor
0 Kudos

Hi Rivka Leah Lieberman,

We do have Timer Element in WebDynpro. You can use this UI element to achive your task.

points if useful

Thanks

Suresh

Former Member
0 Kudos

Hi,

The timer element runs only when the application is running.

I need to use a thread that is constantly running.

Thanks,

sureshmandalapu6
Active Contributor
0 Kudos

Hi Rivka Leah Lieberman,

Since the query has to run in your application everyday, you need to start running the application. Without running the application and query should be executed from application is not posible.

Eloborate clearly,

Thanks

Suresh

Former Member
0 Kudos

Hi Suresh Mandalapu,

I am looking for a script that will run all the time and send e-mails according to sql queries,

similar to Sql jobs.(im not using Sql jobs because in sql jobs i can only use sql code).

Thank You,

Edited by: Rivka Leah Lieberman on Sep 3, 2008 9:44 AM