Page 1 of 2

Fundamentals of Basics Routines

Posted: Sun Feb 26, 2006 4:15 pm
by Dsnew
I have a very fundamental question regarding routines.
Can somebody please tell me where we can write routines in datastage.
I would appreciate if somebody could give me a example of a simple routine and where to write it in DS.
Please dont ignore it as a very basic/fundamental question.
Can i pass values and get returned values from routines too?

Thanks in advance

Posted: Sun Feb 26, 2006 4:42 pm
by chulett
Dsnew - nothing gets ignored here. :wink:

You write Routines via the Manager client tool. When your cursor is over in the Routine branch of the repository, the File menu will give you the option to create a New Server Routine. You can also copy an existing one and edit it much the same way you would do that for any other object, like a job or table metadata.

Rather than provide a simple routine, why not take a look at the Routines that come with the product? In that same branch are many different categories of routines, simply double-click on one to check its properties and to see the code behind it. I've found that exploration to be quite worthwhile as they are generally well documented as to how they work and the code something you could learn from.

And yes, you can certainly pass values as 'arguments' to a Routine. Note, however, that they can only return a single value (although you could always stash multiple bits of data in that 'single value') and the name of that value is hard-coded to Ans so you would need to ensure anything you write sets that properly.

ADVERTISEMENT

Posted: Sun Feb 26, 2006 4:48 pm
by ray.wurlod
We expect shortly to announce availability of a beginners' class in writing server routines. (This is already available from my personal business, we're working on offering it through DSXchange.)

Posted: Sun Feb 26, 2006 5:21 pm
by Dsnew
Thank you chulet.

But how do we know which header file to include ?

Also can you please throw some light on the types
-Transform function
-Before/After Subroutine
-Custom Universe Function
Does the coding method change for these types?

Posted: Sun Feb 26, 2006 7:50 pm
by chulett
Header file? Experience. You could go through the included routines and see which ones include which headers and try to figure out why. You could also find the header files under your DSEngine directory and examine them there. You'll be able to tell from what's defined in them when you would need to use them.

As for the other questions, they mostly dictate where it can be used. Transform functions are used in Transform derivations, constraints, etc and can have multiple inputs but only one output. B/A subroutines take only one input and only return a status, nothing more. Never played with Custom Universe Functions, so not really sure but not something a typical user would need.

Try creating a new routine and switching the Type yourself to see how the Arguments and Code tabs change accordingly.

Posted: Mon Feb 27, 2006 10:33 am
by ray.wurlod
Custom UniVerse functions were originally intended for DataStage customers who already had their business rules functions written in the UniVerse database, which was the original engine for DataStage. This is no longer the case, so it's a requirement that is likely to atrophy in DataStage. As a beginner, the best idea is to forget that it is there.

Other than that, Craig has pretty much covered the territory.

Re: Fundamentals of Basics Routines

Posted: Mon Feb 27, 2006 11:54 am
by parag.s.27
Dsnew wrote:I have a very fundamental question regarding routines.
Can somebody please tell me where we can write routines in datastage.
I would appreciate if somebody could give me a example of a simple routine and where to write it in DS.
Please dont ignore it as a very basic/fundamental question.
Can i pass values and get returned values from routines too?

Thanks in advance
Hi,
You can write basic routines in a very simple way. You can see the Routines category in the left hand side pane. you can just right click on that category and select new routine.

In the new opened work space you can define arguments, to which you can pass values from any transformer when you call the routine. Then in the code area you can use those arguments. Just remember to return the answer at the end of ur logic

Posted: Mon Feb 27, 2006 10:39 pm
by rasi
Go to Routines Folder in the Designer. By default you won't see the routine folder. You need to enable this by clicking Tools/options and inside that go to appearance/Repository Tree. Click Show routines.

A good start is to look at the existing routine codes. Double any routine and inside that click the code tab you will find the codes used for that routine

Posted: Mon Feb 27, 2006 11:00 pm
by chulett
Do you guys skip over all the previous replies when you reply to a thread? Just wondering as you've both basically just gone over ground we've already covered. :?

Posted: Mon Feb 27, 2006 11:21 pm
by rasi
Thanks for mentioning that Craig. I did skipped all previous thread.

Re: Fundamentals of Basics Routines

Posted: Tue Feb 28, 2006 3:58 am
by ram.m
Dsnew wrote:I have a very fundamental question regarding routines.
Can somebody please tell me where we can write routines in datastage.
I would appreciate if somebody could give me a example of a simple routine and where to write it in DS.
Please dont ignore it as a very basic/fundamental question.
Can i pass values and get returned values from routines too?

Thanks in advance

Hi,

there are 2 ways to write routines.u can write routines in designer and Manager.in Designer in the repository items rightclick on the routine and select create routine.a window will be dispaly.there u can write.in Manager also same way.

Thanks
Ram

Posted: Tue Feb 28, 2006 8:07 am
by chulett
:roll:

Posted: Tue Feb 28, 2006 8:29 am
by ray.wurlod
There are, indeed, other ways to write routines, including in text files outside of DataStage. But let's not muddy the waters!

Posted: Tue Feb 28, 2006 8:58 am
by I_Server_Whale
Ram, Rasi and Parag,

Please don't ridicule yourselves. There is no point in repeating the same over and over again.

Many Thanks,
Naveen.

Posted: Tue Feb 28, 2006 9:06 am
by kcbland
Let's all remember that premium content answers are not visible to everyone, and therefore, some non-premium folks may answer something similar to a premium content answer without knowing it. :wink: