Accessing Datastage Env variable value in Basic Rouitne

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
dstest
Participant
Posts: 66
Joined: Sun Aug 19, 2007 10:52 pm

Accessing Datastage Env variable value in Basic Rouitne

Post by dstest »

Hi,

Can any one please tell me how to access datastage Env variable value in basic routine.

Thanks
rameshrr3
Premium Member
Premium Member
Posts: 609
Joined: Mon May 10, 2004 3:32 am
Location: BRENTWOOD, TN

Post by rameshrr3 »

You can use a code snippet similar if you have a job handle attached.

Code: Select all

CurrentJobHandle = DSJ.ME 
/* CurrentJobHandle= DSAttachJob(JobName,DSJ.ERRFATAL)*/
TargetEnv =  '$TARGET_ENV'
TargetEnvValue = DSGetParamInfo(CurrentJobHandle, TargetEnv, DSJ.PARAMVALUE)
Ans = TargetEnvValue
In the example above $TARGET_ENV is a parameter defined as a DS Environment variable.
umamahes
Premium Member
Premium Member
Posts: 110
Joined: Tue Jul 04, 2006 9:08 pm

Post by umamahes »

I know this way.I am asking is there any other way with out adding env in the job parameter can we access env value in basic routine
HI
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

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)
Last edited by ray.wurlod on Wed Jul 16, 2008 3:58 pm, edited 1 time in total.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
vivekgadwal
Premium Member
Premium Member
Posts: 457
Joined: Tue Sep 25, 2007 4:05 pm

Post by vivekgadwal »

I have a question with this routine Ray.

> Is there a reason why "UnAssigned()" is present twice?

Code: Select all

If UnAssigned(EnvVarName) Or UnAssigned(EnvVarName) 
      Then 
         Ans = @NULL
Vivek Gadwal

Experience is what you get when you didn't get what you wanted
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Code: Select all

UNIXcmd="echo $yourenvironmentvariable"
CALL DSExecute("UNIX", UNIXcmd, ScreenOutput,ReturnCode)
yourenvironmentvariable = ScreenOutput<1>
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 »

The test condition should have been

Code: Select all

UnAssigned(EnvVarName) Or IsNull(EnvVarName)
:oops:

I have edited the original post to show this.
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