Problem in using DS Routine

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

aaikat
Participant
Posts: 47
Joined: Tue Mar 07, 2006 2:49 am

Problem in using DS Routine

Post by aaikat »

I am developing a server job (say Job1).Now in its Trasnformer stage derivation if I use a Routine (written by me) :

MyGetLinkCount(<Job2>,<Stage2>,<Link2>)

It is not creating any value for that derivation in output file,though the routine when tested from outside with the same arguments returns value.
Job2,Stage2,Link2 are pre-developed.
dprasanth
Charter Member
Charter Member
Posts: 90
Joined: Fri Oct 07, 2005 7:55 am

Re: Problem in using DS Routine

Post by dprasanth »

aaikat wrote:I am developing a server job (say Job1).Now in its Trasnformer stage derivation if I use a Routine (written by me) :

MyGetLinkCount(<Job2>,<Stage2>,<Link2>)

It is not creating any value for that derivation in output file,though the routine when tested from outside with the same arguments returns value.
Job2,Stage2,Link2 are pre-developed.
Do you mind putting that routine over here so that we can have a look what you are trying to do?
aaikat
Participant
Posts: 47
Joined: Tue Mar 07, 2006 2:49 am

Post by aaikat »

It just calculates the count associated with any link. Here it is (MyGetLinkCount) :

$INCLUDE DSINCLUDE JOBCONTROL.H

hJob=DSAttachJob(JobName,DSJ.ERRFATAL)

If NOT(hJob) Then
Call DSLogFatal("Job Attach Failed", "JobControl")
Abort
End

LinkCount = DSGetLinkInfo(hJob,StageName,LinkName,DSJ.LINKROWCOUNT)

Ans = 0

If LinkCount > 0 Then
Ans = LinkCount
End

Now when I am calling that from a Transformer stage derivation like :

MyGetLinkCount("TESTAA0005","Transformer_16","DSLink11")

I dont get any output value.However I got the value while testing it from outside with the same arguments.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Add a DSLogInfo() call to your routine that echos the input parameters, and then test that in the manager. Also, a job cannot attach to itself so if your routine gets passed the name of the actual job it will not return a value (in some versions it will hang for 30 minutes before returning nothing!). You can avoid that problem with a

Code: Select all

   IF DSGetJobInfo(DSJ.ME,DSJ.JOBNAME)#JobName THEN hJob = DSJ.ME
   ELSE hJob=DSAttachJob(JobName,DSJ.ERRFATAL)
aaikat
Participant
Posts: 47
Joined: Tue Mar 07, 2006 2:49 am

Post by aaikat »

The job name I am passing as an argument is different from the one I am working with.

When I put 'DSLogInfo' in the routine code, the message gets shown in Director Log,but the job seems to be hung up(running for long time).The control is not returning (for a small job which does almost nothing other than calculating those routine calls.)
aaikat
Participant
Posts: 47
Joined: Tue Mar 07, 2006 2:49 am

Post by aaikat »

What I dbout whether we can call a routine in the derivation of a Transformer stage.When I remove the routine call,it is running fine.
Do I need to explicitly return the control from routine.

Please help.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

aaikat wrote:What I dbout whether we can call a routine in the derivation of a Transformer stage.
Of course you can. Just recognize the fact that it will be called for every row processed. What does yor job process, by the way... a series of job / stage / link names? Any chance one of the jobs it is trying to attach to is itself? That can hang the job.
aaikat also wrote:Do I need to explicitly return the control from routine.
No, that's built it - but I would suggest you add a call to DSDetachJob in there.
Lastly, aaikat wrote:Please help.
I always wonder why people add things like that in their posts sometimes. Isn't that the whole point of coming here? Do people think we won't? :wink:
-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 »

You can call a routine from a transform stage. The DSAttachJob() call is pretty slow, so that might bring your rows/second speed down into the single digits. The call to DSLogInfo() is not your problem, that will not cause the delay you mentioned.
aaikat
Participant
Posts: 47
Joined: Tue Mar 07, 2006 2:49 am

Post by aaikat »

Yes,what I found is that a routine (without any DSAttachJob therein) runs fine when called from a Transformer stage. But when used it gets struck at the DSAttachJob.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

chulett wrote:What does your job process, by the way... a series of job / stage / link names? Any chance one of the jobs it is trying to attach to is itself? That can hang the job.
Well?
-craig

"You can never have too many knives" -- Logan Nine Fingers
aaikat
Participant
Posts: 47
Joined: Tue Mar 07, 2006 2:49 am

Post by aaikat »

The routine finds the count associated with the arguments job,stage,link.
So inside that it is opening just one job and I am sure the job from which I am calling the routine is no way the job I am attaching.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

At least put in some DSLogInfo() calls to show you at whichstatement in your routine the execution is being delayed.
aaikat
Participant
Posts: 47
Joined: Tue Mar 07, 2006 2:49 am

Post by aaikat »

Routine : MyGetLinkCount(JobName,StageName,LinkName)

Code is :


$INCLUDE DSINCLUDE JOBCONTROL.H

Call DSLogInfo("Inside Routine - Before Attach","Routine")

hJob=DSAttachJob(JobName,DSJ.ERRFATAL)

If NOT(hJob) Then
Call DSLogFatal("Job Attach Failed", "JobControl")
Abort
End

Call DSLogInfo("Inside Routine - After Attach before Get Link","Routine")


LinkCount = DSGetLinkInfo(hJob,StageName,LinkName,DSJ.LINKROWCOUNT)

Call DSLogInfo("Inside Routine - After Get Link","Routine")

Ans = 0

If LinkCount > 0 Then
Ans = LinkCount
End


I get upto this line in Log :

"Inside Routine - Before Attach"

which means DSAttachJob call is making it hung up.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Echo your input variables as well.

Code: Select all

CALL DSLogInfo('Routine input variableJobName is "':JobName:'"','')
CALL DSLogInfo('Routine input variableStageName is "':StageName:'"','')
CALL DSLogInfo('Routine input variableLinkName is "':LinkName:'"','')
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You can not attach an already-running job if that job is already attached to another process (such as a job sequence). That might explain a hang on DSAttachJob().
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