hot to pass environment variable in server routine

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
pongal
Participant
Posts: 77
Joined: Thu Mar 04, 2004 4:46 am

hot to pass environment variable in server routine

Post by pongal »

Hi,
I would like to pass environment variable $TargetFilePath into server routine.
if i write this code, it is giving an error
strFileLoc = DSGetParamInfo(DSJ.ME,"#$TargetFileDir#", DSJ.PARAMVALUE)
Call DSLogInfo("strACRFileLoc :":strFileLoc, DSJ.ME)

how to read environment variable's valve in server routine
do i need to define anything

Thanks
benny.lbs
Participant
Posts: 125
Joined: Wed Feb 23, 2005 3:46 am

Re: hot to pass environment variable in server routine

Post by benny.lbs »

Pass the environment variable to Input Argument
pongal wrote:Hi,
I would like to pass environment variable $TargetFilePath into server routine.
if i write this code, it is giving an error
strFileLoc = DSGetParamInfo(DSJ.ME,"#$TargetFileDir#", DSJ.PARAMVALUE)
Call DSLogInfo("strACRFileLoc :":strFileLoc, DSJ.ME)

how to read environment variable's valve in server routine
do i need to define anything

Thanks
elavenil
Premium Member
Premium Member
Posts: 467
Joined: Thu Jan 31, 2002 10:20 pm
Location: Singapore

Post by elavenil »

Tried using the dummy environment variable with $ symbol and it gives error message. And tried assigning this env variable to the argument and it gives error.

Can you pls share us how the env variable can be assigned to Argument of the routine.

Thanks for the inputs.

Regards
Saravanan
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Tell us the exact error.

Also tell us if you've included JOBCONTROL.H in your routine, where the DEFFUN for DSGetParamInfo() function lives. (It is not necessary to include it in a job control routine.)

If there's no DEFFUN, the error is likely to be something like "dimensioned array not defined".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
benny.lbs
Participant
Posts: 125
Joined: Wed Feb 23, 2005 3:46 am

Post by benny.lbs »

What kind of server routine do you use ? Before/After ?

Where do you call the routine ? Before/After job routine or within Job Sequence ?

Maybe you should add the env variable to Job properties first, and then code as #$env_var# in Before/After job routine, only $env_var in sequence routine activity.
elavenil wrote:Tried using the dummy environment variable with $ symbol and it gives error message. And tried assigning this env variable to the argument and it gives error.

Can you pls share us how the env variable can be assigned to Argument of the routine.

Thanks for the inputs.

Regards
Saravanan
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Re: hot to pass environment variable in server routine

Post by roy »

Hi,
why do you have # signs around the parameter name?
pongal wrote:Hi,
I would like to pass environment variable $TargetFilePath into server routine.
if i write this code, it is giving an error
strFileLoc = DSGetParamInfo(DSJ.ME,"#$TargetFileDir#", DSJ.PARAMVALUE)
Call DSLogInfo("strACRFileLoc :":strFileLoc, DSJ.ME)

how to read environment variable's valve in server routine
do i need to define anything

Thanks
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
benny.lbs
Participant
Posts: 125
Joined: Wed Feb 23, 2005 3:46 am

Re: hot to pass environment variable in server routine

Post by benny.lbs »

It seems it can't be compiled with $TargetFileDir, "$" unexpected.
roy wrote:Hi,
why do you have # signs around the parameter name?
pongal wrote:Hi,
I would like to pass environment variable $TargetFilePath into server routine.
if i write this code, it is giving an error
strFileLoc = DSGetParamInfo(DSJ.ME,"#$TargetFileDir#", DSJ.PARAMVALUE)
Call DSLogInfo("strACRFileLoc :":strFileLoc, DSJ.ME)

how to read environment variable's valve in server routine
do i need to define anything

Thanks
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Well

Code: Select all

ErrCode = DSSetParam(hJob1, "$DS_ENABLE_RESERVED_CHAR_CONVERT", "True")
this is part of a job control code added automatically when adding a job with env variable as above
it compiles fine :roll:
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
elavenil
Premium Member
Premium Member
Posts: 467
Joined: Thu Jan 31, 2002 10:20 pm
Location: Singapore

Post by elavenil »

Hi All,

Thanks for your inputs.

Hi Ray,

The error message is as follows.

Compiling: Source = 'DSU_BP/DSU.ttrd', Object = 'DSU_BP.O/DSU.ttrd'
*
WARNING: Variable 'TestInput' never assigned a value.

Compilation Complete.

Pls let me know if any of the header file to be included.

Hi Benny,

I am trying to create this as new server routine.

Hi Roy,

Tried using the variable without $ but it did not work.

The test code is as follows.

SS = TestInput

If SS = 'S' Then
Ans = 'RRRR'
End

If SS <> 'S' Then
Ans = 'TTT'
End

TestInput has been defined as env variable in the Administrator.

Pls let me know your inputs.

Regards
Saravanan
benny.lbs
Participant
Posts: 125
Joined: Wed Feb 23, 2005 3:46 am

Post by benny.lbs »

I have create a very simple routine only contain

Code: Select all

Call DSLogInfo("$APT_CONFIG_FILE", 'RoutineName')
, but the output is string "$APT_CONFIG_FILE"
roy wrote:Well

Code: Select all

ErrCode = DSSetParam(hJob1, "$DS_ENABLE_RESERVED_CHAR_CONVERT", "True")
this is part of a job control code added automatically when adding a job with env variable as above
it compiles fine :roll:
pongal
Participant
Posts: 77
Joined: Thu Mar 04, 2004 4:46 am

Post by pongal »

env variable is working fine in After job routine.
we should give parameter as '$TargetFilePath' and include
#INCLUDE DSINCLUDE JOBCONTROL.H

Thanks all of you.... :D
Post Reply