ParmeterFile

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
vijayindukuri
Participant
Posts: 66
Joined: Fri Nov 25, 2005 7:55 am

ParmeterFile

Post by vijayindukuri »

Hi
How do we read parameters from file and where do we store the parameter file and which format the file is stored.
we have used the routine to read from the parameter file but,the value of the parameter is not being retreived from the file .

The path of the file and name is
e:\Ascential\DataStage\Projects\MYPROJ\DSParams
we have given Job name ,Parametername and path of the file as arguments.
The code is as follows

Code: Select all

ParamFile = ParameterFileName 
Var = 0 
OpenSeq ParamFile To FileVar Else 
Call DSLogFatal("Cannot open ":ParamFile: "- Aborting Job", "ParameterRoutine") 
Ans = @Null 
GoTo ErrorExit 
End 
Loop 
ReadSeq FileLine From FileVar 
Then 
If Var = 1 Or TrimF(TrimB(Field(EReplace(FileLine, '[',""),']',1))) = TrimF(TrimB(JobName)) 
Then 
Var = 1 
If Var = 1 And TrimF(TrimB(Field(FileLine,"=",1))) = TrimF(TrimB(ParameterName)) 
Then 
Ans = TrimF(TrimB(Field(FileLine,"=",2))) 
GoTo MatchFound 
End Else 
Ans = @Null 
End 
End Else 
Ans = @Null 
End 
End Else 
Exit 

End 

Repeat 

MatchFound: 

CloseSeq FileVar 

ErrorExit: 

Can any one help me in this.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Vijay,

first off, take this code into your manager and FORMAT it; in it's present state it is very difficult to read.

I am assuming that you did not write this routine but got it from somewhere. After formatting you really need to debug this yourself instead of getting some answer from this forum. In this case you should put in some PRINT {variable} statements to see what the routine is parsing and in which state it is in (whether reading a parameter name or a value).

The code that parses the value looks OK, and I'd end up doing what I suggested above to debug it - something I think you should be doing in this case.

Some general coding suggestions (these are just my preferences, not an absolute "must do"):
1. Using TRIM() is easier to read and understand than TRIMF(TRIMB()) and does the same thing.
2. Use whatever TRIM() you want on the input parameters into a temporary variable outside of your main loop - don't TRIM() every iteration of the loop.
3. Use a IF-THEN-ELSE around your code instead of using a GOTO and a LABEL:
vijayindukuri
Participant
Posts: 66
Joined: Fri Nov 25, 2005 7:55 am

Post by vijayindukuri »

Hi arndw
I have got the code from dsxchange and ill do the changes and let u know
thankyou
Sunshine2323
Charter Member
Charter Member
Posts: 130
Joined: Mon Sep 06, 2004 3:05 am
Location: Dubai,UAE

Post by Sunshine2323 »

Hi vijayindukuri,

viewtopic.php?t=84590
contains a FUNCTION GetParameterFromFile(ConfigFileName, ParamName) written by Tonystark. I have checked it, works great!

Hope this helps :)
Warm Regards,
Amruta Bandekar

<b>If A equals success, then the formula is: A = X + Y + Z, X is work. Y is play. Z is keep your mouth shut. </b>
--Albert Einstein
Andal
Participant
Posts: 124
Joined: Thu Dec 02, 2004 6:24 am
Location: Bangalore, India

Post by Andal »

Hi vijayindukuri,

For the routine you have posted, there is some specific ways to write the Parameter File.

Code: Select all

If Var = 1 Or TrimF(TrimB(Field(EReplace(FileLine, '[',""),']',1))) = TrimF(TrimB(JobName)) 
Then 
Var = 1 
If Var = 1 And TrimF(TrimB(Field(FileLine,"=",1))) = TrimF(TrimB(ParameterName)) 
Then 
Ans = TrimF(TrimB(Field(FileLine,"=",2))) 
For this , the input should be like

Code: Select all


[Jobname_1]
ParamName1 = ParamValue1
ParamName2 = ParamValue2

[Jobname_2]
ParamName1 = ParamValue1
ParamName2 = ParamValue2

Hope this will work For your Existing Code itself. And I hope maintaing the Parameters in DSParams itself is not a good practice. Please try to maintain a seperate file for you Job Parameters.
Rgds
Anand
Post Reply