Custom Routine

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
PRIYARAJ
Participant
Posts: 41
Joined: Fri Jan 18, 2008 10:23 am

Custom Routine

Post by PRIYARAJ »

Hi

Can anyone help me write a custom routine?

I have a workdate & from the workdate I should get a date 30 days ago.


Thanks !
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You don't need a routine for that - simply use IConv to convert to internal format, subtract 30 and then OConv back to whatever external format you'd like.
-craig

"You can never have too many knives" -- Logan Nine Fingers
PRIYARAJ
Participant
Posts: 41
Joined: Fri Jan 18, 2008 10:23 am

Cutom Routine

Post by PRIYARAJ »

chulett wrote:You don't need a routine for that - simply use IConv to convert to internal format, subtract 30 and then OConv back to whatever external format you'd like. ...
Thanks for ur reply.Yes,If I do that in transformer stage,I can do that way.But i ahve to use this concept in Routine Activity Sequence & use it no where in the project except in Sequence.HOw to do in the sequence?
PRIYARAJ
Participant
Posts: 41
Joined: Fri Jan 18, 2008 10:23 am

Cutom Routine

Post by PRIYARAJ »

chulett wrote:You don't need a routine for that - simply use IConv to convert to internal format, subtract 30 and then OConv back to whatever external format you'd like. ...
Thanks for ur reply.Yes,If I do that in transformer stage,I can do that way.But I have to use this concept in Routine Activity Sequence & use it no where in the project except in Sequence.HOw to do in the sequence?
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Re: Cutom Routine

Post by gateleys »

No matter where you do the computation, the basic logic remains the same. Assuming your date is of the form 'YYYY-MM-DD', then as Craig pointed out, you can use -

Code: Select all

Oconv(Iconv(YourDate,"D-YMD[4,2,2]") - 30, "D-YMD[4,2,2])
gateleys
PRIYARAJ
Participant
Posts: 41
Joined: Fri Jan 18, 2008 10:23 am

Re: Cutom Routine

Post by PRIYARAJ »

gateleys wrote:No matter where you do the computation, the basic logic remains the same. Assuming your date is of the form 'YYYY-MM-DD', then as Craig pointed out, you can use -

Code: Select all

Oconv(Iconv(YourDate,"D-YMD[4,2,2]") - 30, "D-YMD[4,2,2])
I have the date format as 23012008[DDMMYYYY] . My code was

iDate=ICONV(Arg1,"DE")-Arg2

dateDiff=iDate-Arg2

Ans=Oconv(iDate,"DE")


Arg1 -WorkDate[23012008]
Arg2-30

When I run this code,I am getting the correct output
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Re: Cutom Routine

Post by gateleys »

I hope you understand the overhead of calling your function for every row!!

Why don't you just use the single line transformation? What's wrong with that?
gateleys
PRIYARAJ
Participant
Posts: 41
Joined: Fri Jan 18, 2008 10:23 am

Re: Cutom Routine

Post by PRIYARAJ »

gateleys wrote:I hope you understand the overhead of calling your function for every row!!

Why don't you just use the single line transformation? What's wrong with that?
Sorry for my last reply.The code is not working.I can use your code but the concerns are about the Format.As I have the format as DDMMYYYY which is not supported by Iconv or Oconv.Can you pls help me?
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Re: Cutom Routine

Post by gateleys »

All you had to do was take away the 'dash' in the format and rearrange the YMD to DMY-

Code: Select all

Oconv(Iconv(YourDate,"DDMY[2,2,4]") - 30, "DDMY[2,2,4])
gateleys
PRIYARAJ
Participant
Posts: 41
Joined: Fri Jan 18, 2008 10:23 am

Re: Cutom Routine

Post by PRIYARAJ »

gateleys wrote:All you had to do was take away the 'dash' in the format and rearrange the YMD to DMY-

Code: Select all

Oconv(Iconv(YourDate,"DDMY[2,2,4]") - 30, "DDMY[2,2,4])
Thank you so much.It works fine.
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Re: Cutom Routine

Post by gateleys »

Good. I wish you would mark the post 'Resolved'.
gateleys
Post Reply