Page 1 of 1

Posted: Fri Apr 15, 2005 8:47 am
by ArndW
palmeal,

I think you are close. You just neglected the DSAttachJob call.

If you code along the lines:

Code: Select all

LJobName = 'MyJob'
LStageName = 'MyStage'
LLinkName = 'MyLink'

   JobHandle = DSAttachJob(LJobName,DSJ.ERRFATAL)
   IF NOT(JobHandle) OR JobHandle=DSJE.BADHANDLE THEN CALL DSLogFatal('Bad attach to job "':LJobName:'".','MyFunction')
   Ans  = DSGetLinkInfo(JobHandle,LStageName,LLinkName,DSJ.LINKROWCOUNT)
   IF (Ans<0)
   THEN
      CALL DSLogWarn('Unable to retrieve rows through link "':LLinkName:'" in stage "':LStageName:'" for Job "':LJobName:'".',ProgramName)
      Ans = 0
   END ;** of if-then something went wrong
   Dummy = DSDetachJob(JobHandle) ;** close up the job

Posted: Fri Apr 15, 2005 8:58 am
by palmeal
Thanks Arnd

This is where I think I went wrong earlier on today when my Job Sequence wouldn't die.
My Job Sequence was running (called job_seq1) and I tried to do a DSAttachJob("job_seq1"). Obviously that was wrong as discussed earlier.

Should the Job Name in the DSAttachJob be the underlying Server Job that I am calling ?

Posted: Fri Apr 15, 2005 9:03 am
by ArndW
The name of the job that you are going to open is that which contains the stage & link that you are trying to get information for. If your function is called as an after-job subroutine then you would use DSJ.ME as the JobHandle.

If you want to avoid the hang and also use multi-instanciation then you can code:

Code: Select all

   MyJobName     = DSGetJobInfo(DSJ.ME,DSJ.JOBNAME)
   MyJobInstance = DSGetJobInfo(DSJ.ME,DSJ.JOBINVOCATIONID)
   IF (MyJobInstance) THEN MyJobName := '.':MyJobInstance ;** make a full jobname if a multi-instance call
   IF (MyJobName=LJobName) THEN Ans = DSJ.ME ;** return the DSJ.ME mnemonic code to the caller
   ELSE
      Ans = DSAttachJob(LJobName,LErrorMode)
   END ;** of if-then-else trying to open own job
to work around the potential problem of hanging while trying to attach to yourself.

Posted: Fri Apr 15, 2005 9:05 am
by palmeal
Thanks again Arnd - I'll give this a try and see how I get on - won't be able to feedback until Tuesday though.

Posted: Fri Apr 15, 2005 9:14 am
by ArndW
Good luck to you up in the far northern part of the island.

Posted: Tue Apr 19, 2005 7:45 am
by palmeal
Couldn't get this to work unfortunately - despite being able to return the job name, short/long description, stageName and LinkName the rowcount returned was always 0. Have given up just now and just gone for a 'wc -l' and an awk statement.

Posted: Tue Apr 19, 2005 8:38 am
by ArndW
Palmeal,

Craig caught it and I missed it! You cannot get the link count information from Sequences, only from Jobs.

-Arnd.