Page 1 of 2

Problem in using DS Routine

Posted: Wed Jun 07, 2006 3:35 am
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.

Re: Problem in using DS Routine

Posted: Wed Jun 07, 2006 3:37 am
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?

Posted: Wed Jun 07, 2006 3:53 am
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.

Posted: Wed Jun 07, 2006 4:01 am
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)

Posted: Wed Jun 07, 2006 5:07 am
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.)

Posted: Wed Jun 07, 2006 5:44 am
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.

Posted: Wed Jun 07, 2006 6:02 am
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:

Posted: Wed Jun 07, 2006 6:09 am
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.

Posted: Wed Jun 07, 2006 6:18 am
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.

Posted: Wed Jun 07, 2006 6:31 am
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?

Posted: Wed Jun 07, 2006 7:11 am
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.

Posted: Wed Jun 07, 2006 7:27 am
by ArndW
At least put in some DSLogInfo() calls to show you at whichstatement in your routine the execution is being delayed.

Posted: Wed Jun 07, 2006 8:09 am
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.

Posted: Wed Jun 07, 2006 8:19 am
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:'"','')

Posted: Wed Jun 07, 2006 3:40 pm
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().