How to write DS Server Routine and call in job?

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
ayadav77
Participant
Posts: 26
Joined: Wed Jun 18, 2014 11:51 am
Location: Pune

How to write DS Server Routine and call in job?

Post by ayadav77 »

I am trying to write server routine in datastage, but not getting how to start.
Can anyone tell me the syntax for writting routines or provided the link for good material for wrtting routines?

I will really APPRECIAT!!! for reply :wink:
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

This forum has many posts with examples; as does the documentation.

You posted in the Parallel forum. DS Server Routines can be called from Parallel Jobs only as Before/After job subroutines or if you include Server Transform stages.

The programming language is DataStage BASIC, which is quite close to UniVerse BASIC (now owned by Rocket Software). Again, the documentation offers the full programming manual for download as a PDF.

Perhaps you could tell us what you want to do and you will get better answers.

IBM Introduction to DataStage BASIC
ayadav77
Participant
Posts: 26
Joined: Wed Jun 18, 2014 11:51 am
Location: Pune

Post by ayadav77 »

Hi ArndW ,
Thnx for ur reply :)

I was trying to write a simple routine to genrate sequence no. to records in table like (1,2,3....)
Plzz tell the syntax for writing routines.

One thing i want to ask that, we can do any transformation through routine which we do through using different stages?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Decided to push this over to the General forum where we can discuss all aspects of routine creation. And why create a routine that already exists and ships with the product? It's called "KeyMgtGetNextValue". :wink: If you find it and open it up as if you were going to edit it (don't) you'll be able to see the source code.

As to the "any transformation" question, that's basically a yes - no pun intended. The BASIC language that ships with DataStage is very powerful... what you can do with it is limited only by your skill set.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ayadav77
Participant
Posts: 26
Joined: Wed Jun 18, 2014 11:51 am
Location: Pune

Post by ayadav77 »

Thnx ArndW :)

I will push it to General forum, n wait for ur reply!!
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I already moved it there... we're here right now. And replied as well. I'm no Arnd but I think I can hold my own.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ayadav77
Participant
Posts: 26
Joined: Wed Jun 18, 2014 11:51 am
Location: Pune

Post by ayadav77 »

Chulett,

Sorry 4 typo error :P

I am new to routines in Datastage.

Can u breif me about Routines and give sample code for routines so that I can start writting routines?
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

azadav77,

this is a message forum and not an SMS chat, so please try to communicate using real words to avoid errors. While smileys are common, please use the word "for" rather than "4" and "you" rather than "u"; it makes things much easier to understand for those of us, including myself, to whom English is not our mother tongue.

Did you follow the link I posted earlier? That contains a lot of information on the programming language and also points to examples, and there are also a lot of examples here in the various threads.

As Craig has stated, there are embedded methods of creating sequences in Datastage. The simplest is using either @INROWNUM or @OUTROWNUM in transform stages, then you have the key management routines that Craig has alluded to.

Asking for code like this isn't going to get you many responses. What will work is if you write your own code and ask specific questions when you get stuck.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Here's a rough approach, in the DataStage designer choose File -> New and choose a new Server Routine. In the screen give it a name and make sure that it is a server Function. Look at the "Arguments" tab, it will have one default argument called "Arg1".
Now click on the "Code" and enter the following source code:

Code: Select all

Ans = Arg1 * 2
Save and compile. Then create a server job and in the derivation for a column, click on the "..." and select "DS Routine" and navigate to your newly created routine in the list; insert it and give it an appropriate numeric input column or constant and you are good to go.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

The product ships with all kinds of "sample" code, pretty much every routine includes the source code. Find them and start examining them, one of the best way to learn how things work is to study working things.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply