Abort Job While No rows in Source File

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
Rubu
Premium Member
Premium Member
Posts: 82
Joined: Sun Feb 27, 2005 9:09 pm
Location: Bangalore

Abort Job While No rows in Source File

Post by Rubu »

Hi


Job1. Load Data To Sequential File S1

Job2. S1-------->Target

While running job Job2, I want to check the source file S1 for data. If there is no row in the file I want to exit the job with Status Success. How it can be done? Please suggest.

Regards
rubu
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Why do you need that? That is the default behaviour of datastage.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

In other words, there is absolutely no problem with processing an 'empty' sequential file. The job will simply process zero records and then declare everything good, green and A-Ok.

You problem will come in if the file does not exist. That will cause the job to abort.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Add job control code (job properties dialog) to perform the check and issue a DSStopJob(DSJ.ME) request. Job control code, if present, is executed before any stage is opened.

Code: Select all

FileName = DSGetParamInfo(DSJ.ME, "FileName", DSJ.PARAMVALUE)
If FileName < 0
Then
   Call DSLogFatal("Unable to get FileName job parameter value", "Job control")
End
Else
   Command = "wc -l " : FileName
   Call DSExecute("UNIX", Command, Result, ExitStatus)
   If ExitStatus = 0
   Then
      If Oconv(Result, "MCN") = 0
      Then
         Call DSLogInfo("Job stopped because input file empty.", "Job control")
         ErrCode = DSStopJob(DSJ.ME)
      End
   End
   Else
      Call DSLogWarn("Error in wc command: " : @FM : Result, "Job control")
      ErrCode = DSStopJob(DSJ.ME)
   End
End
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Rubu
Premium Member
Premium Member
Posts: 82
Joined: Sun Feb 27, 2005 9:09 pm
Location: Bangalore

Thanks

Post by Rubu »

Thanks Ray.....
Post Reply