To get Job Status for jobs with Invocation ID

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
TPons
Participant
Posts: 18
Joined: Mon Jan 03, 2011 3:32 am
Location: India

To get Job Status for jobs with Invocation ID

Post by TPons »

Hi

I have a Multiple Instance enabled job which runs for 60 tables. Table name is used as Invocation ID.
I have created a sequence to form a loop which executes the job for all 60 Invocation IDs( Target table name). There is no dependency between one table load to any of other table load from these 60 table loads.

Though i have formed loop to execute the job one after another Invocation ID, I am not checking completion of one load to start another load to let the loads continue in parallel. I need to form another loop to get Job Status for the 60 Invocation IDs.

The following step is what stopping me to complete the sequence.

At the end of job sequence, I want to get the Job Status for each Invocation ID. If any of the loads for an Invocation ID has got aborted, I need to abort the sequence.
I am sure that I need to use kind of unix commands in an Execute Command Activity to get it done with in the second loop. As the original job status is in compiled staus, I dont know how to get Job Status for Invocation ID.

Please help me on this.

Thanks in Advance
TPons
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

There are a couple of methods of implementing this, but in your case you already have a loop in your job sequence to start the jobs so you have a list of instance names - so I would suggest you write a BASIC function which accepts your 60 table names as an input parameter and looks as follows:
(Parameter "InstanceList", comma separated)

Code: Select all

Ans = 0
FOR i = 1 TO DCOUNT(InstanceList,",")
   JobName = 'MyJobName.':FIELD(InstanceList,',',i)
   JobHandle = DSAttachJob(JobName,DSJ.ERRNONE)
   TryAgain:
   JobStatus = DSGetJobInfo(JobHandle,DSJ.JOBSTATUS)
   IF (JobStatus=DSJS.JOBRUNNING)
   THEN
      SLEEP 10
      GOTO TryAgain:
   END   
   IF NOT(JobStatus=DSJS.RUNOK OR JobStatus=DSJS.RUNWARN) THEN Ans += 1
   Dummy = DSDetachJob(JobHandle)
NEXT i
I never use GOTO in my programs, but I thought I'd keep this simple and not use the BASIC "DEL" function to strip elements from a dynamic array.

If Ans = 0 then none of the jobs failed, otherwise it returns the number of failed jobs.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

How are you running the jobs inside the loop? The Job Activity stage will automatically wait so you must be doing something else.
-craig

"You can never have too many knives" -- Logan Nine Fingers
TPons
Participant
Posts: 18
Joined: Mon Jan 03, 2011 3:32 am
Location: India

Post by TPons »

I am running the job through Job Activity which is set Invocation ID as Table Name and Triggering Expression Type as Unconditional.
As Job Activity output link is given to End Loop Activity and this link has unconditional trigger type, I believe that the loop continues till all Invocation IDs without waiting for completion of one load.
Please correct me if i am wrong.

Thanks
TPons
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The Job Activity will always wait for the job to complete. I thought you might be doing something like a command activity to issue a "dsjob -run ..." command in order to get this going in parallel.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Wondered if there was some confusion here, hence the question. Unconditional just means the trigger fires no matter what the exit status is.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply