passing a parameter
Moderators: chulett, rschirm, roy
passing a parameter
Hello , I'm trying to do the following through a job control :
*read date from seq. file
OpenSeq 'E:\Ascential\DataStage\Projects\DSFIND\PILOT\YNKxx_JOBDATE.txt' To jobdatefile
Else Call DSLogWarn("Cannot open ":jobdatefile)
ReadSeq YSATCdate From jobdatefile
Else Goto jobdatefilerror
jobdatefilerror:
If YSATCdate = 0 Then
check=@False
End
* send message to loglisting
Call DSLogInfo("Processing ":YSATCdate ,"Job Controller")
* Setup YNKxx_NP_to_FLATFILE, run it, wait for it to finish, and test for success
hJob1 = DSAttachJob("YNKxx_NP_to_FLATFILE", DSJ.ERRFATAL)
If NOT(hJob1) Then
Call DSLogFatal("Job Attach Failed: YNKxx_NP_to_FLATFILE", "JobControl")
Abort
End
ErrCode = DSSetParam(hJob1, "LIB", LIB)
ErrCode = DSSetParam(hJob1, "JOBDATE", YSATCdate)
ErrCode = DSSetDisableProjectHandler(hJob1, @FALSE)
ErrCode = DSSetDisableJobHandler(hJob1, @FALSE)
ErrCode = DSRunJob(hJob1, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(hJob1)
Status = DSGetJobInfo(hJob1, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED Then
* Fatal Error - No Return
Call DSLogFatal("Job Failed: YNKxx_NP_to_FLATFILE", "JobControl")
End
Log says :
YNKxx_to_FLAT_CONTROL..JobControl (Job Controller): Processing "2006-01-10"
so the parameter YSATCdate is set imho , but the attache job aborts saying
YNKxx_NP_to_FLATFILE: Missing Parameters JOBDATE.
I read a lot of the post about parameters and passing them , but I do not understand why I can perfectly show the date in the log , but the attached jobs fails .
anybody?
Any help greatly appreciated .
Regards,
Luc
*read date from seq. file
OpenSeq 'E:\Ascential\DataStage\Projects\DSFIND\PILOT\YNKxx_JOBDATE.txt' To jobdatefile
Else Call DSLogWarn("Cannot open ":jobdatefile)
ReadSeq YSATCdate From jobdatefile
Else Goto jobdatefilerror
jobdatefilerror:
If YSATCdate = 0 Then
check=@False
End
* send message to loglisting
Call DSLogInfo("Processing ":YSATCdate ,"Job Controller")
* Setup YNKxx_NP_to_FLATFILE, run it, wait for it to finish, and test for success
hJob1 = DSAttachJob("YNKxx_NP_to_FLATFILE", DSJ.ERRFATAL)
If NOT(hJob1) Then
Call DSLogFatal("Job Attach Failed: YNKxx_NP_to_FLATFILE", "JobControl")
Abort
End
ErrCode = DSSetParam(hJob1, "LIB", LIB)
ErrCode = DSSetParam(hJob1, "JOBDATE", YSATCdate)
ErrCode = DSSetDisableProjectHandler(hJob1, @FALSE)
ErrCode = DSSetDisableJobHandler(hJob1, @FALSE)
ErrCode = DSRunJob(hJob1, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(hJob1)
Status = DSGetJobInfo(hJob1, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED Then
* Fatal Error - No Return
Call DSLogFatal("Job Failed: YNKxx_NP_to_FLATFILE", "JobControl")
End
Log says :
YNKxx_to_FLAT_CONTROL..JobControl (Job Controller): Processing "2006-01-10"
so the parameter YSATCdate is set imho , but the attache job aborts saying
YNKxx_NP_to_FLATFILE: Missing Parameters JOBDATE.
I read a lot of the post about parameters and passing them , but I do not understand why I can perfectly show the date in the log , but the attached jobs fails .
anybody?
Any help greatly appreciated .
Regards,
Luc
When the Job starts it has to have all parameters already set and you cannot use the Jobs own Job Controller as Job Parameter. You can read it in any routine but a parameter can never be changed itself.
What you can do is:
Use a 2nd Job and read the 1st Job's Job Controller and start in the 2nd Job the 1st Job by setting this parameter.
and several other ways....
... but not the one you have tried.
What you can do is:
Use a 2nd Job and read the 1st Job's Job Controller and start in the 2nd Job the 1st Job by setting this parameter.
and several other ways....
... but not the one you have tried.
Wolfgang Hürter
Amsterdam
Amsterdam
Wolfgang, I think you've missed something. This is perfectly valid 'job control' code and seems to have been cloned from the 'Add Job' function.
One problem, Luc, is the fact that you don't check the success or failure of your operations before the job is run. You should check to see if the DSSetParam is failing and the reason for the failure. The error says your parameter has no default value, was left blank and is not of a type that allows it to stay empty - Date, Integer, etc. And all your 'Processing' message really means is you were successful logging the message.
Make sure your parameter name is actually "JOBDATE" case and all and what you are passing is in an acceptable format. Again, checking ErrCode post 'Set' should point you in the right direction.
One problem, Luc, is the fact that you don't check the success or failure of your operations before the job is run. You should check to see if the DSSetParam is failing and the reason for the failure. The error says your parameter has no default value, was left blank and is not of a type that allows it to stay empty - Date, Integer, etc. And all your 'Processing' message really means is you were successful logging the message.
![Wink :wink:](./images/smilies/icon_wink.gif)
Make sure your parameter name is actually "JOBDATE" case and all and what you are passing is in an acceptable format. Again, checking ErrCode post 'Set' should point you in the right direction.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
Ok, in pondering this - we've both made assumptions.chulett wrote:Wolfgang, I think you've missed something. This is perfectly valid 'job control' code and seems to have been cloned from the 'Add Job' function.
![Wink :wink:](./images/smilies/icon_wink.gif)
I assumed a separate 'job control' job being run that in turn runs the other job. Luc, is that the case or is something else going on?
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
Hello ,
first of all thnx to all for the fast reply's.
I do indeed work with a job control , having cloned jobs put in a loop since I have to do year processing later on .
the jobcontrol does not have a parameter JOBDATE (tried to add it , same result (YNKxx_NP_to_FLATFILE: Missing Parameters JOBDATE.)
it does have the LIB parameter
The than called job (YNKxx_NP_to_FLATFILE) has both parameters LIB and JOBDATE .
I'm now testing with the formats and embedding Craig 's option of checking ErrCode post 'Set'
I'll keep in touch and will post furhter findings.
Regards ,
Luc
first of all thnx to all for the fast reply's.
I do indeed work with a job control , having cloned jobs put in a loop since I have to do year processing later on .
the jobcontrol does not have a parameter JOBDATE (tried to add it , same result (YNKxx_NP_to_FLATFILE: Missing Parameters JOBDATE.)
it does have the LIB parameter
The than called job (YNKxx_NP_to_FLATFILE) has both parameters LIB and JOBDATE .
I'm now testing with the formats and embedding Craig 's option of checking ErrCode post 'Set'
I'll keep in touch and will post furhter findings.
Regards ,
Luc
in addtition ,after adding this line
Call DSLogInfo("ERROR ":ErrCode ,"Job Controller")
the info from the log
YNKxx_to_FLAT_CONTROL..JobControl (Job Controller): ERROR -4
according to the manual
0 = ok
-1 = badhandle
-2 = badstate
-3= badparam
-4 = badvalue
so I narrowed down the options to ...badvalue ...
although the previus info from the log says
YNKxx_to_FLAT_CONTROL..JobControl (Job Controller): Processing "2006-02-23"
Is it possible DS uses somekind of numeric value behind the scenes for this date resulting in badvalue ?
the 2006-02-23 is a valid date on AS400
Regards,
Luc
Call DSLogInfo("ERROR ":ErrCode ,"Job Controller")
the info from the log
YNKxx_to_FLAT_CONTROL..JobControl (Job Controller): ERROR -4
according to the manual
0 = ok
-1 = badhandle
-2 = badstate
-3= badparam
-4 = badvalue
so I narrowed down the options to ...badvalue ...
although the previus info from the log says
YNKxx_to_FLAT_CONTROL..JobControl (Job Controller): Processing "2006-02-23"
Is it possible DS uses somekind of numeric value behind the scenes for this date resulting in badvalue ?
the 2006-02-23 is a valid date on AS400
Regards,
Luc
That error means there is more than just "2006-02-23" in your date, which usually means Field Marks or some other invisible mojo going on.
So try either passing YSATCdate<1> to the DSSetParam function or remove things first using Convert or EReplace:
This will remove all Field Marks from the string. One of the two should get it working for you, I would think.
So try either passing YSATCdate<1> to the DSSetParam function or remove things first using Convert or EReplace:
Code: Select all
Convert(@FM,"",YSATCdate)
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
Hello,
both jobs have the LIB (string , no default) and JOBDATE (sting,no default) as parameter in the parameter tab.
I tried the option to use 'convert(..) , then ran the JOBCONTROL (wich than calls the YNKxx_NP_to_FLATFILE)
the JOBCONTROL control program says in the logs :
Current job parameters:
LIB=DSFIND
JOBDATE=2007-01-01 (wich i entered when launching )
LOG: YNKxx_to_FLAT_CONTROL..JobControl (Job Controller): ERROR -4
(bad value)
the underlying job YNKxx_NP_to_FLATFILE says in its log
Current job parameters:
LIB=DSFIND
JOBDATE=
LOG: YNKxx_NP_to_FLATFILE: Missing Parameters JOBDATE.
I did it several different ways , first using the convert in the job control program itself , secondly in the underlying job as
SELECT
.....
FROM
#LIB#.YNKNP AS YNKNP
WHERE YNKNP.NPDACR =Convert(@FM,"",#JOBDATE#)
(as before is was just WHERE YNKNP.NPDACR =#JOBDATE#
ps: NPDACR is set as Date.
All with the same result , both jobs abort .
I even tried to change the parameters to a string to avoid 'bad value', same result , I really dont know what I'm doing wrong but I must be missing something.
regards
Luc
below the code (part) as it is now ...
* --------------- read date from seq. file
OpenSeq 'E:\Ascential\DataStage\Projects\DSFIND\PILOT\YNKxx_JOBDATE.txt' To jobdatefile
Else Call DSLogWarn("Cannot open ":jobdatefile)
ReadSeq YSATCdate From jobdatefile * >>> file contains 1 record => 2006-01-01
Else Goto jobdatefilerror
jobdatefilerror:
If YSATCdate = 0 Then
check=@False
End
* --------------- Setup YNKxx_NP_to_FLATFILE, run it, wait for it to finish, and test for success
hJob1 = DSAttachJob("YNKxx_NP_to_FLATFILE", DSJ.ERRFATAL)
If NOT(hJob1) Then
Call DSLogFatal("Job Attach Failed: YNKxx_NP_to_FLATFILE", "JobControl")
Abort
End
* --------------- send message to loglisting
* Call DSLogInfo("Processing ":YSATCdate ,"Job Controller")
closeSeq jobdatefile
* --------------- Setup YNKxx_NP_to_FLATFILE, run it, wait for it to finish, and test for success
hJob4 = DSAttachJob("YNKxx_NP_to_FLATFILE", DSJ.ERRFATAL)
If NOT(hJob4) Then
Call DSLogFatal("Job Attach Failed: YNKxx_NP_to_FLATFILE", "JobControl")
Abort
End
ErrCode = DSSetParam(hJob4, "LIB", "DSFIND")
ErrCode = DSSetParam(hJob4, "JOBDATE", YSATCdate)
Call DSLogInfo("ERROR ":ErrCode ,"Job Controller")
ErrCode = DSSetDisableProjectHandler(hJob4, @FALSE)
ErrCode = DSSetDisableJobHandler(hJob4, @FALSE)
ErrCode = DSRunJob(hJob4, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(hJob4)
Status = DSGetJobInfo(hJob4, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED Then
* Fatal Error - No Return
Call DSLogFatal("Job Failed: YNKxx_NP_to_FLATFILE", "JobControl")
End
both jobs have the LIB (string , no default) and JOBDATE (sting,no default) as parameter in the parameter tab.
I tried the option to use 'convert(..) , then ran the JOBCONTROL (wich than calls the YNKxx_NP_to_FLATFILE)
the JOBCONTROL control program says in the logs :
Current job parameters:
LIB=DSFIND
JOBDATE=2007-01-01 (wich i entered when launching )
LOG: YNKxx_to_FLAT_CONTROL..JobControl (Job Controller): ERROR -4
(bad value)
the underlying job YNKxx_NP_to_FLATFILE says in its log
Current job parameters:
LIB=DSFIND
JOBDATE=
LOG: YNKxx_NP_to_FLATFILE: Missing Parameters JOBDATE.
I did it several different ways , first using the convert in the job control program itself , secondly in the underlying job as
SELECT
.....
FROM
#LIB#.YNKNP AS YNKNP
WHERE YNKNP.NPDACR =Convert(@FM,"",#JOBDATE#)
(as before is was just WHERE YNKNP.NPDACR =#JOBDATE#
ps: NPDACR is set as Date.
All with the same result , both jobs abort .
I even tried to change the parameters to a string to avoid 'bad value', same result , I really dont know what I'm doing wrong but I must be missing something.
regards
Luc
below the code (part) as it is now ...
* --------------- read date from seq. file
OpenSeq 'E:\Ascential\DataStage\Projects\DSFIND\PILOT\YNKxx_JOBDATE.txt' To jobdatefile
Else Call DSLogWarn("Cannot open ":jobdatefile)
ReadSeq YSATCdate From jobdatefile * >>> file contains 1 record => 2006-01-01
Else Goto jobdatefilerror
jobdatefilerror:
If YSATCdate = 0 Then
check=@False
End
* --------------- Setup YNKxx_NP_to_FLATFILE, run it, wait for it to finish, and test for success
hJob1 = DSAttachJob("YNKxx_NP_to_FLATFILE", DSJ.ERRFATAL)
If NOT(hJob1) Then
Call DSLogFatal("Job Attach Failed: YNKxx_NP_to_FLATFILE", "JobControl")
Abort
End
* --------------- send message to loglisting
* Call DSLogInfo("Processing ":YSATCdate ,"Job Controller")
closeSeq jobdatefile
* --------------- Setup YNKxx_NP_to_FLATFILE, run it, wait for it to finish, and test for success
hJob4 = DSAttachJob("YNKxx_NP_to_FLATFILE", DSJ.ERRFATAL)
If NOT(hJob4) Then
Call DSLogFatal("Job Attach Failed: YNKxx_NP_to_FLATFILE", "JobControl")
Abort
End
ErrCode = DSSetParam(hJob4, "LIB", "DSFIND")
ErrCode = DSSetParam(hJob4, "JOBDATE", YSATCdate)
Call DSLogInfo("ERROR ":ErrCode ,"Job Controller")
ErrCode = DSSetDisableProjectHandler(hJob4, @FALSE)
ErrCode = DSSetDisableJobHandler(hJob4, @FALSE)
ErrCode = DSRunJob(hJob4, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(hJob4)
Status = DSGetJobInfo(hJob4, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED Then
* Fatal Error - No Return
Call DSLogFatal("Job Failed: YNKxx_NP_to_FLATFILE", "JobControl")
End
Hmzz... i got a bit further now,
the JOBDATE is actually passed (added some logging in the subsequent job)
Call DSLogInfo("Processing YNKxx_NP_to_FLATFILE":JOBDATE ,"Job Controller")
Current job parameters:(for YNKxx_NP_to_FLATFILE)
LIB=DSFIND
JOBDATE="2006-01-01"
LOG says :
YNKxx_NP_to_FLATFILE..JobControl (Job Controller): Processing YNKxx_NP_to_FLATFILE"2006-01-01"
YNKxx_NP_to_FLATFILE..READ_YNKNP: [IBM][CLI Driver][AS] SQL0113N """" contains a character that is not allowed or does not contain any characters. SQLSTATE=42602
SQLExecDirect: Error executing statement 'SELECT
_ _ _ _ _
FROM
DSFIND.YNKNP AS YNKNP
WHERE YNKNP.NPDACR =Convert(@FM,"","2006-01-01")
'. See following DB2 message for details.
if I ran it on DB2 , it gives an error, change it to
SELECT * FROM
DSFIND.YNKNP AS YNKNP
WHERE char(YNKNP.NPDACR) ='2006-01-01'
and it works
so how do the " " come in ?
(sorry if I'm not clear , I'm working with DS for only 3 months now )
Regrads,
Luc
the JOBDATE is actually passed (added some logging in the subsequent job)
Call DSLogInfo("Processing YNKxx_NP_to_FLATFILE":JOBDATE ,"Job Controller")
Current job parameters:(for YNKxx_NP_to_FLATFILE)
LIB=DSFIND
JOBDATE="2006-01-01"
LOG says :
YNKxx_NP_to_FLATFILE..JobControl (Job Controller): Processing YNKxx_NP_to_FLATFILE"2006-01-01"
YNKxx_NP_to_FLATFILE..READ_YNKNP: [IBM][CLI Driver][AS] SQL0113N """" contains a character that is not allowed or does not contain any characters. SQLSTATE=42602
SQLExecDirect: Error executing statement 'SELECT
_ _ _ _ _
FROM
DSFIND.YNKNP AS YNKNP
WHERE YNKNP.NPDACR =Convert(@FM,"","2006-01-01")
'. See following DB2 message for details.
if I ran it on DB2 , it gives an error, change it to
SELECT * FROM
DSFIND.YNKNP AS YNKNP
WHERE char(YNKNP.NPDACR) ='2006-01-01'
and it works
so how do the " " come in ?
(sorry if I'm not clear , I'm working with DS for only 3 months now )
Regrads,
Luc
-
- Participant
- Posts: 612
- Joined: Thu May 03, 2007 4:59 am
- Location: Melbourne
In your job keep this as before : WHERE YNKNP.NPDACR =#JOBDATE# .
Between these 2 lines:
ErrCode = DSSetParam(hJob4, "LIB", "DSFIND")
ErrCode = DSSetParam(hJob4, "JOBDATE", YSATCdate)
Insert Convert(@FM,"",YSATCdate) and make it:
ErrCode = DSSetParam(hJob4, "LIB", "DSFIND")
YSATCdate = Convert(@FM,"",YSATCdate)
ErrCode = DSSetParam(hJob4, "JOBDATE", YSATCdate)
If you still have issue try this:
ErrCode = DSSetParam(hJob4, "LIB", "DSFIND")
YSATCdate = "'":Convert(@FM,"",YSATCdate) : "'"
ErrCode = DSSetParam(hJob4, "JOBDATE", YSATCdate)
or
If you still have issue try this:
ErrCode = DSSetParam(hJob4, "LIB", "DSFIND")
YSATCdate = "\'":Convert(@FM,"",YSATCdate) : "\'"
ErrCode = DSSetParam(hJob4, "JOBDATE", YSATCdate)
Between these 2 lines:
ErrCode = DSSetParam(hJob4, "LIB", "DSFIND")
ErrCode = DSSetParam(hJob4, "JOBDATE", YSATCdate)
Insert Convert(@FM,"",YSATCdate) and make it:
ErrCode = DSSetParam(hJob4, "LIB", "DSFIND")
YSATCdate = Convert(@FM,"",YSATCdate)
ErrCode = DSSetParam(hJob4, "JOBDATE", YSATCdate)
If you still have issue try this:
ErrCode = DSSetParam(hJob4, "LIB", "DSFIND")
YSATCdate = "'":Convert(@FM,"",YSATCdate) : "'"
ErrCode = DSSetParam(hJob4, "JOBDATE", YSATCdate)
or
If you still have issue try this:
ErrCode = DSSetParam(hJob4, "LIB", "DSFIND")
YSATCdate = "\'":Convert(@FM,"",YSATCdate) : "\'"
ErrCode = DSSetParam(hJob4, "JOBDATE", YSATCdate)
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
Ok,
Got it running , thing was that the " jept on appearing , even with the workarounds from JoshGeorge , so it had to be something else,
first i tried to write/read it straight from a file , same problem ...
than finally , the light went on while browsing trough all the options and settings of everything.. i saw somewhere delimiter =" , changed it to ' , all working fine now .
I did checked the file contents but only through DS, not on the server itself, there I'll probably should ,noticed the "2006-01-01"
instead of the 2006-01-01
btw, it was also in the log ...
LOG says :
YNKxx_NP_to_FLATFILE..JobControl (Job Controller): Processing YNKxx_NP_to_FLATFILE"2006-01-01"
thanx for al the help and sorry for the inconvience by my stupidity
Regards,
Luc
Got it running , thing was that the " jept on appearing , even with the workarounds from JoshGeorge , so it had to be something else,
first i tried to write/read it straight from a file , same problem ...
than finally , the light went on while browsing trough all the options and settings of everything.. i saw somewhere delimiter =" , changed it to ' , all working fine now .
I did checked the file contents but only through DS, not on the server itself, there I'll probably should ,noticed the "2006-01-01"
instead of the 2006-01-01
btw, it was also in the log ...
LOG says :
YNKxx_NP_to_FLATFILE..JobControl (Job Controller): Processing YNKxx_NP_to_FLATFILE"2006-01-01"
thanx for al the help and sorry for the inconvience by my stupidity
![Wink ;-)](./images/smilies/icon_wink.gif)
Regards,
Luc
If your quotes were always coming in around the DATE parameter's value, that would explain why it continued to complain about a 'bad value'. I would assume they came from the flat file you sourced from - quoted string there but brought in whole by your 'read'. So the answer all along may have been to remove the quotes and the Field Marks don't play any role here. The Convert function could still do that for you.
Anywho, sounds like things are resolved. Time to mark the post as Resolved as well then! :D
Anywho, sounds like things are resolved. Time to mark the post as Resolved as well then! :D
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers