Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to execute a job reading the parameters in a file.

Status
Not open for further replies.

irinac

IS-IT--Management
May 14, 2002
1
FR
There are two routines and an example of a master job who can help to execute the jobs in a master without parameters.

1.The first ExecCompil subroutine is a routine who compile a job if it is aborted.

Arguments:

InputArg = The Job Name
***********************************************************
*$INCLUDE DSINCLUDE DSD.H
*$INCLUDE DSINCLUDE DSD_STAGE.H
*$INCLUDE DSINCLUDE DSD_RTCONFIG.H
*$INCLUDE UNIVERSE.INCLUDE ODBC.H
*$INCLUDE DSINCLUDE DSD_BCI.H
$INCLUDE DSINCLUDE JOBCONTROL.H


hJob1 = DSAttachJob(InputArg, DSJ.ERRFATAL)

NomJob = DSGetJobInfo(hJob1, DSJ.JOBNAME)


Status = DSGetJobInfo(hJob1, DSJ.JOBSTATUS)



If Status = DSJS.RUNFAILED Then
ErrCode = DSRunJob(hJob1, DSJ.RUNRESET)
ErrCode = DSWaitForJob(hJob1)
End

ErrCode = DSDetachJob(hJob1)

*JobNom = DSAttachJob(hJob1, DSJ.ERRFATAL)

Return
***********************************************************
2. The second subroutine ExecRunJob is for running a job:

Arguments:

InputArg = NomFic%Section%JobNom%
where

NomFicher = The path and the name of file of parameters (ex : /soft/datastage/CONFIG.ini)

Section = The section tu use in the file (ex : PROD/DEV/TEST)

JobNom = The name of the job


***********************************************************
*$INCLUDE DSINCLUDE DSD.H
*$INCLUDE DSINCLUDE DSD_STAGE.H
*$INCLUDE DSINCLUDE DSD_RTCONFIG.H
*$INCLUDE UNIVERSE.INCLUDE ODBC.H
*$INCLUDE DSINCLUDE DSD_BCI.H
$INCLUDE DSINCLUDE JOBCONTROL.H

DEFFUN RechercheParam(Arg1, Arg2, Arg3) Calling "DSU.RechercheParam"

NomFicher = Field (InputArg,'%',1)
Section = Field (InputArg,'%',2)
JobNom = Field (InputArg,'%',3)


*Insertion des infos du démarrage du job

hJob1 = DSAttachJob(JobNom, DSJ.ERRFATAL)
NomJob = DSGetJobInfo(hJob1, DSJ.JOBNAME)

ListeParam = DSGetJobInfo(hJob1, DSJ.PARAMLIST)
NbParam = DCount(ListeParam, ",")

For i = 1 to NbParam
NomParam = FIELD(ListeParam, ",", i)
ValParam = RechercheParam(NomFicher, NomParam, Section)
ErrCode = DSSetParam(hJob1, NomParam, ValParam)
Next i


If NOT(hJob1) Then
Call DSLogWarn("Job Failed: ":NomJob, "ExecRunJob")
Abort
End

ErrCode = DSRunJob(hJob1, DSJ.JOBSTATUS)
ErrCode = DSWaitForJob(hJob1)
Status = DSGetJobInfo(hJob1,DSJ.JOBSTATUS)

If Status = DSJS.RUNFAILED Then
* Fatal Error - No Return
Call DSLogWarn("Job Failed: " : NomJob, "ExecRunJob")
End


ErrCode = DSDetachJob(hJob1)
Return
***********************************************************

3. The third function RechercheParam looks for the parameters in a config file (CONFIG.ini)

Arguments:

NomFichier = File name and path(ex : /soft/datastage.CoNFIG.ini)
NomParametre = The name of the variable to look for
NomSection = The name of the Section (ex : PROD/DEV...)

***********************************************************


$INCLUDE DSINCLUDE JOBCONTROL.H

RoutineName="RechercheParam"
Ans=''

OpenSeq NomFichier To PtFichier
Else
Message="Impossibe to open the file"
Goto ErrorWay
End


Loop
ReadSeq Ligne FROM PtFichier
Else
Message="Immposible to read the file or the section wasn't found"
Goto ErrorWay
End
While UpCase('[':NomSection:']') <> UpCase(Ligne)
Repeat

Loop
ReadSeq Ligne FROM PtFichier
Else
Message=&quot;Immposible to read the file or the name of the parameter wasn't found&quot;
Goto ErrorWay
End
While UpCase(NomParametre:' ') <> UpCase(field(Ligne,'=',1))
Repeat

Ans= field(field(Ligne,'=',2),' ',2)
Goto End

ErrorWay:
Call DSLogWarn(Message, RoutineName)

End:
***********************************************************

4. The master job:

NomFicher = File name and path(ex : /soft/datastage.CONFIG.ini)
Section = The name of the Sect
ion (ex : PROD/DEV...)


***********************************************************

DEFFUN RechercheParam(Arg1, Arg2, Arg3) Calling &quot;DSU.RechercheParam&quot;
DEFFUN ExecRunJob(InputArg, ErrorCode) Calling &quot;DSU.ExecRunJob&quot;
DEFFUN ExecCompil(InputArg, ErrorCode) Calling &quot;DSU.ExecCompil&quot;


* Setup Job_Name, run it, wait for it to finish, and test for success
hJob1 = DSAttachJob(&quot;Job_Name&quot;, DSJ.ERRFATAL)

JobName = DSGetJobInfo(hJob1, DSJ.JOBNAME)

Call DSU.ExecCompil(JobName, 0)
Call DSU.ExecRunJob(NomFicher :&quot;%&quot; : Section : &quot;%&quot; : JobName, 0)

***********************************************************
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top