How to stop a sequencer normally

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
gpbarsky
Participant
Posts: 160
Joined: Tue May 06, 2003 8:20 pm
Location: Argentina

How to stop a sequencer normally

Post by gpbarsky »

Hola mis amigos......

I am building a sequencer, which is controlled by the appearance of two files: PROCESSFILE.TXT indicates that the loop in the sequencer should invoke a batch job. ENDFILE.TXT indicates that the loop should end, and the sequencer also should end in a normal mode.

Any idea on how to do this ?

Thanks in advance.
:wink:
Guillermo P. Barsky
Buenos Aires - Argentina
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

I doubt that it's possible using StartLoop and EndLoop activities, which is what you seem to be asking. The StartLoop activity only effects a counted loop or a "list of things" loop; it does not effect an uncounted loop, and this is where your proposed algorithm fails. I'm surmising that you also propose a Wait For File activity, with a small timeout, for ENDFILE.TXT. You may be able to design this as a loop with a large number of iterations, but you would then probably need a Terminator to get out of the loop.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Re: How to stop a sequencer normally

Post by DSguru2B »

gpbarsky wrote: and the sequencer also should end in a normal mode.
What do you mean by normal mode?
Do you mean by just end and not continue processing ???

If you force abort the sequence job, it will abort. Not in a normal mode. You need to build your logic in such a way, so that it keeps checking for the arrival of ENDFILE.TXT after every piece of major processing, so that it braches away to stop further processing or continues.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
gpbarsky
Participant
Posts: 160
Joined: Tue May 06, 2003 8:20 pm
Location: Argentina

Post by gpbarsky »

My StartLoop activity is working from 1 to 500. But in the middle, I need to check the existence of the files.

If just PROCESSFILE.TXT exists, a job is invoked and then I have to continue with the loop.

If ENDFILE.TXT exists, I need to force the endloop activity, setting the $Counter variable to 501.

But anyway this is not working fine.

With "normal mode" I want to mean that no termination activity is used. I just want to end the job.

And thank you for your answers.
Guillermo P. Barsky
Buenos Aires - Argentina
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Still doesnt make sense.
Say for example your job is inserting a few hunder thousand records into the database and your end file shows up, how do you want to handle that? You cannot just end the job without aborting it or sending an explicit stop request.
I dont think termiinating the job at the very instance is a good idea if you want a clean stop. My advice, wait for that piece of execution to finish and then stop the batch.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

He's not saying that my Guru friend. It is exactly what you are saying - process X files and in-between every iteration look for a file that says you should stop any further processing. Break out of the loop rather than going on to the next file...
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

If thats the case then my apologies. Just couldnt get you the first time :oops:
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
gpbarsky
Participant
Posts: 160
Joined: Tue May 06, 2003 8:20 pm
Location: Argentina

Post by gpbarsky »

Let me clarify, if I can.

The DS process should be up from Monday to Friday, and it should be waiting for a file comming from SAP. The process of this file depends on the user decision. May be some days there's no file, and another days may be more than one file to process.

So, what I really need is to have the process waiting for the file to appear, from 8:00 AM to 8:00 PM.

I know that in BASIC code it very easy this, but I want to use a sequencer because it has good tools to achieve this.

The million question is how to stop the process al 8:00 PM, without having to press the "stop" button, and without having to use the "Terminator Activity".

Thanks for all your comments.
Guillermo P. Barsky
Buenos Aires - Argentina
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

So now, either the arrival of END file or arrival of 8 pm will terminate the sequence job.
Well i hate to break it to you but you will have to use some sort of Basic coding to achieve that.
Here's what i would do.
Within start loop and end loop have a wait for file activity that waits for the trigger file, once its found it braches over to the job you want to run, after its successful have a small routine that checks for either the presence of END file or time to cross 8pm. Either one of them is true your routine will return 1 else 0.
Depending upon return value you could start all over or terminate your sequence.
Terminating is not difficult, just branch it out to do something like , say for eg, branch it out to a routine activity to run UtilityMessageToLog(), or maybe a notification activity.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
gpbarsky
Participant
Posts: 160
Joined: Tue May 06, 2003 8:20 pm
Location: Argentina

Post by gpbarsky »

Ok Guru.

I'll try what you are saying, but I'm not understanding why I cannot use the DSWaitForFile activity of the sequencer to check the existence of a file within a loop activity.

Thanks again, and have a good day.
Guillermo P. Barsky
Buenos Aires - Argentina
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Who says you can't? :twisted:

Leave the Timeout Length set to zero and you get a single check.
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

As Craig pointed out you can. But thats only part of your test, the second part is the time 8:00pm
I wrote a quick little routine for you. It checks for existence of end file and checks for time. If file exists or time equals or exceeds 8:00pm, it will return 1 else 0. Depending upon that you can branch your execution to continue forward or terminate gracefully.

Code: Select all

      Equate RoutineName to "isFileOrTimeOut"

      EndFilePath = Arg1
      FilePresnt = @FALSE
      TimeOut = @FALSE

*Internal Time for 8:00pm
      TimeLimit=72000

*Check for presence of End file

      OpenSeq EndFilePath to endFile
      On Error
         Stop "Cannot open file:":EndFilePath
      End Locked
         FilePresent = @FALSE
      End Then
         CloseSeq endFile
         FilePresent = @TRUE
      End Else
         FilePresent = @FALSE
      End

*Check for 8:00pm

      If (Time() => TimeLimit)
      Then
         TimeOut = @TRUE
      END

*Return 1 if either end file is found or present time is equal
*or greater than 8:00pm

      If (FilePresent OR TimeOut)
      Then
         Ans = @TRUE
      END
      Else
         Ans = @FALSE
      END
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Post Reply