Page 2 of 2

Posted: Fri Jan 02, 2009 12:08 pm
by chulett
Only execute the code to run those jobs if the 'result' value is greater than zero.

Posted: Fri Jan 02, 2009 12:54 pm
by sagar deshmukh

Code: Select all

 JobName = "srcDlyCalcTxns_LN"
      BatchName = DSGetJobInfo(DSJ.ME, DSJ.JOBNAME)
      result = DSGetLinkInfo(DSJ.JOBNAME,DSJ.ME,DSJ.ME,DSJ.LINKROWCOUNT)
      Errcode = RunRestartableJob(JobName,HASHPATH,BATCHNUMBER,"BATCHTIMESTAMP=":BatchStartDts)
      If Errcode Then
      GOTO ENDJOB
      
      End
      
      
      
      If result > 0 Then
      StgFileName = "LNREMIT"
      JobName = "xfmDlyCalcTxns_LN"
      BatchName = DSGetJobInfo(DSJ.ME, DSJ.JOBNAME)
      Errcode = RunRestartableJob(JobName,HASHPATH,BATCHNUMBER,"BATCHTIMESTAMP=":BatchStartDts)
      If Errcode Then
         GOTO ENDJOB
      End
      End
     
      
i used above codeits not working...its should call "xfmDlyCalcTxns_LN" as the input DataStage job has records flowing into the link....

what might be the problem?

Posted: Fri Jan 02, 2009 1:18 pm
by chulett
chulett wrote:You need to establish a handle to the "srcDlyCalcTxns_LN" job and not use DSJ.ME at all. The 2nd & 3rd arguments are Stage Name and Link Name respectively from the job the handle is attached to. And then detach the handle when you are done with it.

Posted: Fri Jan 02, 2009 1:30 pm
by sagar deshmukh

Code: Select all

 JobName = "hashProcessControlDTS"
      BatchName = DSGetJobInfo(DSJ.ME, DSJ.JOBNAME)
      Errcode = RunRestartableJob(JobName,HASHPATH,BATCHNUMBER,"BATCHTIMESTAMP=":BatchStartDts)
      If Errcode Then
         GOTO ENDJOB
      End

      JobName = "srcDlyCalcTxns_LN"
      BatchName = DSGetJobInfo(DSJ.ME, DSJ.JOBNAME)
      result = DSGetLinkInfo(DSJ.JOBNAME,DSJ."xfmDailyCalcTxns",DSJ."Xfm_DailyCalcTxns",DSJ.LINKROWCOUNT)
      Errcode = RunRestartableJob(JobName,HASHPATH,BATCHNUMBER,"BATCHTIMESTAMP=":BatchStartDts)
      If Errcode Then
         GOTO ENDJOB
      End
      
      If result > 0 Then 
      StgFileName = "LNREMIT"
      JobName = "xfmDlyCalcTxns_LN"
      BatchName = DSGetJobInfo(DSJ.ME, DSJ.JOBNAME)
      Errcode = RunRestartableJob(JobName,HASHPATH,BATCHNUMBER,"BATCHTIMESTAMP=":BatchStartDts)
      If Errcode Then
         GOTO ENDJOB
      End
      End

      

      JobName = "Batch::LNRemitMaintenance"
      BatchName = DSGetJobInfo(DSJ.ME, DSJ.JOBNAME)
      Errcode = RunRestartableJob(JobName,HASHPATH,BATCHNUMBER,"BATCHTIMESTAMP=":BatchStartDts)
      If Errcode Then
         GOTO ENDJOB
      End

      
      JobName = "ldiLNRemitProcessControl"
      BatchName = DSGetJobInfo(DSJ.ME, DSJ.JOBNAME)
      Errcode = RunRestartableJob(JobName,HASHPATH,BATCHNUMBER,"BATCHTIMESTAMP=":BatchStartDts)
      If Errcode Then
         GOTO ENDJOB
      End
If i use like this at the compilation only i will get error.....
imean if i give link and stage name indead of "ME"

Also it runs the code bt doesnt run the

Code: Select all

If result > 0 Then 
      StgFileName = "LNREMIT"
      JobName = "xfmDlyCalcTxns_LN"
      BatchName = DSGetJobInfo(DSJ.ME, DSJ.JOBNAME)
      Errcode = RunRestartableJob(JobName,HASHPATH,BATCHNUMBER,"BATCHTIMESTAMP=":BatchStartDts)
      If Errcode Then
         GOTO ENDJOB
      End
      End
where it should run above part as the input link had rows in previous job

Posted: Fri Jan 02, 2009 2:05 pm
by chulett
The first parameter needs to be a handle you establish, not a name. And the other two are just names, so get rid of the "DSJ." part. Bare bones code:

Code: Select all

JobName = "srcDlyCalcTxns_LN" 
hJob = DSAttachJob(JobName, DSJ.ERRNONE)
result = DSGetLinkInfo(hJob,"xfmDailyCalcTxns","Xfm_WriteLink",DSJ.LINKROWCOUNT)
x = DSDetachJob(hJob)
I had no idea what to put for the third argument. It cannot be the same as the second one which is the name of the transformer to check. So where I put "Xfm_WriteLink", replace it with the name of the link from the transformer you named that writes to the Sequential File stage.

Technically you should always check to make sure the handle could be established and was then detached successfully plus if the "result" is less than zero as that means an error in the DSGetLinkInfo() call.

:idea: And please, next time pay closer attention to the syntax details as written in the online help. You can also (typically) search the forums here for a function name and find examples of how others have used it. I just did for "dsgetlinkinfo" and got almost 300 matches in the forums here so plenty of examples are out there for this function.

Posted: Fri Jan 02, 2009 2:18 pm
by sagar deshmukh

Code: Select all

Batch::CopyOfLNRemitMaster..JobControl (fatal error from DSGetJobInfo): Job control fatal error (-1)
(DSGetJobInfo) Invalid job handle 2
after using your code i got above error

Posted: Fri Jan 02, 2009 2:26 pm
by chulett
[sigh] Nowhere in "my code" is there a call to DSGetJobInfo, so can't really help you there. You'd need to post your most current version of the code before I could even begin to guess what in the heck the problem is now.

Posted: Fri Jan 02, 2009 3:00 pm
by sagar deshmukh

Code: Select all

  DEFFUN RunRestartableJob(JobName,HASHPATH,BatchNumber,SKIPPARAM) Calling "DSU.RunRestartableJob"
      DEFFUN EmailErrorMessage(HASHPATH,BatchNumber) Calling "DSU.EmailErrorMessage"
      DEFFUN JobControlReset(JobList) Calling "DSU.JobControlReset"
      DEFFUN RunBatch(JobList, Params) Calling "DSU.RunBatch"
      DEFFUN ConvDateYYYYMMDD.DashDeltoMMDDYYYY(DATE) Calling "DSU.ConvDateYYYYMMDD.DashDeltoMMDDYYYY"
      DEFFUN GetHashValueByKey(File,Key) Calling "DSU.GetHashValueByKey"

      BatchStartDts = DSGetJobInfo(DSJ.ME, DSJ.JOBSTARTTIMESTAMP)

      
      JobName = "hashProcessControlDTS"
      BatchName = DSGetJobInfo(DSJ.ME, DSJ.JOBNAME)
      Errcode = RunRestartableJob(JobName,HASHPATH,BATCHNUMBER,"BATCHTIMESTAMP=":BatchStartDts)
      If Errcode Then
         GOTO ENDJOB
      End

      JobName = "srcDlyCalcTxns_LN"
      *BatchName = DSGetJobInfo(DSJ.ME, DSJ.JOBNAME)
      BatchName = DSGetJobInfo(JobName, DSJ.ERRNONE)
      result = DSGetLinkInfo(BatchName,"xfmDailyCalcTxns","Xfm_DailyCalcTxns",DSJ.LINKROWCOUNT)
            *result = DSGetLinkInfo(DSJ.JOBNAME,DSJ.ME,DSJ.ME,DSJ.LINKROWCOUNT)
      Errcode = RunRestartableJob(JobName,HASHPATH,BATCHNUMBER,"BATCHTIMESTAMP=":BatchStartDts)
      If Errcode Then
         GOTO ENDJOB
      End
      

   
      
      

      If result > 0 Then 
      StgFileName = "LNREMIT"
      JobName = "xfmDlyCalcTxns_LN"
      BatchName = DSGetJobInfo(DSJ.ME, DSJ.JOBNAME)
      Errcode = RunRestartableJob(JobName,HASHPATH,BATCHNUMBER,"BATCHTIMESTAMP=":BatchStartDts)
      If Errcode Then
         GOTO ENDJOB
      End
      End

      

      JobName = "Batch::LNRemitMaintenance"
      BatchName = DSGetJobInfo(DSJ.ME, DSJ.JOBNAME)
      Errcode = RunRestartableJob(JobName,HASHPATH,BATCHNUMBER,"BATCHTIMESTAMP=":BatchStartDts)
      If Errcode Then
         GOTO ENDJOB
      End

      
      JobName = "ldiLNRemitProcessControl"
      BatchName = DSGetJobInfo(DSJ.ME, DSJ.JOBNAME)
      Errcode = RunRestartableJob(JobName,HASHPATH,BATCHNUMBER,"BATCHTIMESTAMP=":BatchStartDts)
      If Errcode Then
         GOTO ENDJOB
      End


ENDJOB:
* Setup DailyPCJobStatsLdiNew, run it, wait for it to finish, and test for success
      JobName = "DailyPCJobStatsLdiNew.":BATCHNAME

      Result = JobControlReset(JobName)
      hJob1 = DSAttachJob(JobName, DSJ.ERRFATAL)
      If NOT(hJob1) Then
         Call DSLogFatal("Job Attach Failed: DailyPCJobStatsLdiNew", "JobControl")
         Abort
      End

      Errcode1 = DSSetParam(hJob1, "HASHPATH", HASHPATH)
      Errcode1 = DSSetParam(hJob1, "STGPATH", PROJDIR:STGPATH)
      Errcode1 = DSSetParam(hJob1, "BATCHNUMBER", BATCHNUMBER)
      Errcode1 = DSSetParam(hJob1, "SRCDBNAME", SRCDBNAME)
      Errcode1 = DSSetParam(hJob1, "SRCUSERID", SRCUSERID)
      Errcode1 = DSSetParam(hJob1, "SRCPWD", SRCPWD)
      Errcode1 = DSRunJob(hJob1, DSJ.RUNNORMAL)
      Errcode1 = DSWaitForJob(hJob1)
      Status = DSGetJobInfo(hJob1, DSJ.JOBSTATUS)
      If Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED Then
         * Fatal Error - No Return
         Call DSLogWarn("Job Failed: DailyPCJobStatsLdiNew", "JobControl")

      End

      If Errcode then
         *  Result = JobControlReset(BatchName)

         Message = EmailErrorMessage(HASHPATH,BATCHNUMBER)
         Reply = DSSendMail("From:":MSG_FROM:"\nTo:":MSG_TO:"\nServer:":SMTPSERVER:"\nSubject:":BatchName:" failed\nBody:":Message:"\n")
         Call DSLogFatal("Batch ran failed! (see warnings)", BatchName)
      End

*Clear Hash File.

      OPENPATH HASHPATH:"/":'hshJobInfo':BATCHNUMBER To hashPath Then
         CLEARFILE hashPath ON ERROR Call DSLogInfo("Cannot Clear the Log",BatchName)

this is my current code.

error am getting is

Code: Select all

Batch::CopyOfLNRemitMaster..JobControl (fatal error from DSGetJobInfo): Job control fatal error (-1)
(DSGetJobInfo) Invalid job handle srcDlyCalcTxns_LN

Posted: Fri Jan 02, 2009 3:10 pm
by ray.wurlod
As Craig has already told you more than once, you need a valid job handle. This part of the code is generating your error.

Code: Select all

JobName = "srcDlyCalcTxns_LN" 
      *BatchName = DSGetJobInfo(DSJ.ME, DSJ.JOBNAME) 
      BatchName = DSGetJobInfo(JobName, DSJ.ERRNONE) 
You must attach the job (assigning a job handle) and detach the job when done.

Posted: Fri Jan 02, 2009 3:11 pm
by chulett
I'm about to give up here. You are not paying attention to the guidance I am attempting to give, so what's the point in continuing this conversation? You did not heed the warnings in my post, did not incorporate "my code" into your code with the change I noted would be required and just continue to perpetuate the same issues over and over.

Reread what I posted.

Posted: Fri Jan 02, 2009 3:18 pm
by sagar deshmukh
I am realy really sorry Sir....Hats off to u....
finally it worked.....
i missed.."DSAttachJob" part....
sorry...i been working since more than 24 hrs so......brain not working...
thanks alot,.,,,,

Posted: Fri Jan 02, 2009 3:22 pm
by ray.wurlod
sagar deshmukh wrote:i been working since more than 24 hrs so......brain not working...
:idea:
Never do that.
ETL developer is a job that requires immense attention to detail.
You can not achieve the same if fatigued.

No correspondence will be entered into concerning this advice, deadlines or any of the other artificial constraints of a project plan.

Posted: Fri Jan 02, 2009 3:26 pm
by chulett
Exactly... go home, get some sleep - or at least take a power nap under your desk or something. After your brain turns to mush, 'being at work' is not quite the same thing as 'working'. Sometimes even well before that. :wink: