Getting Sequencer name from the job name

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

DSMaestro
Participant
Posts: 14
Joined: Thu Oct 15, 2009 6:47 am

Getting Sequencer name from the job name

Post by DSMaestro »

Hi Gurus,

I've a list of jobs in a sequential file.
I want to get the Sequencer name at which these list of jobs are being called.
How to achieve it by using Server routines...

Sample input & output are given below,

Input:

Job1
Job2
Job3
Job4

Output:

Job1 Seq1
Job1 Seq2
Job2 Seq1
Job3 Seq1
Job4 Seq1


Thanks in Advance...
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

There should be a Macro for that - and it will have 'Controller' in its name, from what I remember. Can't check right now or I'd post the exact name.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The DSGetJobInfo(YourJobHandle,DSJ.JOBCONTROLLER) will give you a job's parent.
DSMaestro
Participant
Posts: 14
Joined: Thu Oct 15, 2009 6:47 am

Post by DSMaestro »

ArndW wrote:The DSGetJobInfo(YourJobHandle,DSJ.JOBCONTROLLER) will give you a job's parent. ...
Thanks ArndW,

But how u call this function in server transformer....
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

If you want the parent process of the job that is running, then simple use "DSGetJobInfo(DSJ.ME,DSJ.JOBCONTROLLER)"
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Or, as noted, the DSJobController macro can be used just like a job parameter. Got a chance to look it up. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSMaestro
Participant
Posts: 14
Joined: Thu Oct 15, 2009 6:47 am

Post by DSMaestro »

chulett wrote:Or, as noted, the DSJobController macro can be used just like a job parameter. Got a chance to look it up. :wink: ...
When i try placing this value in the column derivation of my tranformer
DSGetJobInfo(DSJ.ME,JobName)
I was getting -5 as output.
I was not getting the Sequencer name as output. :cry:
DSMaestro
Participant
Posts: 14
Joined: Thu Oct 15, 2009 6:47 am

Post by DSMaestro »

chulett wrote:Or, as noted, the DSJobController macro can be used just like a job parameter. Got a chance to look it up. :wink: ...
When i try placing this value in the column derivation of my tranformer
DSGetJobInfo(JobName,DSJ.JOBCONTROLLER)
I was getting -1 as output.
I was not getting the Sequencer name as output. :cry:
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Did you try using the macro instead? Did you try looking up the error codes? They are documented.
-craig

"You can never have too many knives" -- Logan Nine Fingers
subrat
Premium Member
Premium Member
Posts: 77
Joined: Tue Dec 11, 2007 5:54 am
Location: UK

Post by subrat »

chulett wrote:Did you try using the macro instead? Did you try looking up the error codes? They are documented. ...
Could you try with the below macro and check if its working fine....

$include DSINCLUDE JOBCONTROL.H
JobName=Arg1
JobHandle = DSAttachJob (JobName, DSJ.ERRFATAL)
controllerList=DSGetJobInfo(JobHandle,DSJ.JOBCONTROLLER)
ErrCode=DSDetachJob(JobHandle);
print controllerList;
Ans=controllerList

Thanks
Subrat
DSMaestro
Participant
Posts: 14
Joined: Thu Oct 15, 2009 6:47 am

Post by DSMaestro »

[quote="subrat]
Could you try with the below macro and check if its working fine....

$include DSINCLUDE JOBCONTROL.H
JobName=Arg1
JobHandle = DSAttachJob (JobName, DSJ.ERRFATAL)
controllerList=DSGetJobInfo(JobHandle,DSJ.JOBCONTROLLER)
ErrCode=DSDetachJob(JobHandle);
print controllerList;
Ans=controllerList

Thanks
Subrat[/quote]

Hi Subrat,

I'd included the code in a routine called GetJobStatus with one arguement Arg1.

When i run my job by calling this routine in my job by uisng the below derivation
"DSGetJobInfo(GetJobStatus(JobName), DSJobController)"

My job is getting aborted with the following error message

"ExtractJobDetails (fatal error from DSGetJobInfo): Job control fatal error (-1)
(DSGetJobInfo) Invalid job handle Seq_Name"

I see the sequencer name was getting retrieved correctly by the fatal error message,but why it was not getting return to the target & also why my job is getting aborted.
subrat
Premium Member
Premium Member
Posts: 77
Joined: Tue Dec 11, 2007 5:54 am
Location: UK

Post by subrat »

You are keeping all the job names in souce file? If yes try to put one comma (,) after each job name and then run your job.

Let me know if any luck.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

DSMaestro wrote:DSGetJobInfo(GetJobStatus(JobName), DSJobController)
Your syntax is bad and you need to let the routine do all the work.

Code: Select all

GetJobStatus(JobName)
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

DSMaestro wrote:But how u call this function in server transformer....
Your original question was how to do it in a routine. People have been answering that question.

I doubt that U (one of our posters) is interested in calling this function at all, but I could be wrong. The second person personal pronoun in English is spelled "you". Please maintain a professional standard of written English on DSXchange; this helps those whose first language is not English.

The function name is DSGetJobInfo, not GetJobInfo. In a Transformer stage you would need to use a custom routine that is passed the job name that is being read from the file and which returns the list of controller job names.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Something like the following code would appear to meet the requirement.

Code: Select all

FUNCTION GetController(JobName)

$IFNDEF JOBCONTROL.H
$INCLUDE DSINCLUDE JOBCONTROL.H
$ENDIF

If UnAssigned(JobName) Or (Len(JobName) = 0)
Then
   Ans = @NULL
End
Else
   hJob = DSAttachJob(JobName, DSJ.ERRNONE)
   Controller = DSGetJobInfo(hJob, DSJ.JOBCONTROLLER)
   If Controller = DSJE.BADHANDLE
   Then
      ErrMsg = 'Unable to attach job ' : JobName
      Call DSLogWarn(ErrMsg, 'GetController')
      Ans = @NULL
   End
   Else
      Ans = Controller
   End
   ErrCode = DSDetachJob(hJob)
End
RETURN(Ans)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply