Get the Value of Project Environment Varaible in Job Control

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
DS_SUPPORT
Premium Member
Premium Member
Posts: 232
Joined: Fri Aug 04, 2006 1:20 am
Location: Bangalore

Get the Value of Project Environment Varaible in Job Control

Post by DS_SUPPORT »

I have a requirement, to get the value of project level userdefined environment variables inside a jobcontrol or routine. I know the easiest way should be declare all the required parameters as job parameters and we can access it inside the job control.

But I dont want it to be defined in the job parameters as the number of parameters is more, and all the parameters wont be required for all the users. So i decided to get it inside the jobcontrol, as the end users wont see it , when running the job.

Is there any way to access the value of the project parameters, inside the jobcontrol?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You could read the DSParams file.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DS_SUPPORT
Premium Member
Premium Member
Posts: 232
Joined: Fri Aug 04, 2006 1:20 am
Location: Bangalore

Post by DS_SUPPORT »

Reading DSParams is a good idea, but my boss is suspecting, that this action may corrupt DSParams file.

Is there any thing similar to PX's GetEnvironment for the Server Edition or is there any other way to get it.

I know the environment variable name, and it will be constant , so inside the jobcontrol , i can hardcode like GetEnvironment('$TGT_DB_CONNECTION') and want to read its value.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I'm curious how reading anything would corrupt it? :?
DS_SUPPORT wrote:Is there any thing similar to PX's GetEnvironment for the Server Edition or is there any other way to get it.
Roll your own. It would be simple enought to "echo" whatever variable was passed in and return the value associated with it.
-craig

"You can never have too many knives" -- Logan Nine Fingers
DS_SUPPORT
Premium Member
Premium Member
Posts: 232
Joined: Fri Aug 04, 2006 1:20 am
Location: Bangalore

Post by DS_SUPPORT »

Sorry, If i didnt make it clear. I want to read the project Parameter and not the Environment Variable.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Project parameters are environment variables, set in all jobs when they run. Double-click on the second log record from any job to see what I mean. Unless we have a different definition of "project parameter" that is. :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
DS_SUPPORT
Premium Member
Premium Member
Posts: 232
Joined: Fri Aug 04, 2006 1:20 am
Location: Bangalore

Post by DS_SUPPORT »

Thanks for the replies, and i am able to echo the environment variable values.

But I used the function , which is provided by Ray in some other posts.

Code: Select all

FUNCTION GetEnvironmentVariable(EnvVarName) 

If UnAssigned(EnvVarName) Or IsNull(EnvVarName) 
      Then 
         Ans = @NULL 
      End 
      Else 
         Call DSExecute("UV", "ENV", Output, ExitStatus) 
         FindStr EnvVarName In Output Setting FMC,VMC,SMC 
         Then 
            Ans = Field(Output<FMC,VMC,SMC>, "=", 2, 99) 
         End 
         Else 
            Ans = "" 
         End 
      End 
RETURN(Ans)
I used it as a Subroutine in my JobControl.

Thanks for helping.
Post Reply