Page 1 of 1

capturing Job's Version Number for audit meta-data

Posted: Fri Mar 02, 2007 12:35 pm
by katz
Hi,

I want to capture a job's version number (i.e. the version number in the General tab of the Job Properties window) in my runtime meta-data. A perfect solution would be a using an InfoType in the DSGetJobInfo function, but this does not seem to be supported (at least its not documented). Neither does the version number appear in the output of the DSMakeJobReport function.

Are there any other means that I use to obtain the job's version number?

Thanks,
katz

Posted: Fri Mar 02, 2007 1:37 pm
by chulett
:? Are you Releasing your jobs? That's the only process that increments that value, from what I recall, unless you are doing it manually...

Posted: Fri Mar 02, 2007 3:35 pm
by ray.wurlod
Version Control also increments the version number, and it's possible that developers do also.

You can query the Repository using a "UV" command in DSExecute.

Code: Select all

SELECT NAME, EVAL "@RECORD<8>" AS VERSION FROM DS_JOBOBJECTS WHERE OBJTYPE = 'J' AND OBJNAME = 'ROOT' AND OBJIDNO = (SELECT JOBNO FROM DS_JOBS WHERE NAME = '<<Job Name>>') COL.SUP COUNT.SUP;
You will need to parse out the penultimate field from the result.

Posted: Fri Mar 02, 2007 3:51 pm
by chulett
Doh! Forgot that little tidbit. :lol:

Posted: Fri Mar 02, 2007 6:51 pm
by kduke
Ray is correct. The result for a job might be 50.1.0 which would indicate version 1.

Posted: Fri Mar 02, 2007 7:19 pm
by ray.wurlod
Here's a cute variation on the theme, retrieving the result as a single expression (for example to set a job parameter value). You need the job name from somewhere.

Code: Select all

Trans("DS_JOBOBJECTS", "J\" : Trans("DS_JOBS", JobName, 5, "X") : "\ROOT", 8, "X")
It returns a zero length string if the job is not found.

Posted: Sun Mar 04, 2007 6:17 am
by katz
Thanks Mucho! I have it working now. The proof-of-concept Routine is below.

From this point there are a couple of directions that I can take it...
...obtain the job version of a specfic job at run-time, to include with my job run audit data.
...generalise it a bit and select the job names and versions for all jobs LIKE the input argument (i.e. what are the job versions running in Production for all jobs LIKE 'abc%').

katz

Code: Select all

FUNCTION TestJobVersion(Arg)
      v_Cmd = ''
      v_Cmd = "SELECT JOBNO TO SLIST 9 FROM DS_JOBS WHERE NAME = '":Arg:"';" 
      Perform v_Cmd 

      * Convert Select List 9 into dynamic array 
      ReadList d_jobNumber From 9 
         Then v_jobNumber = d_jobNumber<1> 
         Else 
              Ans=-2 
              Return(Ans)
         End 

      v_Cmd = ''
      v_Cmd = "SELECT  EVAL '@RECORD<8>' TO SLIST 9 FROM DS_JOBOBJECTS WHERE OBJTYPE = 'J' AND OBJNAME = 'ROOT' AND OBJIDNO = '":v_jobNumber:"';"
      Perform v_Cmd

      * Convert Select List 9 into dynamic array 
      ReadList d_jobVersion From 9 
         Then Ans = d_jobVersion<1> 
         Else 
              Ans=-1
         End

RETURN(Ans)

Posted: Sun Mar 04, 2007 10:28 am
by ray.wurlod
How about:

Code: Select all

FUNCTION TestJobVersion(TheJobName)
* Returns job version number if found, or "" otherwise

Ans = Trans("DS_JOBOBJECTS", "J\":Trans("DS_JOBS", TheJobName, 5, "X"):"\ROOT", 8, "X")

RETURN(Ans)

Posted: Sun Mar 04, 2007 3:44 pm
by katz
Thanks Ray,

That is a certainly lot more elegant. It even seems to run faster. A clear improvement. I've not worked with the TRANS or XLATE functions until now; it seems like a bit of a play-about is in order. :)

katz

Posted: Sun Mar 04, 2007 8:38 pm
by ray.wurlod
XLATE is a synonym for TRANS, as your researches will have revealed.