Task Object
The Task object enables access to a subset of the functionality of the ComScript module from within an AMT Report. In order to be able to use the Task Object the ComScript module needs
to be configured on the server running the Batch controller, see ComScript Module.
The subset of the total ComScript functionality is the major part of the general ComScript Connection Interface and
the complete Job Interface. Excluded from the ComScript Connection Interface are the functions for creating
most of the Interface objects. The only Interface object that can be created in the Task object is the Job Interface
object.
Full descriptions of all the functionality of the Task Object is found in the Connection Interface, in the Job Interface and in the Print Interface help pages.
Below an extract from a report that uses the task object: (not all code has been inserted here, just the code needed
to understand the task object)
02.var
03. st-path-extracts : string
04. mytask : task //define the task object
05. myjob : job //define the job object
06. myprint : print //define the print object
07. requestid : integer
08. sb-found : boolean
09.end_definitions
10.
11.routine main
12.begin_routine
19. mytask.appname := 'TEST'
20. mytask.connect()
21.
22. if not mytask.connected
23. gt-result &= ('ERROR TASK_OBJECT not connected, report exited without running!') + gac-crlf
24. goto (end)
25. endif
26.
27. myjob := mytask.createjob()
28.
29. myjob.user := 'USER'
30. myjob.usergroup := 'Administrators'
31. myjob.queuename := 'Default'
32. myjob.station := 'STATIONNAME'
33. myjob.wait := false //in case of error, REPORT should continue
34.
35. //MyJob.addprinter ('PROUT', 'HP3015')
36. myjob.setdefaultdontprint (true)
37. //MyJob.setdontprint ('PROUT', True)
38.
39. requestid := myjob.addjobrequest('RT_TASK_TEST', report)
40.
41. // MyPrint := MyTask.CreatePrint()
58.end_routine
Lines 04/05:
In order to use the Task object inside a report it has to be defined as variable in the definitions section of the report. And since it will be used to control jobs also a variable for the Job object has to be defined.
Lines 19/25:
Then the ComScript module needs to be connected to a specific application which needs not necessarily be the application the report belongs to
Line 27:
Next a Job Interface object has to be created to be able to start jobs.
Lines 29/36:
Finally a Job can be started.
When the AddJobRequest failed, the returned RequestId will be -1, otherwise the returned RequestId can be used to check the progress of the Job.
// waiting for the job to finish
endloop
Note: waiting for the job to finish is better accomplished by using the Wait property of the Job Interface. (line 33)
The full functionality of the Task Object interfaces can be found on the Task Object Connection Interface, the Task Object Job Interface and the Task Object Print Interface help pages.