Page 1 of 1

How To Pass Velues To Parameters

Posted: Fri May 06, 2005 12:30 am
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

Posted: Fri May 06, 2005 12:39 am
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

SETting Up Job params

Posted: Fri May 06, 2005 1:21 am
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

Posted: Fri May 06, 2005 1:38 am
by ray.wurlod
CLOSESEQ rather than CLOSE in Arnd's routine please. :oops:

Re: SETting Up Job params

Posted: Fri May 06, 2005 6:17 am
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.

Posted: Fri May 06, 2005 6:21 am
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.

Posted: Thu Jun 23, 2005 9:48 am
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

Posted: Thu Jun 23, 2005 10:43 am
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?

Posted: Thu Jun 23, 2005 11:10 am
by Titto
Hi Arndw,

Tested the function and it is working fine now.
Now need some hlep how to pass values to Job Parameters.

Posted: Thu Jun 23, 2005 1:25 pm
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"