DSWaitForFile

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
jo8712
Participant
Posts: 12
Joined: Tue Nov 04, 2003 7:41 am

DSWaitForFile

Post by jo8712 »

Aside from proper syntax, is there anything else needed to get the DWWaitForFile before-job subroutine such as scheduling the job or anything else. I have the correct path in the DSWaitForFile test box and I also have the correct path in for my SrcDir....do I need to add a parameter for DSWaitForFile?

My syntax is

Reply = DSWaitForFile("\DataStage60\Ascential\DataStage\Projects\morphius\Household.csv timeout:3600/60")

Anything wrong with this?
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

The code generated in a batch job looks like this:

Code: Select all

* Setup GetInformixMetadata, run it, wait for it to finish, and test for success
hJob1 = DSAttachJob("GetInformixMetadata", DSJ.ERRFATAL)
ErrCode = DSSetParam(hJob1, "pSystemId", SystemId)
ErrCode = DSSetParam(hJob1, "pSID", SID)
ErrCode = DSSetParam(hJob1, "pSourceName", DsnId)
ErrCode = DSSetParam(hJob1, "pUserId", UserId)
ErrCode = DSSetParam(hJob1, "pPwd", Pwd)
ErrCode = DSRunJob(hJob1, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(hJob1)
Status = DSGetJobInfo(hJob1, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Then
   * Fatal Error - No Return
   Call DSLogFatal("Job Failed: GetInformixMetadata", "JobControl")
End
Notice DSWaitForJob(hJob1) where hJob1 is the return from DSAttachJob. This is a special variable and not the path to the job running. It is a pointer to the job. You cannot shortcut this process. You need all these steps to run a job and wait for it. This code is easily generated in job control of a batch job. All you have to do is select a job from the drop down list.

Kim.
Mamu Kim
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Errr... Kim?

WaitforFile, not WaitForJob. :roll:
-craig

"You can never have too many knives" -- Logan Nine Fingers
jo8712
Participant
Posts: 12
Joined: Tue Nov 04, 2003 7:41 am

Post by jo8712 »

I'm not trying to run a job by waiting for another job, I have created a job and am merely waiting for a file to be FTP to my server, than I want my job to kick off every time it sees that file(or a new version of that file). That is what I was trying to set up the DWWaitForFile for.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Just to get picky... Doing this in a before routine, the job won't "kick off" when the file arrives. You'll need to start the job and then the DSWaitForFile routine will poll for the existence of the file. Once the file shows up or your polling window is exceeded, the meat of the job will continue on.

Your syntax looks fine, what kind of problem are you having exactly? You may want to consider using the routine in a controlling Batch Job instead of a before-job routine. That way you can run the job that processes the file when it shows up or not run the job if it fails to show up and alert someone to that fact.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

My bad.
jo8712
Participant
Posts: 12
Joined: Tue Nov 04, 2003 7:41 am

Post by jo8712 »

Thanks for the Job Control suggestion, it worked!
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Excellent! Appreciate you coming back and letting us know everything worked out ok.
-craig

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