Page 1 of 1

Get the Value of Project Environment Varaible in Job Control

Posted: Fri Dec 12, 2008 10:42 pm
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?

Posted: Sat Dec 13, 2008 2:58 pm
by ray.wurlod
You could read the DSParams file.

Posted: Sat Dec 13, 2008 9:15 pm
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.

Posted: Sun Dec 14, 2008 8:12 am
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.

Posted: Sun Dec 14, 2008 8:55 pm
by DS_SUPPORT
Sorry, If i didnt make it clear. I want to read the project Parameter and not the Environment Variable.

Posted: Mon Dec 15, 2008 7:44 am
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. :?

Posted: Mon Dec 15, 2008 10:29 pm
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.