Project 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
Veni
Participant
Posts: 45
Joined: Fri Oct 21, 2005 2:51 am

Project Variable

Post by Veni »

Any body know , how to invoke project variable that is environment variable in subroutine....

i created one variable say Hash_file_location in project level environment variable...

i need to invoke this variable in my subroutine. is it possible i know how to invoke this variable from job parameter.... using #$Hash_file_location#

but i want to invoke in my subroutine
rv
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Environment variables have to be setup in the job as job parameters. As for getting any variable into a subroutine (I assume you mean before/after transformer/job subroutine call) you have to pass it as the argument. Your subroutine needs to get it from the argument. Otherwise, you will need to do an "env" command from inside your subroutine and parse it from the screen results of the env command.
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
Veni
Participant
Posts: 45
Joined: Fri Oct 21, 2005 2:51 am

Post by Veni »

kcbland wrote:Environment variables have to be setup in the job as job parameters. As for getting any variable into a subroutine (I assume you mean before/after transformer/job subroutine call) you have to pass it as the argument. Your subroutine needs to get it from the argument. Otherwise, you will need to do an "env" command from inside your subroutine and parse it from the screen results of the env command.

Please tell me how to parse " env" command from inside my subroutine
rv
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Veni,

in a routine you can issue

Code: Select all

EnvironmentString = DSExecute('UNIX','env',ErrorCode)
The EnvironemtString will contain the UNIX output of the env command, with all <LF> converted to @FM. You can then write some code to loop through all the values to find the ones you are interested in.
gsherry1
Charter Member
Charter Member
Posts: 173
Joined: Fri Jun 17, 2005 8:31 am
Location: Canada

Post by gsherry1 »

Here is example of calling external program. You should adapt this to call env instead.

Expression="env | grep '^ABC='"
call DSExecute("UNIX", Expression, Output, SystemReturnCode)

Output would then be assigned something like "ABC=somevalue"
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

Normally you want to avoid plucking env variables from within a routine as it breaks good modular coding practices. Kind of like using global variables in Visual Basic code. The project specific environment variables are set as the default values for job parameters, it is possible that someone will run the job and change those defaults (for example change the hash file location) when the run or schedule the job, so your jobs will end up using one value and your routines another value.

Passing all variables in a arguments to the routine is a better way to go and it is very easy to set up from a Sequence job.
Veni
Participant
Posts: 45
Joined: Fri Oct 21, 2005 2:51 am

Post by Veni »

vmcburney wrote:Normally you want to avoid plucking env variables from within a routine as it breaks good modular coding practices. Kind of like using global variables in Visual Basic code. The project specific environment variables are set as the default values for job parameters, it is possible that someone will run the job and change those defaults (for example change the hash file location) when the run or schedule the job, so your jobs will end up using one value and your routines another value.

Passing all variables in a arguments to the routine is a better way to go and it is very easy to set up from a Sequence job.

i want to get access userdefine variable in project environment from my subroutine ,

it is entripted value that in job i can invoke #$HASH_PATH_Par# BUT I don't know how to invoke from subroutine
rv
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Look for the function DSGetParamInfo() in on-line help.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply