Start Loop

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
thumsup9
Charter Member
Charter Member
Posts: 168
Joined: Fri Feb 18, 2005 11:29 am

Start Loop

Post by thumsup9 »

Hello All,

I am currently running a job from a sequencer.The Sequencer has a Start Job Activity and End Loop. I have to run the same job for number of days say 20 or more.

I am currently passing the a parameter in the start loop and the value is in format YYYYMMDD

From -- #BeginDate#
Step--- 1
To----- #EndDate#

Its runs good, but i know this isnt a right approach and this wont solve my problem.I want to pass the date not as numeric but in its original format say YYYY-MM-DD or MM-DD-YYYY.

Please advice,

Thanks,
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

You still can convert the integer into date in you job.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Re: Start Loop

Post by chulett »

thumsup9 wrote:Its runs good, but i know this isnt a right approach and this wont solve my problem.I want to pass the date not as numeric but in its original format say YYYY-MM-DD or MM-DD-YYYY.
You can't - not if you want the Loop stages to control the iterations. You'd have to roll your own, I would think, if you really want to stick with ISO dates for some reason.

There's nothing wrong with your approach per se, and you'll need to stick with 'numeric' dates - the only thing you are missing is converting them to internal format first. If you do that then you can iterate from BeginDate to EndDate with a step of 1, with each step being a day.
-craig

"You can never have too many knives" -- Logan Nine Fingers
thumsup9
Charter Member
Charter Member
Posts: 168
Joined: Fri Feb 18, 2005 11:29 am

Post by thumsup9 »

Thx Craig and Kumar,

I think i was confused and also confused you,

I have main sequencer job sqDimensionLoad.It has 3 job activities,

loadjob1,loadjob2,sqloadjob3.( All these jobs take #BeginDate# retunred by a routine as input to run each day 10/28 )

sqloadjob3 is a sequencer by itself which has 1 job activity

startloop--loadjob3--endloop.

I want to run sqloadjob3 job for say 2days (10/26,10/27,10/28 back from #BeginDate# ,how do I run this particular job for 3 different days while calling this job from sqDimensionLoad where we are passing #BeginDate#

Please ask me if you need further clarification,

Thanks,
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Create a delimited list of dates in an upstream Routine, and use that as the driver for a List loop. Error handling has been omitted here for clarity.

Code: Select all

FUNCTION ListOfDates(StartDate,EndDate)
intStartDate = Iconv(StartDate, "DYMD")
intEndDate = Iconv(EndDate, "DYMD")
Ans = ""
For intDate = intStartDate To intEndDate
   Ans<-1> = intDate
Next IntDate
Convert @FM To "," In Ans
RETURN(Ans)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Ray's got another way having the Loop step through a delimited list of dates. Don't see why the way I outlined wouldn't work as well, the decider would be how you needed to use the parameter, if you had a chance to switch it back to 'external' format within the job or if you needed to use it before there would be any chance to do that - like in SQL.

Probably easiest to take Ray's route as it can use the dates in the format you'd prefer. Then something like this in the Job Activity stage that runs sqloadjob3 to pass in the iteration date from the delimited list:

Code: Select all

Trim(EReplace(YourLoopList.$Counter,@FM,""))
-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 »

The routine could always switch them back, returning instead a list of external format dates. I just happen to prefer using internal format in server jobs.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
thumsup9
Charter Member
Charter Member
Posts: 168
Joined: Fri Feb 18, 2005 11:29 am

Post by thumsup9 »

Thanks Ray and Craig. I wanted to get back to you once I test it against our scenario and you know my answer, that fits perfectly.Thanks for all your inputs...

Thums !!
Post Reply