Page 1 of 1

how to pass UNIX script(Procedure) output to job parameter?

Posted: Tue Apr 11, 2006 1:05 pm
by vbeeram
Hi,

I have a db2 procedure in my UNIX script,when i execute it returns a value,i need to pass that value into (Job Parameter) to use in Transformer.

I tried with execSH and i passed path and file name as Input Value.
Then how to pass that output to job parameter?


Thanks
Beeram

Posted: Tue Apr 11, 2006 1:31 pm
by DSguru2B
you will need to append that value to your param file in the format DS Jobs accepts it.
-param param name=param value

Posted: Tue Apr 11, 2006 1:45 pm
by kcbland
From a before-job routine? Can't set a jobs parameter values from its before-job routine. Consider using a staging variable in your transformer, and for the initialization of the value do the ExecSH call to your script to get the startup value. :wink:

Posted: Tue Apr 11, 2006 2:17 pm
by vbeeram
Thanks Bland,

as per your guidelines i can call in stage variable but also i need to use that value in another stage(Not in transformer) as job parameter.



Thanks
Beeram

Posted: Tue Apr 11, 2006 2:44 pm
by kcbland
You mean like a filename or a query value? Instead, use job control to feed the parameter.

Posted: Tue Apr 11, 2006 3:19 pm
by vbeeram
I need to use query output.
I wrote job control but not able to pass to job parameter.

Posted: Tue Apr 11, 2006 3:50 pm
by kcbland
Using a Sequencer a Routine stage can call your script, or in Batch a CALL DSExecute(...) will return the screen output and return code of the script. Choose your weapon.

Posted: Tue Apr 11, 2006 4:31 pm
by vbeeram
Thanks bland, i am almost done
but still i have doubt on passing value :

Below is my code :


hjob1=DSAttachJob("demojob2",DSJ.ERRFATAL)
IF NOT(hjob1) then
CALL DSlogFatal("Job Failed:demojob2","JOB ABORTED")
END

Unixcmd="/fdev/users/10001/Proc.shl"
CALL DSExecute("UNIX",Unixcmd,Scroutput,RetCode)



how to pass Scroutput(output) value to parameter ?



Thanks
Beeram

Posted: Tue Apr 11, 2006 5:12 pm
by ray.wurlod
ErrCode = DSSetParam(hJob, ParamName, ScrOutput)

Posted: Tue Apr 11, 2006 7:31 pm
by kduke
ray.wurlod wrote:ErrCode = DSSetParam(hJob, ParamName, ScrOutput)

Code: Select all

ErrCode = DSSetParam([i]hJob[/i], [i]ParamName[/i], ScrOutput<1>)
Is usually what I have to do. You could also use field().

Posted: Thu Apr 13, 2006 11:05 am
by vbeeram
Thanks Bland,

I wrote this code in job control within the same job.
and i declared a parameter ScrOutput in job parameters with some default value then i called ScrOutput parameter into Transformer.
This not working properly .when i ran it is taking time ,never end the job
unless i kill that one.

hjob=DSAttachJob("demojob",DSJ.ERRWARN)
status=DSRunJob(hjob,DSJ.RUNNORMAL)
Unixcmd="/fdev/users/11001/Proc.shl"
CALL DSExecute("UNIX",Unixcmd,ScrOutput,RetCode)
ErrCode=DSSetParam(hjob,"ScrOutput",ScrOutput)

Thanks
Beeram

Posted: Thu Apr 13, 2006 11:14 am
by ogmios
vbeeram wrote: hjob=DSAttachJob("demojob",DSJ.ERRWARN)
status=DSRunJob(hjob,DSJ.RUNNORMAL)
Unixcmd="/fdev/users/11001/Proc.shl"
CALL DSExecute("UNIX",Unixcmd,ScrOutput,RetCode)
ErrCode=DSSetParam(hjob,"ScrOutput",ScrOutput)
You first run demojob and then you still want to put a parameter on it. Your order is wrong:
- first execute your UNIX script (and remember about the limited environment you get)
- DSAttachJob
- DSSetParam
- DSRunJob

Ogmios

Posted: Thu Apr 13, 2006 11:19 am
by kcbland
Attach, check status, reset if necessary and detach and attach again, set all parameters, set run limits, run job, wait for finish, check status.