Access to the Job Identifier in Teradata PT job scripts

Tools
Tools covers the tools and utilities you use to work with Teradata and its supporting ecosystem. You'll find information on everything from the Teradata Eclipse plug-in to load/extract tools.
Teradata Employee

Access to the Job Identifier in Teradata PT job scripts

TPT constructs a unique identifier for each TPT job submitted for execution. Even though it is not generated until your job executes, you can reference its unique job identifier in your job script via the new script keyword $JOBID. The job identifier consists of the job name and a TPT-generated job sequence number, joined by the hyphen character ('-'):

    <job name> - <job sequence number>

Job Name

The value for <job name> is dependent upon the Operating System used.

  • on UNIX and Windows:

the name you optionally give to your job on the tbuild command line when you submit it:

tbuild  -f  <script file name>  ...  <job name>

When you do not name the job on the command line, the value for <job name> defaults to your logon user name on the host system on which you run the job.


Examples:

tbuild  -f  daily_load3.tpt  -v  dvars.jv  dload3
tbuild -f weekly_ld.tpt -v wvars.jv



The <job name> in the 1st example is dload3 and the <job name> of the 2nd example is SmithJ for the user whose logon name is SmithJ. 

  • on z/OS:

The MVS job name your job will have when submitted for execution, as specified in the JOB statement in the JCL (Job Control Language) for your TPT job:

//<job name> JOB ( ... ) <job parameters> 


Example:

//TPTLOAD2 JOB (22150000),'J SMITH',CLASS=A

The <job name> in this example is TPTLOAD2.

Job Sequence Number

The value for <job sequence number> is a consecutive number that is the count of the number of TPT jobs submitted on the your client host machine. If you submit successive TPT jobs on any client host, then the <job sequence number> of the 2nd job will be one higher than the <job sequence number> of the 1st job.

Example TPT job identifiers:

dload3-423     SmithJ-95     TPTLOAD2-1128

Coding the Job Identifier -- $JOBID

Since TPT constructs a unique job identifier for each job when it is executed, and since this identfier is different each time any given job script is executed, it would be impractical, to say the least, to try to explicitly reference the job identifier in a job script by anticipating what job sequence number will be assigned upon its execution.

To make the job identifier accessible to the job script, TPT, starting with release 13.10, now supports the script keyword $JOBID, which represents the job identifier -- as a quoted string -- that TPT will construct for each job that results from the execution of the job script.

For example, if you wanted to have the job identifier be part of the name of an operator's private log file, you would code that part of your script as follows:

VARCHAR PrivateLogName = $JOBID || '.log'

Then, if you submit the script, name the job test_job5 and it is the 144th TPT job run on your client machine, the private log file would be named

     test_job5-144.log

The $JOBID feature allows you to use the unique TPT-constructed job identifier in the names of script items, which can be especially useful for items which persist after job execution, like log files.

Tags (1)
2 REPLIES
Supporter

Re: Access to the Job Identifier in Teradata PT job scripts

Hi,

good news.
Are there more internal variables like $JOBID?

Ulrich
Enthusiast

Re: Access to the Job Identifier in Teradata PT job scripts

Is there a practical way to get the JobName and JobId post script execution?  Mutliload can output internal variables with an .OS command.  Can TPT do the same?