How can i get all the jobs name in a sequence

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

jerrynn
Participant
Posts: 5
Joined: Wed Sep 28, 2005 9:05 pm

How can i get all the jobs name in a sequence

Post by jerrynn »

Hello,

i need to generate a report for the datastage jobs. For some reason, i am not allowed to modified the sequence/jobs itself. All i can do is to create a new job/routine.

I am facing a problem when i need to get all the jobs name in the main sequence, sub-sequence or sub-sub-sequence. There are around a total of 200-300 jobs in that particular main sequence. For that reason, i could not hardcode it myself. There are also few main sequence in the job and i just cannot select all the job by the command "select jobname from dsjob".

Can that be achieve by put constaint in the statement? Any Guru here willing to share the knowledge doing that?

Thanks in advance!
Last edited by jerrynn on Mon Apr 03, 2006 2:33 am, edited 1 time in total.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

"Hardcore" is a good word, if inadvertent. To do this in a single query would be impossible (recursive SQL does not exist in DataStage Repository). You would need to identify job sequences in DS_JOBS then, for each, generate a list of the jobs run under its control based on records in DS_JOBOBJECTS. I don't have access to DataStage just at the moment. It can be done (I have done it in the past), but you need to store intermediate results, if I recall correctly. It can definitely be done with a recursive server routine.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
jerrynn
Participant
Posts: 5
Joined: Wed Sep 28, 2005 9:05 pm

Post by jerrynn »

ray.wurlod wrote:"Hardcore" is a good word, if inadvertent. To do this in a single query would be impossible (recursive SQL does not exist in DataStage Repository). You would need to identify job sequences in DS_JOB ...
lol it was a typo. i meant hardcode
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Iam not sure what is the feild which will help to identify the dependcy among the job in DS_JOBOBJECTS. I could not find a use full output form 'DEPENDS' feild in DS_JOBOBJECTS. But dsjob -logdetail for the main sequence will give you the full log. If you manage to grep within the log you can find the list of jobs being called. Of in the individual jobs you can find '(Main Sequnce) <- Job name: Job under control finished.' as the last log.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

Kumar is on the right track. I think the SQL below could be better. I will send a better version later today.

Code: Select all

SELECT 
   NAME,
   CATEGORY,
   EVAL "TRANS('DS_JOBOBJECTS','J\':@RECORD<5>:'\ROOT',31,'X')" AS DEPEND_JOBS FMT '35L',
   EVAL "if TRANS('DS_JOBOBJECTS','J\':@RECORD<5>:'\ROOT',40,'X') = '2' then 'Y' else 'N'" AS SEQ
FROM 
   DS_JOBS
WHERE
   SEQ = 'Y'
ORDER BY
   NAME
;
Mamu Kim
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Yea... now i could get the list with simple select query. But I dont know why the same didnt worked previously. :oops:
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
murali
Participant
Posts: 54
Joined: Mon Sep 12, 2005 11:38 pm

Post by murali »

Hi kduke
SELECT
NAME,
CATEGORY,
EVAL "TRANS('DS_JOBOBJECTS','J\':@RECORD<5>:'\ROOT',31,'X')" AS DEPEND_JOBS FMT '35L',
EVAL "if TRANS('DS_JOBOBJECTS','J\':@RECORD<5>:'\ROOT',40,'X') = '2' then 'Y' else 'N'" AS SEQ
FROM
DS_JOBS
WHERE
SEQ = 'Y'
ORDER BY
NAME
;
Will this also work on windows plat form.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Yes, the query is a DataStage SQL one and is hardware and platform independant.
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

That SQL is based on the job dependencies in job properties page. This is not always accurate. This is more accurate.

Code: Select all

select
   DS_JOBS.NAME JobName FMT '40L',
   DS_JOBOBJECTS.NAME LinkName FMT '30L',
   EVAL DS_JOBOBJECTS."@RECORD<12>" AS JobActivtyJobName FMT '40L'
from 
   DS_JOBOBJECTS,
   DS_JOBS
where 
   DS_JOBOBJECTS.OLETYPE = 'CJSJobActivity'
   and DS_JOBS.NAME = 'Control_Sequence'
   and DS_JOBOBJECTS.OBJIDNO = DS_JOBS.JOBNO 
;
Mamu Kim
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

As noted earlier, it's then up to you to put the data together in such a fashion as to identify sub-sub-sequences and lower. The query does not do that. It can be done with a routine.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

I would use this SQL in a UV stage. Output the results into a staging table then you can report on it any way you want. EtlStats has jobs like this. I populate ETL_JOB which has the category and a field that says this job is a sequence.

DwNav lets you drill down into sequences. So you can go from the top sequence down to the lowest level.

EtlStats also has reports like all the run times for the last run of all sequences by date or by job name. This report is very useful in getting the run order. If you run this on a regular basis then you will notice when a sequence runs longer than normal.
Mamu Kim
jerrynn
Participant
Posts: 5
Joined: Wed Sep 28, 2005 9:05 pm

Post by jerrynn »

Thanks for all the helps. I am really appreciate it.

May i know where can i get EtlStats?
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

You can find a link to it in Kum Duke's signature.

http://www.Duke-Consulting.com/DataStage_Tips.htm
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
dwblore
Charter Member
Charter Member
Posts: 40
Joined: Tue Mar 28, 2006 12:02 am

Post by dwblore »

ray.wurlod wrote:As noted earlier, it's then up to you to put the data together in such a fashion as to identify sub-sub-sequences and lower. The query does not do that. It can be done with a routine.
Hello I have been trying to fetch the all calling sequences ( direct/indirect ) of a job using a routine with the SQL extract provided ...

For ex1
SeqA calls SeqB calls Jobd

ex2

SeqA calls Jobx

So if i execute the routine with

Jobd -> Ans = SeqB,SeqA

Jobx -> Ans = SeqA

This is the routine ...

Dependacy(aSearchString)
DEFFUN Dependancy(aSearchstring) CALLING 'DSU.Dependancy'

NAME = aSearchString
Ans = ''
i=0

CMD = "SELECT DS_JOBS.NAME JobName from DS_JOBOBJECTS,DS_JOBS where DS_JOBOBJECTS.OLETYPE = 'CJSJobActivity' and EVAL DS_JOBOBJECTS.'@RECORD<12>' = '":NAME:"' and DS_JOBOBJECTS.OBJIDNO = DS_JOBS.JOBNO"
EXECUTE CMD CAPTURING CMDRST ;


x = convert (@FM , '|', CMDRST )

If Index(x,"0 records",1) Then
Return(Ans)
End
Else
Str = Trim(Field(x,'|',4,(count(x,'|')-5)))
for i=1 to (count(Str,'|')+1)
Ans=Field(Str,'|',i):Dependancy(Field(Str,'|',i))
Next i
End

This works fine for Ex2 but whenever there is a recursive call this bombs

any ideas where i am going wrong?

thanks
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

You maybe looping back on yourself. So you are in an infinite loop.
Mamu Kim
Post Reply