How To Pass Velues To Parameters

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
Rubu
Premium Member
Premium Member
Posts: 82
Joined: Sun Feb 27, 2005 9:09 pm
Location: Bangalore

How To Pass Velues To Parameters

Post by Rubu »

Hi

I want to read a text file and Pass a couple of values to 2 JOB PARAMETERS. Can it be achieved in job control routine?

Is it possible to asign values to parameters in Job Control?

Regards
Palasjyoti
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Yes, it can be done. I would write a function, "ReadMySeqFile" which accepts the filename&path as an input parameter and returns a delimited string which you can then use to get the parameters to pass on to other jobs from the sequence. A sample of this code could be (with error-handling removed)

Code: Select all

ReadMySeqFile(InFile)

EQUATE Delimiter to ','
Ans = ''
OPENSEQ InFile TO InFilePtr ELSE CALL DSLogFatal('Cannot open file "':InFile:'".','')
Finished = 0
READSEQ InRecord FROM InFilePtr ELSE Finished = 1
LOOP UNTIL Finished
   Ans := Delimiter:InRecord
   READSEQ InRecord FROM InFilePtr ELSE Finished = 1
REPEAT
Ans = Ans[2,9999] ;** remove first delimiter
CLOSE InFilePtr
Rubu
Premium Member
Premium Member
Posts: 82
Joined: Sun Feb 27, 2005 9:09 pm
Location: Bangalore

SETting Up Job params

Post by Rubu »

Thanks Andrw

yes, it will give me the values from the Seq File. Now I want Set Parameters in my job as those values from the Seq file.

I added following code in Job Control to asign NAME="rubu". But this routine is giving both the warning messages included in... saying "BAD HANDLE". Why is it happening. Cant I SET parameter of the same job I inside job control?


ErrCode = DSSetParam (DSJ.ME, "NAME","rubu")

IF ErrCode <>0 THEN

IF ErrCode =DSJE.BADHANDLE
THEN
Call DSLogWarn("BAD HANDLE","Job Control")
END

Call DSLogWarn("Not asign","Job Control")

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

Post by ray.wurlod »

CLOSESEQ rather than CLOSE in Arnd's routine please. :oops:
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Re: SETting Up Job params

Post by chulett »

Rubu wrote:I added following code in Job Control to asign NAME="rubu". But this routine is giving both the warning messages included in... saying "BAD HANDLE". Why is it happening. Cant I SET parameter of the same job I inside job control?
Nope, it's too late at that point. Parameters must be set before the job is run, so job control code is typically setting the parameters for and running other jobs.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

You can return the value from the routine and pass its userstatus to following jobs.

If you are using DS ver > 7.5, you can use user-defined variables stage.
Titto
Participant
Posts: 148
Joined: Tue Jun 21, 2005 7:49 am

Post by Titto »

I have same kind of requirement to read a sequential file which contains a single record seperated by "," . I need to use this values as parameters in same job to get the data from DB2. I created function using

ReadMySeqFile(InFile)

EQUATE Delimiter to ','
Ans = ''
OPENSEQ InFile TO InFilePtr ELSE CALL DSLogFatal('Cannot open file "':InFile:'".','')
Finished = 0
READSEQ InRecord FROM InFilePtr ELSE Finished = 1
LOOP UNTIL Finished
Ans := Delimiter:InRecord
READSEQ InRecord FROM InFilePtr ELSE Finished = 1
REPEAT
Ans = Ans[2,9999] ;** remove first delimiter
CLOSESEQ InFilePtr

when i test this function by passing inputfile path and name , i am not getting any result.
Rubu, Arndw if you got successful can you please direct me how to do.

Thx
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Titto,

Suggestions/Questions:

-are you getting an abort in the log file when opening in the file?, i.e. an incorrectly formed path?

try putting "Counter += 1" and "CALL DSLogInfo(Counter,'')" inside the loop and seeing if it loops for each line.

If you test from within the manager you will need to double-click and on the return value to see any error/warning messages. Have you done this?
Titto
Participant
Posts: 148
Joined: Tue Jun 21, 2005 7:49 am

Post by Titto »

Hi Arndw,

Tested the function and it is working fine now.
Now need some hlep how to pass values to Job Parameters.
sonia jacob
Participant
Posts: 122
Joined: Mon Jul 05, 2004 1:33 pm
Location: MA

Post by sonia jacob »

Titto wrote:Hi Arndw,

Tested the function and it is working fine now.
Now need some hlep how to pass values to Job Parameters.
1. get handle for job "DSAttachJob"
2. Set parameters for the job. One of the previous post talks about "DSSetParam".
3. Then "DSRunJob"
Regards
Sonia Jacob
Post Reply