Gary Koester · Nov 11

#5003 not implemented

I am trying to create a scheduled task but get not implemented error when I try to run it.

Class PICIS.Core.Tasks.CleanEntry Extends %RegisteredObject

ClassMethod ClearTasks(pBackupFile As %String = "d:\Temp\BackupTasks.xml", pDelete As %Boolean = 0)
    // Create backup file
    Set tBackup = ##class(%Stream.FileCharacter).%New()
    Set tBackup.Filename = pBackupFile
    Do tBackup.WriteLine("<?xml version=""1.0"" encoding=""UTF-8""?>")
    Do tBackup.WriteLine("<Tasks>")

    // Delete loop
    Set tCount = 0
    Set tSC = $$$OK
    Set tRS = ##class(%SQL.Statement).%ExecDirect(, "Select ID From %SYS.Task Where Namespace = ? And TaskClass = ?", PICIS, "picis.core.tasks.senddelayedtrigger")
    While tRS.%Next() {
        Set tTask = ##class(%SYS.Task).%OpenId(tRS.ID)
        Set tSC = tTask.XMLExportToString(.tExport)
        If $$$ISERR(tSC) {
            Write !,"Problem trying to export TASK ID ",tRS.ID
            Do $System.Status.DisplayError(tSC)
        Do tBackup.WriteLine($ZConvert(tExport, "O", "UTF8"))

        // Delete?

        If pDelete {
            Set tSC = ##class(%SYS.Task).%DeleteId(tRS.ID)
            If $$$ISERR(tSC) {
                Write !,"Problem trying to delete TASK ID ",tRS.ID
                Do $System.Status.DisplayError(tSC)
        Set tCount = tCount + 1
    // Close backup file
    Do tBackup.WriteLine("</Tasks>")
    Set tSC = tBackup.%Save()
    If $$$ISERR(tSC) {
        Write !,"Problem saving backup file"
        Do $System.Status.DisplayError(tSC)
    Write !!,"Backed up ",$Select(pDelete:"and Deleted ", 1:""),tCount," Tasks"


Product version: Caché 2017.1
1 0 14 151
Log in or sign up to continue

Can you see where the not implemented is being thrown?

No, its a new one for me. It is a mystery to me.

If you debug the class and go through it can you try to identify which line is throwing the error?

I assume your Classmethod runs from console / terminal.
running as scheduled Task you are always running in Background.
So where do you expect all the WRITE to go.
I did neither see a log file or a Spool device.  

The code was given to me from Intersystems. I can remove the writes.

There's a syntax error in this line:

Set tRS = ##class(%SQL.Statement).%ExecDirect(, "Select ID From %SYS.Task Where Namespace = ? And TaskClass = ?", PICIS, "picis.core.tasks.senddelayedtrigger")

PICIS needs to be in quotes.

That wouldn't typically cause a not implemented error, though. Are you getting any errors when you try to compile the class?

No it compiles successfully

To use something in the task scheduler, you have to create a class that extends %SYS.Task.Definition. Within that class you have to define:

Method OnTask() As %Status{
    //The stuff you want to happen when the task is scheduled goes here.
    //In your case, that probably means calling your task method.

If that method is not defined, you get the "Not Implemented" error. If you've created such a class, make sure the method had the right name, isn't a classmethod, is As %Status, and does return a %Status. Also make sure the class is compiling correctly.

I added the Method and now have a different error.

<UNDEFINED>zOnTask+3^PICIS.Core.Tasks.CleanEntry.1 *pBackupFile

I have not written much of this code so I am a beginner and learning.

That's okay! That's what we're here for. What exactly is in your OnTask method?

Finally getting back to this. Where does the method live. In the file directory?

Gary, if you want to put something into the Cache Task Manager, you have to create a class that extends %SYS.Task.Definition and put the OnTask method there.

I wrote a how-to on using the task manager after you posted this. It might help you.