Job Info

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

Post Reply
amsh76
Charter Member
Charter Member
Posts: 118
Joined: Wed Mar 10, 2004 10:58 pm

Job Info

Post by amsh76 »

I have a situation where I need to log Job information in the file. There are DS routines that I can use ? And is it anyways I can run them afterstage or afterjob ? I want the timestamp, row count, job name..all these write into flat file in same job.

And if someone can tell me in steps as to how to run this in afterjob or afterstage ?
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

You can write a routine to be called in the after-job routine or in a controlling job. The appropriate API's (DS*) are in your DS BASIC manual. The steps are to attach to a job, get its stage list, loop thru the stage list getting the link list and for each link the row count. You'll have to learn about opening a sequential file (OPENSEQ), writing data to a sequential file (WRITESEQ) and close it when finished (WEOFSEQ, CLOSESEQ). Have fun!
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Question your need. This information is already captured into the job's own log (which happens to be a table in the Repository). You can print, or print to file, from the Director client on those odd occasions you genuinely need to capture these data into a file.

Yes, you can do it all in code, but why re-invent the wheel?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
amsh76
Charter Member
Charter Member
Posts: 118
Joined: Wed Mar 10, 2004 10:58 pm

Post by amsh76 »

yeah thats true Ray, but thats the Client requirement....thats how they want. That was the first thing I suggested but they wanted it to be written in the file as soon as the job is executed. :cry:

Can you throw more light on this.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Yes, you can have a great deal of free time by requiring their specifications to be documented. For example:
  • Which row count? Row counts are different on different links (for example they are ideally zero on reject-handling links).

    What is their business rule for "timestamp"? That is, which particular timestamp do they want? Job start, job finish, active stage start/finish, and so on.

    What naming convention is required for the output file? Should it be overwritten or appended to. How is it to be further processed? (If you don't get an answer on this, don't do the time-wasting work.)

    What is their business rule for capturing the invocation ID should you, the developer, elect for performance reasons to create multiple-instance jobs and run them in parallel? What are the implications then for the output file name?
You create a before/after subroutine as a new Routine, and choose "before/after subroutine" as its type. There are exactly two arguments; the first (by default called "InputArg") accepts whatever is in the Input Value field of its caller (job parameter references are resolved before the before/after subroutine is called). The second argument (by default called ErrorCode and initialized to zero) is used to halt execution of the job if necessary (I believe that jobs should be written so that abort is never necessary.).

Functions you need include DSGetJobInfo (for job name and job start time stamp) and DSGetLinkInfo (for row counts). In intermediate steps you will probably also need DSGetStageInfo (to get a list of the link names attached to an active stage).

As Ken suggested, the statements needed for manipulating the output file are OpenSeq, WriteSeq and CloseSeq (and possibly WeofSeq if you're going to truncate or Seek if you're going to append).
All of these functions and statements are in on-line help from Designer.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

There is a job on ADN you can download called DSJobReport.dsx. I modifed this to dump straight to 3 Oracle tables. One for job stats, one for row stats and one for parameter stats. I should post it back this week with my changes.

You need to job stats because not all jobs have row counts like sequences. The next you need history to show rows per second over time. Is this job getting slower. The last thing is parameter history because if a job fails it may be because the parameter had the wrong value.
Mamu Kim
girishoak
Participant
Posts: 65
Joined: Wed Oct 29, 2003 3:54 am

Post by girishoak »

Hi All,

I have recently prepered a DSJob to get log that takes input as file name. this Input file contains list of job names for those log is required. After running this job. It creates a text file containinng jobname, stagename, no. of rows (in as well as out) and time elapsed. If you wish I wont mind to share it.

It would be great if kim, ray and other DS Guru review the code and fine tune that. I will try to upload this code in next few days.

Regards

Girish Oak
Post Reply