Page 1 of 3

Can we get only job status???

Posted: Tue Nov 29, 2005 3:10 am
by ICE
Hi,

I like to write a batch job which contains all other jobs from my project directory to get only their job status whether they are successful or not.
I don't want to run those jobs from there.I just want to get their status only.
Can I do that???
Could u pls give me some idea???


Thanks,

Posted: Tue Nov 29, 2005 3:38 am
by loveojha2
You would need to use

Code: Select all

Result = DSGetJobInfo (JobHandle, DSJ.JOBSTATUS)
which will give you the status of the job.
where JobHandle is the Handle for the job returned by

Code: Select all

JobHandle = DSAttachJob (JobName, ErrorMode)
Use erroMode as DSJ.ERRNONE. You can get the name of the jobs from

Code: Select all

Call DSExecute("NAME FMT '60R' FROM DS_JOBS WHERE NAME NOT LIKE '%\%';",cmd,output,sysretcode)

Posted: Tue Nov 29, 2005 3:43 am
by Andal
Ice,

Kim Duke has posted this. You can search the posts of Kim, something it would have

Code: Select all

begin case 
            case JStat = 0 
               JobStatus = 'Running' 
               CanRunFlag = 0 
               CanResetFlag = 0 
               CanStopFlag = 1 
            case JStat = 1 
               JobStatus = 'Finished' 
            case JStat = 2               ; * Finished with warnings 
               JobStatus = 'Finished' 
            case JStat = 3 
               ContinueFlag = @false 
               JobStatus = 'Aborted' 
               CanRunFlag = 0 
            case JStat = 11 
               JobStatus = 'Finished' 
            case JStat = 12              ; * Validated with warnings 
               JobStatus = 'Finished' 
            case JStat = 13 
               * ContinueFlag = @false 
               JobStatus = 'Finished' 
            case JStat = 21 
               JobStatus = 'Finished' 
            case JStat = 96 
               ContinueFlag = @false 
               JobStatus = 'Aborted' 
               CanRunFlag = 0 
            case JStat = 97 
               * ContinueFlag = @false 
               JobStatus = 'Stopped' 
               CanRunFlag = 0 
            case JStat = 98 
               JobStatus = 'Finished' 
            case JStat = 99 
               JobStatus = 'Finished' 
            case @true 
               ContinueFlag = @false 
               JobStatus = 'Not Compiled' 
               CanRunFlag = 0 
               CanResetFlag = 0 
         end case 
    end 
It is part of his ETL_Stats code. Search for it

Posted: Tue Nov 29, 2005 3:54 am
by ICE
Hi loveojha2,

Thanks for your suggestion.But still i need some suggestion.
You give the example to get the jobs name.
So there are more than one jobs I will get if I use this.Right?So do I have to use the loop function to get the job status???


Thank u so much,
ICE



loveojha2 wrote:You would need to use

Code: Select all

Result = DSGetJobInfo (JobHandle, DSJ.JOBSTATUS)
which will give you the status of the job.
where JobHandle is the Handle for the job returned by

Code: Select all

JobHandle = DSAttachJob (JobName, ErrorMode)
Use erroMode as DSJ.ERRNONE. You can get the name of the jobs from

Code: Select all

Call DSExecute("NAME FMT '60R' FROM DS_JOBS WHERE NAME NOT LIKE '%\%';",cmd,output,sysretcode)

Posted: Tue Nov 29, 2005 3:55 am
by loveojha2
Yes :)
and don't forget to detach the job, once you have read the status with

Code: Select all

ErrCode = DSDetachJob(JobHandle)
ICE wrote:Hi loveojha2,

Thanks for your suggestion.But still i need some suggestion.
You give the example to get the jobs name.
So there are more than one jobs I will get if I use this.Right?So do I have to use the loop function to get the job status???


Thank u so much,
ICE



loveojha2 wrote:You would need to use

Code: Select all

Result = DSGetJobInfo (JobHandle, DSJ.JOBSTATUS)
which will give you the status of the job.
where JobHandle is the Handle for the job returned by

Code: Select all

JobHandle = DSAttachJob (JobName, ErrorMode)
Use erroMode as DSJ.ERRNONE. You can get the name of the jobs from

Code: Select all

Call DSExecute("NAME FMT '60R' FROM DS_JOBS WHERE NAME NOT LIKE '%\%';",cmd,output,sysretcode)

Posted: Tue Nov 29, 2005 4:13 am
by ICE
Dear loveojha2,

May I know how to get the job name one by one???
Now your exp will give the series of jobs name.Right?So how to get one by one.I mean how to assign to a variable???I cannot assign to one variable when I run this DSExecute.
Or can I use the jobname as the alias of NAME from that query statement.I think it's a query statement.Right?
Sorry for my inconvinience.
I am very poor knowledge in this.


Thank u so much 4 ur help.


loveojha2 wrote:Yes :)
and don't forget to detach the job, once you have read the status with

Code: Select all

ErrCode = DSDetachJob(JobHandle)
ICE wrote:Hi loveojha2,

Thanks for your suggestion.But still i need some suggestion.
You give the example to get the jobs name.
So there are more than one jobs I will get if I use this.Right?So do I have to use the loop function to get the job status???


Thank u so much,
ICE



loveojha2 wrote:You would need to use

Code: Select all

Result = DSGetJobInfo (JobHandle, DSJ.JOBSTATUS)
which will give you the status of the job.
where JobHandle is the Handle for the job returned by

Code: Select all

JobHandle = DSAttachJob (JobName, ErrorMode)
Use erroMode as DSJ.ERRNONE. You can get the name of the jobs from

Code: Select all

Call DSExecute("NAME FMT '60R' FROM DS_JOBS WHERE NAME NOT LIKE '%\%';",cmd,output,sysretcode)

Posted: Tue Nov 29, 2005 5:42 am
by loveojha2
ICE wrote:Dear loveojha2,

May I know how to get the job name one by one???
Now your exp will give the series of jobs name.Right?So how to get one by one.I mean how to assign to a variable???I cannot assign to one variable when I run this DSExecute.
Or can I use the jobname as the alias of NAME from that query statement.I think it's a query statement.Right?
Sorry for my inconvinience.
I am very poor knowledge in this.
From
Call DSExecute("NAME FMT '60R' FROM DS_JOBS WHERE NAME NOT LIKE '%\%';",cmd,output,sysretcode)

output will contain the list of the jobnames separated by @FM (it will also contain CHAR(10)s). Use Field function to select individual jobnames from this string.

Posted: Tue Nov 29, 2005 5:53 am
by ArndW
hmmm... that last post needs to be corrected!

The command to execute had 2 errors, it should read:

Code: Select all

Call DSExecute("UV","SELECT NAME FMT '60R' FROM DS_JOBS WHERE NAME NOT LIKE '%\%';",output,sysretcode) 
Your output variable "output" will contain a multivalued list of the jobs located. You can then do something like:

Code: Select all

JobsFound = DCOUNT(output,@FM)
FOR I = 1 TO JobsFound
  JobNameToCheck = output<I>
  ** do your processing here **
NEXT I

Posted: Tue Nov 29, 2005 8:22 pm
by ICE
Thank you so much.

But I still have some more questions.
Can I output to the txt file in batch job?
How to make it???

Can I call a routine from batch job???
How to call ???

Thanks in Advance,


ArndW wrote:hmmm... that last post needs to be corrected!

The command to execute had 2 errors, it should read:

Code: Select all

Call DSExecute("UV","SELECT NAME FMT '60R' FROM DS_JOBS WHERE NAME NOT LIKE '%\%';",output,sysretcode) 
Your output variable "output" will contain a multivalued list of the jobs located. You can then do something like:

Code: Select all

JobsFound = DCOUNT(output,@FM)
FOR I = 1 TO JobsFound
  JobNameToCheck = output<I>
  ** do your processing here **
NEXT I

Posted: Wed Nov 30, 2005 1:24 am
by ray.wurlod
I think we're becoming confused. By "batch job" do you mean the task of getting each job's job status?

Can I output to the txt file in batch job? Yes
How to make it??? OpenSeq, WriteSeq, CloseSeq

Can I call a routine from batch job??? Yes
How to call ??? What kind of routine?

Why not just create a regular server job that processes DS_JOBS using a Hashed File stage or UniVerse stage (you need only the NAME column; declare it as VarChar(254)) to get the job names, call a routine via a Transformer stage to get the job status, and direct the output to a Sequential File stage?

Posted: Wed Nov 30, 2005 1:36 pm
by djm
I don't know whether they will work for DS 4.x, as they have only been used in anger against DS 6.x & DS 7.x, but one option for you may be to try either this thread or this one.

Both threads provide DS jobs that allow different dumps of DS Director job log. The first thread (you can ignore the spreadsheet bit if you want - the DS job creates a flat file that you can always manipulate) provides a summary of each job that has been run, with one of the columns created being the job status. The second thread provides a complete dump of the Director log content and you could always pick apart the job and steal this bits you want if the first thread isn't of any use.

<aside>Craig, is that an improvement on the "Try here" message? :wink: </aside>

David

Posted: Wed Nov 30, 2005 9:01 pm
by ICE
Great.Thank u so much ,Ray.
Really thanks to u.
Yeah,I wanna check all of my jobs status whether successfully done or not.
Now I created regular server job according to your suggestion.It works.Thank u so much.

ICE

ray.wurlod wrote:I think we're becoming confused. By "batch job" do you mean the task of getting each job's job status?

Can I output to the txt file in batch job? Yes
How to make it??? OpenSeq, WriteSeq, CloseSeq

Can I call a routine from batch job??? Yes
How to call ??? What kind of routine?

Why not just create a regular server job that processes DS_JOBS using a Hashed File stage or UniVerse stage (you need only the NAME column; declare it as VarChar(254)) to get the job names, call a routine via a Transformer stage to get the job status, and direct the output to a Sequential File stage?

Posted: Wed Nov 30, 2005 9:42 pm
by ICE
Dear Ray,

Now I got the jobs name but the DSJ.JOBSTATUS are always -1 even though they are not the same status.
May I know what is that???
May I know how to know the staus as -1 is what,1 is what.Like that way.Where can I find those information???I don't see any clarification in DS Dev help files.


Thank u so much.


ray.wurlod wrote:I think we're becoming confused. By "batch job" do you mean the task of getting each job's job status?

Can I output to the txt file in batch job? Yes
How to make it??? OpenSeq, WriteSeq, CloseSeq

Can I call a routine from batch job??? Yes
How to call ??? What kind of routine?

Why not just create a regular server job that processes DS_JOBS using a Hashed File stage or UniVerse stage (you need only the NAME column; declare it as VarChar(254)) to get the job names, call a routine via a Transformer stage to get the job status, and direct the output to a Sequential File stage?

Posted: Wed Nov 30, 2005 10:15 pm
by loveojha2
Hi ICE,

For me job status is -1 when I create a new job and its yet to be compiled.
But not very sure on this.
ICE wrote:Dear Ray,

Now I got the jobs name but the DSJ.JOBSTATUS are always -1 even though they are not the same status.
May I know what is that???
May I know how to know the staus as -1 is what,1 is what.Like that way.Where can I find those information???I don't see any clarification in DS Dev help files.


Thank u so much.


ray.wurlod wrote:I think we're becoming confused. By "batch job" do you mean the task of getting each job's job status?

Can I output to the txt file in batch job? Yes
How to make it??? OpenSeq, WriteSeq, CloseSeq

Can I call a routine from batch job??? Yes
How to call ??? What kind of routine?

Why not just create a regular server job that processes DS_JOBS using a Hashed File stage or UniVerse stage (you need only the NAME column; declare it as VarChar(254)) to get the job names, call a routine via a Transformer stage to get the job status, and direct the output to a Sequential File stage?

Posted: Wed Nov 30, 2005 10:27 pm
by ICE
Hi loveojha2,

Thanks for ur sharing.......
My jobs are with different kinds of status.But I got all of the status as -1.
So,I wanna to know what this.At least it should be different status .Right?

Thanks,
ICE

loveojha2 wrote:Hi ICE,

For me job status is -1 when I create a new job and its yet to be compiled.
But not very sure on this.
ICE wrote:Dear Ray,

Now I got the jobs name but the DSJ.JOBSTATUS are always -1 even though they are not the same status.
May I know what is that???
May I know how to know the staus as -1 is what,1 is what.Like that way.Where can I find those information???I don't see any clarification in DS Dev help files.


Thank u so much.


ray.wurlod wrote:I think we're becoming confused. By "batch job" do you mean the task of getting each job's job status?

Can I output to the txt file in batch job? Yes
How to make it??? OpenSeq, WriteSeq, CloseSeq

Can I call a routine from batch job??? Yes
How to call ??? What kind of routine?

Why not just create a regular server job that processes DS_JOBS using a Hashed File stage or UniVerse stage (you need only the NAME column; declare it as VarChar(254)) to get the job names, call a routine via a Transformer stage to get the job status, and direct the output to a Sequential File stage?