Routine Variable

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
mahi_mahi
Charter Member
Charter Member
Posts: 45
Joined: Mon Aug 01, 2005 10:02 am

Routine Variable

Post by mahi_mahi »

Hi All,
My requirement is like below

I have a input file which is having 10 records
in trnaformer iam calling a basic routine where am doing some process
and returning a value to output.

my question i need to declare a variable in routine and this should incremented every time when i call the subroutine.

in this case the value of the variable should be 10 at last excution as i have 10 input records...

SO please how can i hold the value in that variable fornext execution of routine..............!!!!!!

regards
Mahi
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

i dont know if you can store the value inside the routine without clearing it, but you could physically store the value in a file. Next time just using the openseq basic command to read the value from the file. Do your manipulation and then increment it by one and write it back to the same file.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

You need to declare a COMMON variable, which will maintain its value as long as the process is active.

COMMON /pickaname/ yourvariable1, yourvariable2, yourvariable3.

Search the forum for implications and limitations to a labeled COMMON.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

There are five system variables called @USER0 through @USER4 and another called @USER.RETURN.CODE. Each is initialized to zero automatically when your job starts. You can use any of these, thereby avoiding the need to use COMMON (and leaving open the possibility, therefore, of later migration into a parallel job).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Sreenivasulu
Premium Member
Premium Member
Posts: 892
Joined: Thu Oct 16, 2003 5:18 am

Re: Routine Variable

Post by Sreenivasulu »

HI,

Wonder if this would help.
RowRunningTotal which holds the cumulative values of the job.

I remember using a datastage provided routine for this purpose.

Will get back on this soon.

Regards
Sreeni
mahi_mahi wrote:Hi All,
My requirement is like below

I have a input file which is having 10 records
in trnaformer iam calling a basic routine where am doing some process
and returning a value to output.

my question i need to declare a variable in routine and this should incremented every time when i call the subroutine.

in this case the value of the variable should be 10 at last excution as i have 10 input records...

SO please how can i hold the value in that variable fornext execution of routine..............!!!!!!

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

Re: Routine Variable

Post by chulett »

Sreenivasulu wrote:Wonder if this would help. RowRunningTotal which holds the cumulative values of the job.
Yes, because it helps illustrate the use of COMMON variables in a very simple to understand example. 'RowProcGetPreviousValue' is a much more interesting one. However, it does sound like the routine you mentioned, which is technically 'RowProcRunningTotal' in the 'sdk/RowProc' branch of the repository, could be used by the OP if they don't want to write their own.

I always tend to forget about the @USER variables. While COMMON can certainly be made to work under the caveats that they come with (like buffering and migration to PX), the @USER answer is the better one. IMHO. :wink:
-craig

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